url
stringlengths
36
137
content
stringlengths
1.21k
7.75M
https://www.mongodb.com/docs/manual/reference/method/sp.listStreamProcessors/
<section> <h1 class="contains-headerlink leafygreen-ui-41fr9s" weight="medium"> sp.listStreamProcessors() <a class="headerlink leafygreen-ui-1kepx47" href="#sp.liststreamprocessors--" 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="sp.liststreamprocessors--"> </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="#definition" target="_self"> <span> Definition </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#syntax" target="_self"> <span> Syntax </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#command-fields" target="_self"> <span> Command Fields </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#behavior" target="_self"> <span> Behavior </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#access-control" target="_self"> <span> Access Control </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#example" target="_self"> <span> Example </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#learn-more" target="_self"> <span> Learn More </span> </a> </li> </ul> </div> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Definition <a class="headerlink leafygreen-ui-1kepx47" href="#definition" 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="definition"> </div> </a> </h2> <dl class="method"> <dt> <code class="leafygreen-ui-1l06pbn"> sp.listStreamProcessors() </code> <a class="headerlink leafygreen-ui-1kepx47" href="#mongodb-method-sp.listStreamProcessors" title="Permalink to this definition"> <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="mongodb-method-sp.listStreamProcessors"> </div> </a> </dt> <dd> </dd> </dl> <div> <p> <em> New <!-- --> in version <!-- --> 7.0 </em> : <!-- --> Returns documents for each named <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/atlas/atlas-sp/overview/#mongodb-expression-exp.Stream-Processor" target="_self"> <span> Stream Processor </span> </a> on the current <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/atlas/atlas-sp/overview/#mongodb-expression-exp.Stream-Processing-Instance" target="_self"> <span> Stream Processing Instance </span> </a> . Each document provides descriptive information including the name, current state, and pipeline of a stream processor. </p> </div> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Syntax <a class="headerlink leafygreen-ui-1kepx47" href="#syntax" 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="syntax"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> The <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-method-sp.listStreamProcessors" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> sp.listStreamProcessors() </code> </span> </a> method has the following syntax: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"sp.listStreamProcessors(\n {\n &lt;filter&gt;\n }\n)","programmingLanguage":"JSON"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" tabindex="-1"><code class="lg-highlight-hljs-light json leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">sp.listStreamProcessors(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-punctuation">{</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> &lt;filter&gt;</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-punctuation">}</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx">)</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> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Command Fields <a class="headerlink leafygreen-ui-1kepx47" href="#command-fields" 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="command-fields"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> <code class="leafygreen-ui-1l06pbn"> sp.listStreamProcessors() </code> takes these fields: </p> <div class="leafygreen-ui-skkc39" tabindex="0"> <table class="leafygreen-ui-hr8lsv"> <colgroup> <col style="width:20%"/> <col style="width:20%"/> <col style="width:20%"/> <col style="width:40%"/> </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> Field </div> </div> </th> <th class="leafygreen-ui-13uteka" role="columnheader" scope="col"> <div class="leafygreen-ui-ui0te9"> <div> Type </div> </div> </th> <th class="leafygreen-ui-13uteka" role="columnheader" scope="col"> <div class="leafygreen-ui-ui0te9"> <div> Necessity </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> <code class="leafygreen-ui-1l06pbn"> filter </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> document </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Optional </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Document specifying which fields to filter stream processors on. If you provide a filter, the command will only return those processors which match the values for all the fields you specify. </div> </div> </td> </tr> </tbody> </table> </div> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Behavior <a class="headerlink leafygreen-ui-1kepx47" href="#behavior" 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="behavior"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> <code class="leafygreen-ui-1l06pbn"> sp.listStreamProcessors() </code> returns documents describing all of the named stream processors on the current stream processing instance to <code class="leafygreen-ui-1l06pbn"> STDOUT </code> . </p> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Access Control <a class="headerlink leafygreen-ui-1kepx47" href="#access-control" 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="access-control"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> The user running <code class="leafygreen-ui-1l06pbn"> sp.listStreamProcessors() </code> must have the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/atlas/mongodb-users-roles-and-privileges/#mongodb-atlasrole-atlasAdmin" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> atlasAdmin </code> </span> </a> role. </p> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Example <a class="headerlink leafygreen-ui-1kepx47" href="#example" 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="example"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> The following example shows an expected response from <code class="leafygreen-ui-1l06pbn"> sp.listStreamProcessors() </code> when the command is called without any filter: </p> <div class="css-1f5771r"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"sp.listStreamProcessors()","programmingLanguage":"Shell"} </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 shell leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">sp.listStreamProcessors()</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="css-9st569 efa38qy0" style="--border-color:#E8EDEB"> <button aria-disabled="false" class="lg-ui-button-0000 leafygreen-ui-hix6y6" data-lgid="lg-button" role="button" type="button"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg alt="" aria-hidden="true" class="leafygreen-ui-hjnzs9" fill="none" height="16" role="presentation" viewbox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M14.364 10.778a1 1 0 0 0 0-1.414l-4.95-4.95-.707-.707a1 1 0 0 0-1.414 0l-.707.707-4.95 4.95a1 1 0 0 0 0 1.414l.707.707a1 1 0 0 0 1.414 0L8 7.243l4.243 4.242a1 1 0 0 0 1.414 0l.707-.707Z" fill="currentColor" fill-rule="evenodd"> </path> </svg> HIDE OUTPUT </div> </button> </div> <div class="leafygreen-ui-1oteowz"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{\n id: '0135',\n name: \"proc01\",\n last_modified: ISODate(\"2023-03-20T20:15:54.601Z\"),\n state: \"RUNNING\",\n error_msg: '',\n pipeline: [\n {\n $source: {\n connectionName: \"myKafka\",\n topic: \"stuff\"\n }\n },\n {\n $match: {\n temperature: 46\n }\n },\n {\n $emit: {\n connectionName: \"mySink\",\n topic: \"output\",\n }\n }\n ],\n lastStateChange: ISODate(\"2023-03-20T20:15:59.442Z\")\n},\n{\n id: '0218',\n name: \"proc02\",\n last_modified: ISODate(\"2023-03-21T20:17:33.601Z\"),\n state: \"STOPPED\",\n error_msg: '',\n pipeline: [\n {\n $source: {\n connectionName: \"myKafka\",\n topic: \"things\"\n }\n },\n {\n $match: {\n temperature: 41\n }\n },\n {\n $emit: {\n connectionName: \"mySink\",\n topic: \"results\",\n }\n }\n ],\n lastStateChange: ISODate(\"2023-03-21T20:18:26.139Z\")\n}","programmingLanguage":"JSON"} </script> <div class="css-1sax7hu e11q6jfk0" style="--code-container-border:initial;--code-pre-border:none"> <div class="leafygreen-ui-1fyvhqe"> <div class="leafygreen-ui-1jheeh3"> <pre class="leafygreen-ui-12cejcz" tabindex="-1"><code class="lg-highlight-hljs-dark json leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-1uztkne">1</td><td class="leafygreen-ui-7razhx"><span class="lg-highlight-punctuation">{</span></td></tr><tr class=""><td class="leafygreen-ui-1uztkne">2</td><td class="leafygreen-ui-7razhx"> id<span class="lg-highlight-punctuation">:</span> '<span class="lg-highlight-number">0135</span>'<span class="lg-highlight-punctuation">,</span></td></tr><tr class=""><td class="leafygreen-ui-1uztkne">3</td><td class="leafygreen-ui-7razhx"> name<span class="lg-highlight-punctuation">:</span> <span class="lg-highlight-string">"proc01"</span><span class="lg-highlight-punctuation">,</span></td></tr><tr class=""><td class="leafygreen-ui-1uztkne">4</td><td class="leafygreen-ui-7razhx"> last_modified<span class="lg-highlight-punctuation">:</span> ISODate(<span class="lg-highlight-string">"2023-03-20T20:15:54.601Z"</span>)<span class="lg-highlight-punctuation">,</span></td></tr><tr class=""><td class="leafygreen-ui-1uztkne">5</td><td class="leafygreen-ui-7razhx"> state<span class="lg-highlight-punctuation">:</span> <span class="lg-highlight-string">"RUNNING"</span><span class="lg-highlight-punctuation">,</span></td></tr><tr class=""><td class="leafygreen-ui-1uztkne">6</td><td class="leafygreen-ui-7razhx"> error_msg<span class="lg-highlight-punctuation">:</span> ''<span class="lg-highlight-punctuation">,</span></td></tr><tr class=""><td class="leafygreen-ui-1uztkne">7</td><td class="leafygreen-ui-7razhx"> pipeline<span class="lg-highlight-punctuation">:</span> <span class="lg-highlight-punctuation">[</span></td></tr><tr class=""><td class="leafygreen-ui-1uztkne">8</td><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-punctuation">{</span></td></tr><tr class=""><td class="leafygreen-ui-1uztkne">9</td><td class="leafygreen-ui-7razhx"> $source<span class="lg-highlight-punctuation">:</span> <span class="lg-highlight-punctuation">{</span></td></tr><tr class=""><td class="leafygreen-ui-1uztkne">10</td><td class="leafygreen-ui-7razhx"> connectionName<span class="lg-highlight-punctuation">:</span> <span class="lg-highlight-string">"myKafka"</span><span class="lg-highlight-punctuation">,</span></td></tr><tr class=""><td class="leafygreen-ui-1uztkne">11</td><td class="leafygreen-ui-7razhx"> topic<span class="lg-highlight-punctuation">:</span> <span class="lg-highlight-string">"stuff"</span></td></tr><tr class=""><td class="leafygreen-ui-1uztkne">12</td><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-punctuation">}</span></td></tr><tr class=""><td class="leafygreen-ui-1uztkne">13</td><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-punctuation">}</span><span class="lg-highlight-punctuation">,</span></td></tr><tr class=""><td class="leafygreen-ui-1uztkne">14</td><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-punctuation">{</span></td></tr><tr class=""><td class="leafygreen-ui-1uztkne">15</td><td class="leafygreen-ui-7razhx"> $match<span class="lg-highlight-punctuation">:</span> <span class="lg-highlight-punctuation">{</span></td></tr><tr class=""><td class="leafygreen-ui-1uztkne">16</td><td class="leafygreen-ui-7razhx"> temperature<span class="lg-highlight-punctuation">:</span> <span class="lg-highlight-number">46</span></td></tr><tr class=""><td class="leafygreen-ui-1uztkne">17</td><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-punctuation">}</span></td></tr><tr class=""><td class="leafygreen-ui-1uztkne">18</td><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-punctuation">}</span><span class="lg-highlight-punctuation">,</span></td></tr><tr class=""><td class="leafygreen-ui-1uztkne">19</td><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-punctuation">{</span></td></tr><tr class=""><td class="leafygreen-ui-1uztkne">20</td><td class="leafygreen-ui-7razhx"> $emit<span class="lg-highlight-punctuation">:</span> <span class="lg-highlight-punctuation">{</span></td></tr><tr class=""><td class="leafygreen-ui-1uztkne">21</td><td class="leafygreen-ui-7razhx"> connectionName<span class="lg-highlight-punctuation">:</span> <span class="lg-highlight-string">"mySink"</span><span class="lg-highlight-punctuation">,</span></td></tr><tr class=""><td class="leafygreen-ui-1uztkne">22</td><td class="leafygreen-ui-7razhx"> topic<span class="lg-highlight-punctuation">:</span> <span class="lg-highlight-string">"output"</span><span class="lg-highlight-punctuation">,</span></td></tr><tr class=""><td class="leafygreen-ui-1uztkne">23</td><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-punctuation">}</span></td></tr><tr class=""><td class="leafygreen-ui-1uztkne">24</td><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-punctuation">}</span></td></tr><tr class=""><td class="leafygreen-ui-1uztkne">25</td><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-punctuation">]</span><span class="lg-highlight-punctuation">,</span></td></tr><tr class=""><td class="leafygreen-ui-1uztkne">26</td><td class="leafygreen-ui-7razhx"> lastStateChange<span class="lg-highlight-punctuation">:</span> ISODate(<span class="lg-highlight-string">"2023-03-20T20:15:59.442Z"</span>)</td></tr><tr class=""><td class="leafygreen-ui-1uztkne">27</td><td class="leafygreen-ui-7razhx"><span class="lg-highlight-punctuation">}</span><span class="lg-highlight-punctuation">,</span></td></tr><tr class=""><td class="leafygreen-ui-1uztkne">28</td><td class="leafygreen-ui-7razhx"><span class="lg-highlight-punctuation">{</span></td></tr><tr class=""><td class="leafygreen-ui-1uztkne">29</td><td class="leafygreen-ui-7razhx"> id<span class="lg-highlight-punctuation">:</span> '<span class="lg-highlight-number">0218</span>'<span class="lg-highlight-punctuation">,</span></td></tr><tr class=""><td class="leafygreen-ui-1uztkne">30</td><td class="leafygreen-ui-7razhx"> name<span class="lg-highlight-punctuation">:</span> <span class="lg-highlight-string">"proc02"</span><span class="lg-highlight-punctuation">,</span></td></tr><tr class=""><td class="leafygreen-ui-1uztkne">31</td><td class="leafygreen-ui-7razhx"> last_modified<span class="lg-highlight-punctuation">:</span> ISODate(<span class="lg-highlight-string">"2023-03-21T20:17:33.601Z"</span>)<span class="lg-highlight-punctuation">,</span></td></tr><tr class=""><td class="leafygreen-ui-1uztkne">32</td><td class="leafygreen-ui-7razhx"> state<span class="lg-highlight-punctuation">:</span> <span class="lg-highlight-string">"STOPPED"</span><span class="lg-highlight-punctuation">,</span></td></tr><tr class=""><td class="leafygreen-ui-1uztkne">33</td><td class="leafygreen-ui-7razhx"> error_msg<span class="lg-highlight-punctuation">:</span> ''<span class="lg-highlight-punctuation">,</span></td></tr><tr class=""><td class="leafygreen-ui-1uztkne">34</td><td class="leafygreen-ui-7razhx"> pipeline<span class="lg-highlight-punctuation">:</span> <span class="lg-highlight-punctuation">[</span></td></tr><tr class=""><td class="leafygreen-ui-1uztkne">35</td><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-punctuation">{</span></td></tr><tr class=""><td class="leafygreen-ui-1uztkne">36</td><td class="leafygreen-ui-7razhx"> $source<span class="lg-highlight-punctuation">:</span> <span class="lg-highlight-punctuation">{</span></td></tr><tr class=""><td class="leafygreen-ui-1uztkne">37</td><td class="leafygreen-ui-7razhx"> connectionName<span class="lg-highlight-punctuation">:</span> <span class="lg-highlight-string">"myKafka"</span><span class="lg-highlight-punctuation">,</span></td></tr><tr class=""><td class="leafygreen-ui-1uztkne">38</td><td class="leafygreen-ui-7razhx"> topic<span class="lg-highlight-punctuation">:</span> <span class="lg-highlight-string">"things"</span></td></tr><tr class=""><td class="leafygreen-ui-1uztkne">39</td><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-punctuation">}</span></td></tr><tr class=""><td class="leafygreen-ui-1uztkne">40</td><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-punctuation">}</span><span class="lg-highlight-punctuation">,</span></td></tr><tr class=""><td class="leafygreen-ui-1uztkne">41</td><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-punctuation">{</span></td></tr><tr class=""><td class="leafygreen-ui-1uztkne">42</td><td class="leafygreen-ui-7razhx"> $match<span class="lg-highlight-punctuation">:</span> <span class="lg-highlight-punctuation">{</span></td></tr><tr class=""><td class="leafygreen-ui-1uztkne">43</td><td class="leafygreen-ui-7razhx"> temperature<span class="lg-highlight-punctuation">:</span> <span class="lg-highlight-number">41</span></td></tr><tr class=""><td class="leafygreen-ui-1uztkne">44</td><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-punctuation">}</span></td></tr><tr class=""><td class="leafygreen-ui-1uztkne">45</td><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-punctuation">}</span><span class="lg-highlight-punctuation">,</span></td></tr><tr class=""><td class="leafygreen-ui-1uztkne">46</td><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-punctuation">{</span></td></tr><tr class=""><td class="leafygreen-ui-1uztkne">47</td><td class="leafygreen-ui-7razhx"> $emit<span class="lg-highlight-punctuation">:</span> <span class="lg-highlight-punctuation">{</span></td></tr><tr class=""><td class="leafygreen-ui-1uztkne">48</td><td class="leafygreen-ui-7razhx"> connectionName<span class="lg-highlight-punctuation">:</span> <span class="lg-highlight-string">"mySink"</span><span class="lg-highlight-punctuation">,</span></td></tr><tr class=""><td class="leafygreen-ui-1uztkne">49</td><td class="leafygreen-ui-7razhx"> topic<span class="lg-highlight-punctuation">:</span> <span class="lg-highlight-string">"results"</span><span class="lg-highlight-punctuation">,</span></td></tr><tr class=""><td class="leafygreen-ui-1uztkne">50</td><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-punctuation">}</span></td></tr><tr class=""><td class="leafygreen-ui-1uztkne">51</td><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-punctuation">}</span></td></tr><tr class=""><td class="leafygreen-ui-1uztkne">52</td><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-punctuation">]</span><span class="lg-highlight-punctuation">,</span></td></tr><tr class=""><td class="leafygreen-ui-1uztkne">53</td><td class="leafygreen-ui-7razhx"> lastStateChange<span class="lg-highlight-punctuation">:</span> ISODate(<span class="lg-highlight-string">"2023-03-21T20:18:26.139Z"</span>)</td></tr><tr class=""><td class="leafygreen-ui-1uztkne">54</td><td class="leafygreen-ui-7razhx"><span class="lg-highlight-punctuation">}</span></td></tr></tbody></table></code></pre> </div> </div> </div> </div> </div> <p class="leafygreen-ui-1kp3ins"> The following example shows an expected response if you invoke <code class="leafygreen-ui-1l06pbn"> sp.listStreamProcessors() </code> filtering for only those stream processors with a <code class="leafygreen-ui-1l06pbn"> state </code> of <code class="leafygreen-ui-1l06pbn"> running </code> . </p> <div class="css-1f5771r"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"sp.listStreamProcessors({\"state\": \"running\"})","programmingLanguage":"Shell"} </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 shell leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">sp.listStreamProcessors({"state": "running"})</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="css-9st569 efa38qy0" style="--border-color:#E8EDEB"> <button aria-disabled="false" class="lg-ui-button-0000 leafygreen-ui-hix6y6" data-lgid="lg-button" role="button" type="button"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg alt="" aria-hidden="true" class="leafygreen-ui-hjnzs9" fill="none" height="16" role="presentation" viewbox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M14.364 10.778a1 1 0 0 0 0-1.414l-4.95-4.95-.707-.707a1 1 0 0 0-1.414 0l-.707.707-4.95 4.95a1 1 0 0 0 0 1.414l.707.707a1 1 0 0 0 1.414 0L8 7.243l4.243 4.242a1 1 0 0 0 1.414 0l.707-.707Z" fill="currentColor" fill-rule="evenodd"> </path> </svg> HIDE OUTPUT </div> </button> </div> <div class="leafygreen-ui-1oteowz"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{\n id: '0135',\n name: \"proc01\",\n last_modified: ISODate(\"2023-03-20T20:15:54.601Z\"),\n state: \"RUNNING\",\n error_msg: '',\n pipeline: [\n {\n $source: {\n connectionName: \"myKafka\",\n topic: \"stuff\"\n }\n },\n {\n $match: {\n temperature: 46\n }\n },\n {\n $emit: {\n connectionName: \"mySink\",\n topic: \"output\",\n }\n }\n ],\n lastStateChange: ISODate(\"2023-03-20T20:15:59.442Z\")\n}","programmingLanguage":"JSON"} </script> <div class="css-1sax7hu e11q6jfk0" style="--code-container-border:initial;--code-pre-border:none"> <div class="leafygreen-ui-1fyvhqe"> <div class="leafygreen-ui-1jheeh3"> <pre class="leafygreen-ui-12cejcz" tabindex="-1"><code class="lg-highlight-hljs-dark json leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-1uztkne">1</td><td class="leafygreen-ui-7razhx"><span class="lg-highlight-punctuation">{</span></td></tr><tr class=""><td class="leafygreen-ui-1uztkne">2</td><td class="leafygreen-ui-7razhx"> id<span class="lg-highlight-punctuation">:</span> '<span class="lg-highlight-number">0135</span>'<span class="lg-highlight-punctuation">,</span></td></tr><tr class=""><td class="leafygreen-ui-1uztkne">3</td><td class="leafygreen-ui-7razhx"> name<span class="lg-highlight-punctuation">:</span> <span class="lg-highlight-string">"proc01"</span><span class="lg-highlight-punctuation">,</span></td></tr><tr class=""><td class="leafygreen-ui-1uztkne">4</td><td class="leafygreen-ui-7razhx"> last_modified<span class="lg-highlight-punctuation">:</span> ISODate(<span class="lg-highlight-string">"2023-03-20T20:15:54.601Z"</span>)<span class="lg-highlight-punctuation">,</span></td></tr><tr class=""><td class="leafygreen-ui-1uztkne">5</td><td class="leafygreen-ui-7razhx"> state<span class="lg-highlight-punctuation">:</span> <span class="lg-highlight-string">"RUNNING"</span><span class="lg-highlight-punctuation">,</span></td></tr><tr class=""><td class="leafygreen-ui-1uztkne">6</td><td class="leafygreen-ui-7razhx"> error_msg<span class="lg-highlight-punctuation">:</span> ''<span class="lg-highlight-punctuation">,</span></td></tr><tr class=""><td class="leafygreen-ui-1uztkne">7</td><td class="leafygreen-ui-7razhx"> pipeline<span class="lg-highlight-punctuation">:</span> <span class="lg-highlight-punctuation">[</span></td></tr><tr class=""><td class="leafygreen-ui-1uztkne">8</td><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-punctuation">{</span></td></tr><tr class=""><td class="leafygreen-ui-1uztkne">9</td><td class="leafygreen-ui-7razhx"> $source<span class="lg-highlight-punctuation">:</span> <span class="lg-highlight-punctuation">{</span></td></tr><tr class=""><td class="leafygreen-ui-1uztkne">10</td><td class="leafygreen-ui-7razhx"> connectionName<span class="lg-highlight-punctuation">:</span> <span class="lg-highlight-string">"myKafka"</span><span class="lg-highlight-punctuation">,</span></td></tr><tr class=""><td class="leafygreen-ui-1uztkne">11</td><td class="leafygreen-ui-7razhx"> topic<span class="lg-highlight-punctuation">:</span> <span class="lg-highlight-string">"stuff"</span></td></tr><tr class=""><td class="leafygreen-ui-1uztkne">12</td><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-punctuation">}</span></td></tr><tr class=""><td class="leafygreen-ui-1uztkne">13</td><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-punctuation">}</span><span class="lg-highlight-punctuation">,</span></td></tr><tr class=""><td class="leafygreen-ui-1uztkne">14</td><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-punctuation">{</span></td></tr><tr class=""><td class="leafygreen-ui-1uztkne">15</td><td class="leafygreen-ui-7razhx"> $match<span class="lg-highlight-punctuation">:</span> <span class="lg-highlight-punctuation">{</span></td></tr><tr class=""><td class="leafygreen-ui-1uztkne">16</td><td class="leafygreen-ui-7razhx"> temperature<span class="lg-highlight-punctuation">:</span> <span class="lg-highlight-number">46</span></td></tr><tr class=""><td class="leafygreen-ui-1uztkne">17</td><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-punctuation">}</span></td></tr><tr class=""><td class="leafygreen-ui-1uztkne">18</td><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-punctuation">}</span><span class="lg-highlight-punctuation">,</span></td></tr><tr class=""><td class="leafygreen-ui-1uztkne">19</td><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-punctuation">{</span></td></tr><tr class=""><td class="leafygreen-ui-1uztkne">20</td><td class="leafygreen-ui-7razhx"> $emit<span class="lg-highlight-punctuation">:</span> <span class="lg-highlight-punctuation">{</span></td></tr><tr class=""><td class="leafygreen-ui-1uztkne">21</td><td class="leafygreen-ui-7razhx"> connectionName<span class="lg-highlight-punctuation">:</span> <span class="lg-highlight-string">"mySink"</span><span class="lg-highlight-punctuation">,</span></td></tr><tr class=""><td class="leafygreen-ui-1uztkne">22</td><td class="leafygreen-ui-7razhx"> topic<span class="lg-highlight-punctuation">:</span> <span class="lg-highlight-string">"output"</span><span class="lg-highlight-punctuation">,</span></td></tr><tr class=""><td class="leafygreen-ui-1uztkne">23</td><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-punctuation">}</span></td></tr><tr class=""><td class="leafygreen-ui-1uztkne">24</td><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-punctuation">}</span></td></tr><tr class=""><td class="leafygreen-ui-1uztkne">25</td><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-punctuation">]</span><span class="lg-highlight-punctuation">,</span></td></tr><tr class=""><td class="leafygreen-ui-1uztkne">26</td><td class="leafygreen-ui-7razhx"> lastStateChange<span class="lg-highlight-punctuation">:</span> ISODate(<span class="lg-highlight-string">"2023-03-20T20:15:59.442Z"</span>)</td></tr><tr class=""><td class="leafygreen-ui-1uztkne">27</td><td class="leafygreen-ui-7razhx"><span class="lg-highlight-punctuation">}</span></td></tr></tbody></table></code></pre> </div> </div> </div> </div> </div> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Learn More <a class="headerlink leafygreen-ui-1kepx47" href="#learn-more" 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="learn-more"> </div> </a> </h2> <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/atlas-sp/manage-stream-processor/" target="_self"> <span> Manage Stream Processors </span> </a> </p> </li> </ul> </section> </section>
https://www.mongodb.com/docs/manual/self-managed-deployments/
<section> <h1 class="contains-headerlink leafygreen-ui-41fr9s" weight="medium"> Self-Managed Deployments <a class="headerlink leafygreen-ui-1kepx47" href="#self-managed-deployments" 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="self-managed-deployments"> </div> </a> </h1> <p class="leafygreen-ui-1kp3ins"> These documents provide instructions on how to install and administer a self-managed MongoDB database. </p> <dl> <dt> <a class="leafygreen-ui-tqgtui" href="/docs/manual/installation/#std-label-tutorial-installation"> Install a Self-Managed Deployment </a> </dt> <dd class="css-1ufxuu7"> Learn how to install a self-managed MongoDB database deployment. </dd> <dt> <a class="leafygreen-ui-tqgtui" href="/docs/manual/administration/deploy-manage-self-managed-replica-sets/#std-label-deploy-manage-self-managed-replica-sets"> Deploy and Manage Self-Managed Replica Sets </a> </dt> <dd class="css-1ufxuu7"> Learn to deploy and manage replica sets in a self-managed database. </dd> <dt> <a class="leafygreen-ui-tqgtui" href="/docs/manual/administration/deploy-manage-self-managed-sharded-clusters/#std-label-deploy-manage-self-managed-sharded-clusters"> Deploy and Manage Self-Managed Sharded Clusters </a> </dt> <dd class="css-1ufxuu7"> Learn to deploy and manage sharded clusters in a self-managed database. </dd> <dt> <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/self-managed-storage/#std-label-self-managed-storage"> Self-Managed Storage </a> </dt> <dd class="css-1ufxuu7"> Learn about managing data in a self-managed MongoDB database. </dd> <dt> <a class="leafygreen-ui-tqgtui" href="/docs/manual/administration/self-managed-administration/#std-label-self-managed-administration"> Self-Managed Administration </a> </dt> <dd class="css-1ufxuu7"> Learn about administering a self-managed MongoDB database. </dd> <dt> <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/self-managed-security/#std-label-self-managed-security"> Self-Managed Security </a> </dt> <dd class="css-1ufxuu7"> Learn about security options for a self-managed MongoDB database. </dd> <dt> <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/text-search/on-prem/#std-label-text-search-on-prem"> Text Search for Self-Managed Deployments </a> </dt> <dd class="css-1ufxuu7"> Learn about using text search in a self-managed MongoDB database. </dd> </dl> </section>
https://www.mongodb.com/docs/manual/reference/method/sp.processor.start/
<section> <h1 class="contains-headerlink leafygreen-ui-41fr9s" weight="medium"> sp.processor.start() <a class="headerlink leafygreen-ui-1kepx47" href="#sp.processor.start--" 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="sp.processor.start--"> </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="#definition" target="_self"> <span> Definition </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#syntax" target="_self"> <span> Syntax </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#command-fields" target="_self"> <span> Command Fields </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#behavior" target="_self"> <span> Behavior </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#access-control" target="_self"> <span> Access Control </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#example" target="_self"> <span> Example </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#learn-more" target="_self"> <span> Learn More </span> </a> </li> </ul> </div> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Definition <a class="headerlink leafygreen-ui-1kepx47" href="#definition" 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="definition"> </div> </a> </h2> <dl class="method"> <dt> <code class="leafygreen-ui-1l06pbn"> sp.processor.start() </code> <a class="headerlink leafygreen-ui-1kepx47" href="#mongodb-method-sp.processor.start" title="Permalink to this definition"> <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="mongodb-method-sp.processor.start"> </div> </a> </dt> <dd> </dd> </dl> <div> <p> <em> New <!-- --> in version <!-- --> 7.0 </em> : <!-- --> Starts a named <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/atlas/atlas-sp/overview/#mongodb-expression-exp.Stream-Processor" target="_self"> <span> Stream Processor </span> </a> on the current <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/atlas/atlas-sp/overview/#mongodb-expression-exp.Stream-Processing-Instance" target="_self"> <span> Stream Processing Instance <!-- --> . </span> </a> </p> </div> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Syntax <a class="headerlink leafygreen-ui-1kepx47" href="#syntax" 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="syntax"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> The <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-method-sp.processor.start" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> sp.processor.start() </code> </span> </a> method has the following syntax: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"sp.processor.start()","programmingLanguage":"JSON"} </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 json leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">sp.processor.start()</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> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Command Fields <a class="headerlink leafygreen-ui-1kepx47" href="#command-fields" 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="command-fields"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> <code class="leafygreen-ui-1l06pbn"> sp.processor.start() </code> takes no fields. </p> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Behavior <a class="headerlink leafygreen-ui-1kepx47" href="#behavior" 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="behavior"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> <code class="leafygreen-ui-1l06pbn"> sp.processor.start() </code> starts a named stream processor on the current stream processing instance. The stream processor must be in a <code class="leafygreen-ui-1l06pbn"> STOPPED </code> state. If you invoke <code class="leafygreen-ui-1l06pbn"> sp.processor.start() </code> for a stream processor that is not <code class="leafygreen-ui-1l06pbn"> STOPPED </code> , <code class="leafygreen-ui-1l06pbn"> mongosh </code> will return an error. </p> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Access Control <a class="headerlink leafygreen-ui-1kepx47" href="#access-control" 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="access-control"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> The user running <code class="leafygreen-ui-1l06pbn"> sp.processor.start() </code> must have the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/atlas/mongodb-users-roles-and-privileges/#mongodb-atlasrole-atlasAdmin" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> atlasAdmin </code> </span> </a> role. </p> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Example <a class="headerlink leafygreen-ui-1kepx47" href="#example" 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="example"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> The following example starts a stream processor named <code class="leafygreen-ui-1l06pbn"> solarDemo </code> . </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"sp.solarDemo.start()","programmingLanguage":"Shell"} </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 shell leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">sp.solarDemo.start()</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> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Learn More <a class="headerlink leafygreen-ui-1kepx47" href="#learn-more" 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="learn-more"> </div> </a> </h2> <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/atlas-sp/manage-stream-processor/" target="_self"> <span> Manage Stream Processors </span> </a> </p> </li> </ul> </section> </section>
https://www.mongodb.com/docs/manual/geospatial-queries/
<section> <h1 class="contains-headerlink leafygreen-ui-41fr9s" weight="medium"> Geospatial Queries <a class="headerlink leafygreen-ui-1kepx47" href="#geospatial-queries" 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="geospatial-queries"> </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="#geospatial-data" target="_self"> <span> Geospatial Data </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#geospatial-indexes" target="_self"> <span> Geospatial Indexes </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#geospatial-queries-1" target="_self"> <span> Geospatial Queries </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#geospatial-models" target="_self"> <span> Geospatial Models </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#perform-geospatial-queries-in-atlas" target="_self"> <span> Perform Geospatial Queries in Atlas </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#examples" target="_self"> <span> Examples </span> </a> </li> </ul> </div> <p class="leafygreen-ui-1kp3ins"> MongoDB supports query operations on geospatial data. This section introduces MongoDB's geospatial features. </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 <!-- --> geospatial queries <!-- --> 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> <p class="leafygreen-ui-1kp3ins"> For deployments hosted in MongoDB Atlas, you can run geospatial queries in the UI by using the query <span class="guilabel css-h15tq0"> Filter </span> bar or aggregation builder. To learn more, see <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-geospatial-queries-atlas" target="_self"> <span> Perform Geospatial Queries in Atlas <!-- --> . </span> </a> </p> <span class="leafygreen-ui-1qnjd6d" id="std-label-geo-overview-location-data"> </span> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Geospatial Data <a class="headerlink leafygreen-ui-1kepx47" href="#geospatial-data" 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="geospatial-data"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> In MongoDB, you can store geospatial data as <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-geospatial-geojson" target="_self"> <span> GeoJSON </span> </a> objects or as <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-geospatial-legacy" target="_self"> <span> legacy coordinate pairs <!-- --> . </span> </a> </p> <span class="leafygreen-ui-1qnjd6d" id="std-label-geospatial-geojson"> </span> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> GeoJSON Objects <a class="headerlink leafygreen-ui-1kepx47" href="#geojson-objects" 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="geojson-objects"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> To calculate geometry over an Earth-like sphere, store your location data as <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/geojson/#std-label-geospatial-indexes-store-geojson"> GeoJSON objects <!-- --> . </a> </p> <p class="leafygreen-ui-1kp3ins"> To specify GeoJSON data, use an embedded document with: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> a field named <code class="leafygreen-ui-1l06pbn"> type </code> that specifies the GeoJSON object type, and </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> a field named <code class="leafygreen-ui-1l06pbn"> coordinates </code> that specifies the object's coordinates. </p> </li> </ul> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"&lt;field&gt;: { type: &lt;geojson&gt; , coordinates: &lt;coordinates&gt; }","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-1q4bxgx" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">&lt;<!-- -->field<!-- -->&gt;<!-- -->: <!-- -->{ <span class="lg-highlight-attr">type</span>: <!-- -->&lt;GeoJSON type&gt; , coordinates: &lt;coordinates&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-85da11" role="note"> <h2 class="leafygreen-ui-1ac4g5h"> Important </h2> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> If specifying latitude and longitude coordinates, list the <strong> longitude </strong> first, and then <strong> latitude </strong> . </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Valid longitude values are between <code class="leafygreen-ui-1l06pbn"> -180 </code> and <code class="leafygreen-ui-1l06pbn"> 180 </code> , both inclusive. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Valid latitude values are between <code class="leafygreen-ui-1l06pbn"> -90 </code> and <code class="leafygreen-ui-1l06pbn"> 90 </code> , both inclusive. </p> </li> </ul> </div> </div> <p class="leafygreen-ui-1kp3ins"> For example, to specify a <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/geojson/#std-label-geojson-point"> GeoJSON Point <!-- --> : </a> </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"location: {\n type: \"Point\",\n coordinates: [-73.856077, 40.848447]\n}","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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"><span class="lg-highlight-attr">location</span>: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">type</span>: <span class="lg-highlight-string">"Point"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">coordinates</span>: <!-- -->[<!-- -->-<span class="lg-highlight-number">73.856077</span>, <span class="lg-highlight-number">40.848447</span>]</td></tr><tr class=""><td class="leafygreen-ui-7razhx">}</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"> For a list of the GeoJSON objects supported in MongoDB as well as examples, see <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/geojson/#std-label-geospatial-indexes-store-geojson"> GeoJSON objects <!-- --> . </a> </p> <p class="leafygreen-ui-1kp3ins"> MongoDB geospatial queries on GeoJSON objects calculate on a sphere; MongoDB uses the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-WGS84"> WGS84 </a> reference system for geospatial queries on GeoJSON objects. </p> <span class="leafygreen-ui-1qnjd6d" id="std-label-geospatial-legacy"> </span> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Legacy Coordinate Pairs <a class="headerlink leafygreen-ui-1kepx47" href="#legacy-coordinate-pairs" 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="legacy-coordinate-pairs"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> To calculate distances on a Euclidean plane, store your location data as legacy coordinate pairs and use a <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-geo-2d" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> 2d </code> </span> </a> index. MongoDB supports spherical surface calculations on legacy coordinate pairs by using a <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-geo-2dsphere" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> 2dsphere </code> </span> </a> index if you manually convert the data to the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/geojson/#std-label-geojson-point"> GeoJSON Point type <!-- --> . </a> </p> <p class="leafygreen-ui-1kp3ins"> To specify data as legacy coordinate pairs, you can use either an array ( <em> preferred </em> ) or an embedded document. </p> <dl> <dt> Specify via an array ( <em> Preferred </em> ): </dt> <dd class="css-1ufxuu7"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"&lt;field&gt;: [ &lt;x&gt;, &lt;y&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">&lt;<!-- -->field<!-- -->&gt;<!-- -->: <!-- -->[ &lt;<!-- -->x<!-- -->&gt;<!-- -->,<!-- --> <!-- -->&lt;<!-- -->y<!-- -->&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"> If specifying latitude and longitude coordinates, list the <strong> longitude </strong> first and then <strong> latitude </strong> ; i.e. </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"&lt;field&gt;: [&lt;longitude&gt;, &lt;latitude&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">&lt;<!-- -->field<!-- -->&gt;<!-- -->: <!-- -->[&lt;<!-- -->longitude<!-- -->&gt;<!-- -->,<!-- --> <!-- -->&lt;<!-- -->latitude<!-- -->&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> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Valid longitude values are between <code class="leafygreen-ui-1l06pbn"> -180 </code> and <code class="leafygreen-ui-1l06pbn"> 180 </code> , both inclusive. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Valid latitude values are between <code class="leafygreen-ui-1l06pbn"> -90 </code> and <code class="leafygreen-ui-1l06pbn"> 90 </code> , both inclusive. </p> </li> </ul> </dd> <dt> Specify via an embedded document: </dt> <dd class="css-1ufxuu7"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"&lt;field&gt;: { &lt;field1&gt;: &lt;x&gt;, &lt;field2&gt;: &lt;y&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">&lt;<!-- -->field<!-- -->&gt;<!-- -->: <!-- -->{ &lt;<!-- -->field1<!-- -->&gt;<!-- -->: &lt;<!-- -->x<!-- -->&gt;<!-- -->,<!-- --> <!-- -->&lt;<!-- -->field2<!-- -->&gt;<!-- -->: &lt;<!-- -->y<!-- -->&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"> If specifying latitude and longitude coordinates, the first field, regardless of the field name, must contain the <strong> longitude </strong> value and the second field, the <strong> latitude </strong> value ; i.e. </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"&lt;field&gt;: { &lt;field1&gt;: &lt;longitude&gt;, &lt;field2&gt;: &lt;latitude&gt; }","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-1q4bxgx" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">&lt;<!-- -->field<!-- -->&gt;<!-- -->: <!-- -->{ &lt;<!-- -->field1<!-- -->&gt;<!-- -->: &lt;<!-- -->longitude<!-- -->&gt;<!-- -->,<!-- --> <!-- -->&lt;<!-- -->field2<!-- -->&gt;<!-- -->: &lt;<!-- -->latitude<!-- -->&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> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Valid longitude values are between <code class="leafygreen-ui-1l06pbn"> -180 </code> and <code class="leafygreen-ui-1l06pbn"> 180 </code> , both inclusive. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Valid latitude values are between <code class="leafygreen-ui-1l06pbn"> -90 </code> and <code class="leafygreen-ui-1l06pbn"> 90 </code> , both inclusive. </p> </li> </ul> </dd> </dl> <p class="leafygreen-ui-1kp3ins"> To specify legacy coordinate pairs, arrays are preferred over an embedded document as some languages do not guarantee associative map ordering. </p> <span class="leafygreen-ui-1qnjd6d" id="std-label-index-feature-geospatial"> </span> </section> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Geospatial Indexes <a class="headerlink leafygreen-ui-1kepx47" href="#geospatial-indexes" 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="geospatial-indexes"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> MongoDB provides the following geospatial index types to support geospatial queries. For more information on geospatial indexes, see <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/indexes/index-types/index-geospatial/#std-label-geospatial-index"> Geospatial Indexes <!-- --> . </a> </p> <span class="leafygreen-ui-1qnjd6d" id="std-label-geo-2dsphere"> </span> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> <code class="leafygreen-ui-1l06pbn"> 2dsphere </code> <a class="headerlink leafygreen-ui-1kepx47" href="#2dsphere" 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="2dsphere"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/indexes/index-types/geospatial/2dsphere/#std-label-2dsphere-index"> 2dsphere </a> indexes support queries that calculate <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-geospatial-geometry" target="_self"> <span> geometries on an earth-like sphere <!-- --> . </span> </a> </p> <p class="leafygreen-ui-1kp3ins"> To create a <code class="leafygreen-ui-1l06pbn"> 2dsphere </code> index, use the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/db.collection.createIndex/#mongodb-method-db.collection.createIndex"> <code class="leafygreen-ui-1l06pbn"> db.collection.createIndex() </code> </a> method and specify the string literal <code class="leafygreen-ui-1l06pbn"> "2dsphere" </code> as the index type: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.collection.createIndex( { &lt;location&gt; : \"2dsphere\" } )","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-1q4bxgx" tabindex="0"><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">createIndex</span>( <!-- -->{ <span class="lg-highlight-tag lg-highlight-xml">&lt;</span><span class="lg-highlight-name lg-highlight-tag lg-highlight-xml">location</span><span class="lg-highlight-tag lg-highlight-xml"> </span><span class="lg-highlight-attr lg-highlight-tag lg-highlight-xml">field</span><span class="lg-highlight-tag lg-highlight-xml">&gt;</span><span class="lg-highlight-xml"> : "2dsphere" } )</span></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"> where the <code class="leafygreen-ui-1l06pbn"> &lt;location field&gt; </code> is a field whose value is either a <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-geospatial-geojson" target="_self"> <span> GeoJSON object </span> </a> or a <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-geospatial-legacy" target="_self"> <span> legacy coordinates pair <!-- --> . </span> </a> </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"> If you try to create an index on a field that contains an array of geoJSON points, the index build fails and returns the following error: </p> <p class="leafygreen-ui-1kp3ins"> <code class="leafygreen-ui-1l06pbn"> MongoServerError: Index build failed </code> </p> </div> </div> <p class="leafygreen-ui-1kp3ins"> For more information on the <code class="leafygreen-ui-1l06pbn"> 2dsphere </code> index, see <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/indexes/index-types/geospatial/2dsphere/#std-label-2dsphere-index"> 2dsphere Indexes <!-- --> . </a> </p> <span class="leafygreen-ui-1qnjd6d" id="std-label-geo-2d"> </span> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> <code class="leafygreen-ui-1l06pbn"> 2d </code> <a class="headerlink leafygreen-ui-1kepx47" href="#2d" 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="2d"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/indexes/index-types/geospatial/2d/#std-label-2d-index"> 2d </a> indexes support queries that calculate <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-geospatial-geometry" target="_self"> <span> geometries on a two-dimensional plane </span> </a> . Although the index can support <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/query/nearSphere/#mongodb-query-op.-nearSphere"> <code class="leafygreen-ui-1l06pbn"> $nearSphere </code> </a> queries that calculate on a sphere, if possible, use the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-geo-2dsphere" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> 2dsphere </code> </span> </a> index for spherical queries. </p> <p class="leafygreen-ui-1kp3ins"> To create a <code class="leafygreen-ui-1l06pbn"> 2d </code> index, use the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/db.collection.createIndex/#mongodb-method-db.collection.createIndex"> <code class="leafygreen-ui-1l06pbn"> db.collection.createIndex() </code> </a> method, specifying the location field as the key and the string literal <code class="leafygreen-ui-1l06pbn"> "2d" </code> as the index type: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.collection.createIndex( { &lt;location&gt; : \"2d\" } )","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">createIndex</span>( <!-- -->{ <span class="lg-highlight-tag lg-highlight-xml">&lt;</span><span class="lg-highlight-name lg-highlight-tag lg-highlight-xml">location</span><span class="lg-highlight-tag lg-highlight-xml"> </span><span class="lg-highlight-attr lg-highlight-tag lg-highlight-xml">field</span><span class="lg-highlight-tag lg-highlight-xml">&gt;</span><span class="lg-highlight-xml"> : "2d" } )</span></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"> where the <code class="leafygreen-ui-1l06pbn"> &lt;location field&gt; </code> is a field whose value is a <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-geospatial-legacy" target="_self"> <span> legacy coordinates pair <!-- --> . </span> </a> </p> <p class="leafygreen-ui-1kp3ins"> For more information on the <code class="leafygreen-ui-1l06pbn"> 2d </code> index, see <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/indexes/index-types/geospatial/2d/#std-label-2d-index"> 2d Indexes <!-- --> . </a> </p> </section> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Geospatial Queries <a class="headerlink leafygreen-ui-1kepx47" href="#geospatial-queries-1" 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="geospatial-queries-1"> </div> </a> </h2> <div class="leafygreen-ui-15mdk4" role="note"> <h2 class="leafygreen-ui-6n7b7d"> Note </h2> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> Using a <code class="leafygreen-ui-1l06pbn"> 2d </code> index for queries on spherical data can return incorrect results or an error. For example, <code class="leafygreen-ui-1l06pbn"> 2d </code> indexes don't support spherical queries that wrap around the poles. </p> </div> </div> <span class="leafygreen-ui-1qnjd6d" id="std-label-geospatial-operators"> </span> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Geospatial Query Operators <a class="headerlink leafygreen-ui-1kepx47" href="#geospatial-query-operators" 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="geospatial-query-operators"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> MongoDB provides the following geospatial query operators. For more details, including examples, see the respective reference pages. </p> <div class="leafygreen-ui-skkc39" tabindex="0"> <table class="leafygreen-ui-hr8lsv"> <colgroup> <col style="width:30%"/> <col style="width:70%"/> </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> Name </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/query/geoIntersects/#mongodb-query-op.-geoIntersects"> <code class="leafygreen-ui-1l06pbn"> $geoIntersects </code> </a> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Selects geometries that intersect with a <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-GeoJSON"> GeoJSON </a> geometry. The <code class="leafygreen-ui-1l06pbn"> 2dsphere </code> index supports <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/query/geoIntersects/#mongodb-query-op.-geoIntersects"> <code class="leafygreen-ui-1l06pbn"> $geoIntersects </code> . </a> </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/query/geoWithin/#mongodb-query-op.-geoWithin"> <code class="leafygreen-ui-1l06pbn"> $geoWithin </code> </a> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Selects geometries within a bounding <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/geojson/#std-label-geospatial-indexes-store-geojson"> GeoJSON geometry </a> . The <code class="leafygreen-ui-1l06pbn"> 2dsphere </code> and <code class="leafygreen-ui-1l06pbn"> 2d </code> indexes support <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/query/geoWithin/#mongodb-query-op.-geoWithin"> <code class="leafygreen-ui-1l06pbn"> $geoWithin </code> . </a> </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/query/near/#mongodb-query-op.-near"> <code class="leafygreen-ui-1l06pbn"> $near </code> </a> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Returns geospatial objects in proximity to a point. Requires a geospatial index. The <code class="leafygreen-ui-1l06pbn"> 2dsphere </code> and <code class="leafygreen-ui-1l06pbn"> 2d </code> indexes support <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/query/near/#mongodb-query-op.-near"> <code class="leafygreen-ui-1l06pbn"> $near </code> . </a> </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/query/nearSphere/#mongodb-query-op.-nearSphere"> <code class="leafygreen-ui-1l06pbn"> $nearSphere </code> </a> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Returns geospatial objects in proximity to a point on a sphere. Requires a geospatial index. The <code class="leafygreen-ui-1l06pbn"> 2dsphere </code> and <code class="leafygreen-ui-1l06pbn"> 2d </code> indexes support <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/query/nearSphere/#mongodb-query-op.-nearSphere"> <code class="leafygreen-ui-1l06pbn"> $nearSphere </code> . </a> </div> </div> </td> </tr> </tbody> </table> </div> <div class="leafygreen-ui-15mdk4" role="note"> <h2 class="leafygreen-ui-6n7b7d"> Note </h2> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> Time series collections only support the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/geoNear/#mongodb-pipeline-pipe.-geoNear"> <code class="leafygreen-ui-1l06pbn"> $geoNear </code> </a> aggregation stage for sorting <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-geospatial-queries" target="_self"> <span> geospatial data </span> </a> from queries against <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/indexes/index-types/geospatial/2dsphere/#std-label-2dsphere-index"> 2dsphere </a> indexes. You can't use <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/query/near/#mongodb-query-op.-near"> <code class="leafygreen-ui-1l06pbn"> $near </code> </a> and <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/query/nearSphere/#mongodb-query-op.-nearSphere"> <code class="leafygreen-ui-1l06pbn"> $nearSphere </code> </a> operators on time series collections </p> </div> </div> <span class="leafygreen-ui-1qnjd6d" id="std-label-geospatial-aggregation"> </span> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Geospatial Aggregation Stage <a class="headerlink leafygreen-ui-1kepx47" href="#geospatial-aggregation-stage" 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="geospatial-aggregation-stage"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> MongoDB provides the following geospatial <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/aggregation-pipeline/#std-label-aggregation-pipeline"> aggregation pipeline stage <!-- --> : </a> </p> <div class="leafygreen-ui-skkc39" tabindex="0"> <table class="leafygreen-ui-hr8lsv"> <colgroup> <col style="width:38%"/> <col style="width:72%"/> </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/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> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/geoNear/#mongodb-pipeline-pipe.-geoNear"> <code class="leafygreen-ui-1l06pbn"> $geoNear </code> </a> requires a <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-index-feature-geospatial" target="_self"> <span> geospatial index <!-- --> . </span> </a> </p> </div> </div> </td> </tr> </tbody> </table> </div> <p class="leafygreen-ui-1kp3ins"> For more details, including examples, see <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/geoNear/#mongodb-pipeline-pipe.-geoNear"> <code class="leafygreen-ui-1l06pbn"> $geoNear </code> </a> reference page. </p> <span class="leafygreen-ui-1qnjd6d" id="std-label-geospatial-geometry"> </span> </section> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Geospatial Models <a class="headerlink leafygreen-ui-1kepx47" href="#geospatial-models" 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="geospatial-models"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> MongoDB geospatial queries can interpret geometry on a flat surface or a sphere. </p> <p class="leafygreen-ui-1kp3ins"> <code class="leafygreen-ui-1l06pbn"> 2dsphere </code> indexes support only spherical queries (i.e. queries that interpret geometries on a spherical surface). </p> <p class="leafygreen-ui-1kp3ins"> <code class="leafygreen-ui-1l06pbn"> 2d </code> indexes support flat queries (i.e. queries that interpret geometries on a flat surface) and some spherical queries. While <code class="leafygreen-ui-1l06pbn"> 2d </code> indexes support some spherical queries, the use of <code class="leafygreen-ui-1l06pbn"> 2d </code> indexes for these spherical queries can result in error. If possible, use <code class="leafygreen-ui-1l06pbn"> 2dsphere </code> indexes for spherical queries. </p> <p class="leafygreen-ui-1kp3ins"> The following table lists the geospatial query operators, supported query, used by each geospatial operations: </p> <div class="leafygreen-ui-skkc39" tabindex="0"> <table class="leafygreen-ui-hr8lsv"> <colgroup> <col style="width:48%"/> <col style="width:12%"/> <col style="width:40%"/> </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> Operation </div> </div> </th> <th class="leafygreen-ui-13uteka" role="columnheader" scope="col"> <div class="leafygreen-ui-ui0te9"> <div> Spherical/Flat Query </div> </div> </th> <th class="leafygreen-ui-13uteka" role="columnheader" scope="col"> <div class="leafygreen-ui-ui0te9"> <div> Notes </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/query/near/#mongodb-query-op.-near"> <code class="leafygreen-ui-1l06pbn"> $near </code> </a> ( <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-geospatial-geojson" target="_self"> <span> GeoJSON </span> </a> centroid point in this line and the following line, <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-geo-2dsphere" target="_self"> <span> 2dsphere </span> </a> index) </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Spherical </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> See also the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/query/nearSphere/#mongodb-query-op.-nearSphere"> <code class="leafygreen-ui-1l06pbn"> $nearSphere </code> </a> operator, which provides the same functionality when used with <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-geospatial-geojson" target="_self"> <span> GeoJSON </span> </a> and a <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-geo-2dsphere" target="_self"> <span> 2dsphere </span> </a> index. </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/query/near/#mongodb-query-op.-near"> <code class="leafygreen-ui-1l06pbn"> $near </code> </a> ( <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-geospatial-legacy" target="_self"> <span> legacy coordinates </span> </a> , <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-geo-2d" target="_self"> <span> 2d </span> </a> index) </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Flat </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <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/query/nearSphere/#mongodb-query-op.-nearSphere"> <code class="leafygreen-ui-1l06pbn"> $nearSphere </code> </a> ( <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-geospatial-geojson" target="_self"> <span> GeoJSON </span> </a> point, <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-geo-2dsphere" target="_self"> <span> 2dsphere </span> </a> index) </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Spherical </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <p class="leafygreen-ui-1kp3ins"> Provides the same functionality as <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/query/near/#mongodb-query-op.-near"> <code class="leafygreen-ui-1l06pbn"> $near </code> </a> operation that uses <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-geospatial-geojson" target="_self"> <span> GeoJSON </span> </a> point and a <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-geo-2dsphere" target="_self"> <span> 2dsphere </span> </a> index. </p> <p class="leafygreen-ui-1kp3ins"> For spherical queries, it may be preferable to use <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/query/nearSphere/#mongodb-query-op.-nearSphere"> <code class="leafygreen-ui-1l06pbn"> $nearSphere </code> </a> which explicitly specifies the spherical queries in the name rather than <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/query/near/#mongodb-query-op.-near"> <code class="leafygreen-ui-1l06pbn"> $near </code> </a> operator. </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/query/nearSphere/#mongodb-query-op.-nearSphere"> <code class="leafygreen-ui-1l06pbn"> $nearSphere </code> </a> ( <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-geospatial-legacy" target="_self"> <span> legacy coordinates </span> </a> , <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-geo-2d" target="_self"> <span> 2d </span> </a> index) </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Spherical </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Use <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-GeoJSON"> GeoJSON </a> points instead. </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/query/geoWithin/#mongodb-query-op.-geoWithin"> <code class="leafygreen-ui-1l06pbn"> $geoWithin </code> </a> : { <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/query/geometry/#mongodb-query-op.-geometry"> <code class="leafygreen-ui-1l06pbn"> $geometry </code> </a> : ... } </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Spherical </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <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/query/geoWithin/#mongodb-query-op.-geoWithin"> <code class="leafygreen-ui-1l06pbn"> $geoWithin </code> </a> : { <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/query/box/#mongodb-query-op.-box"> <code class="leafygreen-ui-1l06pbn"> $box </code> </a> : ... } </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Flat </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <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/query/geoWithin/#mongodb-query-op.-geoWithin"> <code class="leafygreen-ui-1l06pbn"> $geoWithin </code> </a> : { <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/query/polygon/#mongodb-query-op.-polygon"> <code class="leafygreen-ui-1l06pbn"> $polygon </code> </a> : ... } </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Flat </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <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/query/geoWithin/#mongodb-query-op.-geoWithin"> <code class="leafygreen-ui-1l06pbn"> $geoWithin </code> </a> : { <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/query/center/#mongodb-query-op.-center"> <code class="leafygreen-ui-1l06pbn"> $center </code> </a> : ... } </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Flat </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <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/query/geoWithin/#mongodb-query-op.-geoWithin"> <code class="leafygreen-ui-1l06pbn"> $geoWithin </code> </a> : { <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/query/centerSphere/#mongodb-query-op.-centerSphere"> <code class="leafygreen-ui-1l06pbn"> $centerSphere </code> </a> : ... } </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Spherical </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <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/query/geoIntersects/#mongodb-query-op.-geoIntersects"> <code class="leafygreen-ui-1l06pbn"> $geoIntersects </code> </a> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Spherical </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <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/geoNear/#mongodb-pipeline-pipe.-geoNear"> <code class="leafygreen-ui-1l06pbn"> $geoNear </code> </a> aggregation stage ( <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-geo-2dsphere" target="_self"> <span> 2dsphere </span> </a> index) </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Spherical </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <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/geoNear/#mongodb-pipeline-pipe.-geoNear"> <code class="leafygreen-ui-1l06pbn"> $geoNear </code> </a> aggregation stage ( <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-geo-2d" target="_self"> <span> 2d </span> </a> index) </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Flat </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> </div> </div> </td> </tr> </tbody> </table> </div> <span class="leafygreen-ui-1qnjd6d" id="std-label-geospatial-queries-atlas"> </span> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Perform Geospatial Queries in Atlas <a class="headerlink leafygreen-ui-1kepx47" href="#perform-geospatial-queries-in-atlas" 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="perform-geospatial-queries-in-atlas"> </div> </a> </h2> <div aria-hidden="true"> </div> <div class="leafygreen-ui-1b75luy" data-lgid="lg-tabs"> <div class="leafygreen-ui-jp7pox" id="tabs-20"> <div aria-label="Tabs to describe usage of aggregation/filter-bar" aria-orientation="horizontal" class="leafygreen-ui-m8p1vb lg-ui-tab-list-0000" data-lgid="lg-tabs-tab_list" role="tablist"> <button aria-controls="_totm7wzlz" aria-selected="true" class="leafygreen-ui-1l773z1" data-text="" id="_a7w4zcb3w" name="" role="tab" tabindex="0"> <div class="leafygreen-ui-1nxuzmg"> Query Filter Bar </div> </button> <button aria-controls="_5hzykgtbc" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_s9pe0uthu" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Aggregation </div> </button> </div> <div class="leafygreen-ui-ov1ktg"> <div class="leafygreen-ui-1sg2lsz"> </div> </div> </div> <div class="lg-ui-tab-panels-0000" data-lgid="lg-tabs-tab_panels"> <div> <div aria-labelledby="_xnfp52xy0" class="" id="_hknq692g0" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <p class="leafygreen-ui-1kp3ins"> You can use the MongoDB Atlas UI to perform geospatial queries in Atlas. </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"HowTo","steps":[{"@type":"HowToStep","text":"If your geospatial collection does not already have a geospatial\nindex, you must create one.Select the database for the collection.The main panel and Namespaces on the left side\nlist the collections in the database.Select the collection.Select the collection that contains your geospatial data on\nthe left-hand side or in the main panel. The main panel displays\nthe Find, Indexes, and\nAggregation views.Select the Index view.When you open the Index view, Atlas\ndisplays any indexes that exist on the collection.Define the Index for the geo TypePress the Create Index button.Define a geo Type index. Refer to\nHow to Index GeoJSON Objects.","name":"Create an index"},{"@type":"HowToStep","text":"Select the Find view.From the collection that contains your geospatial\ndata, select the Find tab to view your geospatial\ncollection.Enter a query.Enter a query in the Filter text box. Use\nany of the geospatial query operators to perform the relevant query\non your geospatial data. A geospatial query might resemble:Press the Apply button.Press the Apply button to apply your query.\nAtlas filters the geospatial data to show only documents\nthat match your geospatial query.","name":"Query the geospatial data"}],"name":"Perform Geospatial Queries in Atlas - Query Filter Bar","image":"https://webimages.mongodb.com/_com_assets/cms/kuyj2focmkbxv7gh3-stacked_default_slate_blue.svg?auto=format%252Ccompress"} </script> <div class="css-4nyere eccljxs0"> <div class="css-1nuklj8 e1ckbxcu1"> <div class="css-18fui5z e1ckbxcu0"> <div class="css-19lsqsq e1ckbxcu2"> 1 </div> </div> <div class="css-1ed38mk"> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Create an index <a class="headerlink leafygreen-ui-1kepx47" href="#create-an-index" 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="create-an-index"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> If your geospatial collection does not already have a geospatial index, you must create one. </p> <ol class="leafygreen-ui-rioki0" type="1"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Select the database for the collection. </p> <p class="leafygreen-ui-1kp3ins"> The main panel and <span class="guilabel css-h15tq0"> Namespaces </span> on the left side list the collections in the database. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Select the collection. </p> <p class="leafygreen-ui-1kp3ins"> Select the collection that contains your geospatial data on the left-hand side or in the main panel. The main panel displays the <span class="guilabel css-h15tq0"> Find </span> , <span class="guilabel css-h15tq0"> Indexes </span> , and <span class="guilabel css-h15tq0"> Aggregation </span> views. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Select the Index view. </p> <p class="leafygreen-ui-1kp3ins"> When you open the <span class="guilabel css-h15tq0"> Index </span> view, Atlas displays any indexes that exist on the collection. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Define the Index for the geo Type </p> <p class="leafygreen-ui-1kp3ins"> Press the <span class="guilabel css-h15tq0"> Create Index </span> button. </p> <p class="leafygreen-ui-1kp3ins"> Define a geo Type index. Refer to <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/atlas/atlas-search/field-types/geo-type/" target="_self"> <span> How to Index GeoJSON Objects <!-- --> . </span> </a> </p> </li> </ol> </section> </div> </div> <div class="css-1nuklj8 e1ckbxcu1"> <div class="css-18fui5z e1ckbxcu0"> <div class="css-19lsqsq e1ckbxcu2"> 2 </div> </div> <div class="css-1ed38mk"> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Query the geospatial data <a class="headerlink leafygreen-ui-1kepx47" href="#query-the-geospatial-data" 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="query-the-geospatial-data"> </div> </a> </h3> <ol class="leafygreen-ui-rioki0" type="1"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Select the Find view. </p> <p class="leafygreen-ui-1kp3ins"> From the collection that contains your geospatial data, select the <span class="guilabel css-h15tq0"> Find </span> tab to view your geospatial collection. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Enter a query. </p> <p class="leafygreen-ui-1kp3ins"> Enter a query in the <span class="guilabel css-h15tq0"> Filter </span> text box. Use any of the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-geospatial-operators" target="_self"> <span> geospatial query operators </span> </a> to perform the relevant query on your geospatial data. A geospatial query might resemble: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{\n \"coordinates\": {\n $geoWithin: {\n $geometry: {\n type: \"Polygon\",\n coordinates: [\n [\n [-80.0, 10.00], [ -80.0, 9.00], [ -79.0, 9.0], [ -79.0, 10.00 ], [ -80.0, 10.0 ]\n ]\n ]\n }\n }\n }\n}","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"coordinates"</span>: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">$geoWithin</span>: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">$geometry</span>: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">type</span>: <span class="lg-highlight-string">"Polygon"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">coordinates</span>: <!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->[<!-- -->-<span class="lg-highlight-number">80.0</span>, <span class="lg-highlight-number">10.00</span>]<!-- -->, <!-- -->[ <!-- -->-<span class="lg-highlight-number">80.0</span>, <span class="lg-highlight-number">9.00</span>]<!-- -->, <!-- -->[ <!-- -->-<span class="lg-highlight-number">79.0</span>, <span class="lg-highlight-number">9.0</span>]<!-- -->, <!-- -->[ <!-- -->-<span class="lg-highlight-number">79.0</span>, <span class="lg-highlight-number">10.00</span> ]<!-- -->, <!-- -->[ <!-- -->-<span class="lg-highlight-number">80.0</span>, <span class="lg-highlight-number">10.0</span> ]</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> ]</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> ]</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">}</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> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Press the Apply button. </p> <p class="leafygreen-ui-1kp3ins"> Press the <span class="guilabel css-h15tq0"> Apply </span> button to apply your query. Atlas filters the geospatial data to show only documents that match your geospatial query. </p> </li> </ol> </section> </div> </div> </div> </div> </div> </div> <div> <div aria-labelledby="_abol26cnz" class="leafygreen-ui-38lglc" id="_rjsmml9e9" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <p class="leafygreen-ui-1kp3ins"> You can create and execute aggregation pipelines to perform geospatial queries in the MongoDB Atlas UI. </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"HowTo","steps":[{"@type":"HowToStep","text":"Select the database for the collection.The main panel and Namespaces on the left side list the\ncollections in the database.Select the collection.Select the collection that contains your geospatial data on\nthe left-hand side or in the main panel. The main panel displays\nthe Find, Indexes, and\nAggregation views.Select the Aggregation view.When you first open the Aggregation view, Atlas\ndisplays an empty aggregation pipeline.","name":"Access the aggregation pipeline builder"},{"@type":"HowToStep","text":"Select an aggregation stage.Select an aggregation stage from the Select dropdown in\nthe bottom-left panel.The toggle to the right of the dropdown dictates whether the\nstage is enabled.Use the $geoNear stage to perform geospatial\nqueries in your aggregation pipeline.Fill in your aggregation stage.Fill in your stage with the appropriate values.\nIf Comment Mode is enabled, the pipeline\nbuilder provides syntactic guidelines for your selected stage.As you modify your stage, Atlas updates the preview documents on\nthe right based on the results of the current stage.Your $geoNear stage may resemble:Run other pipeline stages as needed.Add stages as needed to complete your aggregation pipeline.\nYou might add $out or\n$merge to write the results to a\nview or the current collection.","name":"Create your geospatial query aggregation pipeline"}],"name":"Perform Geospatial Queries in Atlas - Aggregation","image":"https://webimages.mongodb.com/_com_assets/cms/kuyj2focmkbxv7gh3-stacked_default_slate_blue.svg?auto=format%252Ccompress"} </script> <div class="css-4nyere eccljxs0"> <div class="css-1nuklj8 e1ckbxcu1"> <div class="css-18fui5z e1ckbxcu0"> <div class="css-19lsqsq e1ckbxcu2"> 1 </div> </div> <div class="css-1ed38mk"> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Access the aggregation pipeline builder <a class="headerlink leafygreen-ui-1kepx47" href="#access-the-aggregation-pipeline-builder" 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="access-the-aggregation-pipeline-builder"> </div> </a> </h3> <ol class="leafygreen-ui-rioki0" type="1"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Select the database for the collection. </p> <p class="leafygreen-ui-1kp3ins"> The main panel and <span class="guilabel css-h15tq0"> Namespaces </span> on the left side list the collections in the database. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Select the collection. </p> <p class="leafygreen-ui-1kp3ins"> Select the collection that contains your geospatial data on the left-hand side or in the main panel. The main panel displays the <span class="guilabel css-h15tq0"> Find </span> , <span class="guilabel css-h15tq0"> Indexes </span> , and <span class="guilabel css-h15tq0"> Aggregation </span> views. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Select the Aggregation view. </p> <p class="leafygreen-ui-1kp3ins"> When you first open the <span class="guilabel css-h15tq0"> Aggregation </span> view, Atlas displays an empty aggregation pipeline. </p> </li> </ol> </section> </div> </div> <div class="css-1nuklj8 e1ckbxcu1"> <div class="css-18fui5z e1ckbxcu0"> <div class="css-19lsqsq e1ckbxcu2"> 2 </div> </div> <div class="css-1ed38mk"> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Create your geospatial query aggregation pipeline <a class="headerlink leafygreen-ui-1kepx47" href="#create-your-geospatial-query-aggregation-pipeline" 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="create-your-geospatial-query-aggregation-pipeline"> </div> </a> </h3> <ol class="leafygreen-ui-rioki0" type="1"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Select an aggregation stage. </p> <p class="leafygreen-ui-1kp3ins"> Select an aggregation stage from the <span class="guilabel css-h15tq0"> Select </span> dropdown in the bottom-left panel. </p> <p class="leafygreen-ui-1kp3ins"> The toggle to the right of the dropdown dictates whether the stage is enabled. </p> <p class="leafygreen-ui-1kp3ins"> Use the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/geoNear/#mongodb-pipeline-pipe.-geoNear"> <code class="leafygreen-ui-1l06pbn"> $geoNear </code> </a> stage to perform geospatial queries in your aggregation pipeline. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Fill in your aggregation stage. </p> <p class="leafygreen-ui-1kp3ins"> Fill in your stage with the appropriate values. If <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/atlas/atlas-ui/agg-pipeline/#std-label-pipeline-settings" target="_self"> <span> Comment Mode </span> </a> is enabled, the pipeline builder provides syntactic guidelines for your selected stage. </p> <p class="leafygreen-ui-1kp3ins"> As you modify your stage, Atlas updates the preview documents on the right based on the results of the current stage. </p> <p class="leafygreen-ui-1kp3ins"> Your <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/geoNear/#mongodb-pipeline-pipe.-geoNear"> <code class="leafygreen-ui-1l06pbn"> $geoNear </code> </a> stage may resemble: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{\n near: { type: \"Point\", coordinates: [ -73.9667, 40.78 ] },\n spherical: true,\n query: { category: \"Parks\" },\n distanceField: \"calcDistance\"\n}","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">near</span>: <!-- -->{ <span class="lg-highlight-attr">type</span>: <span class="lg-highlight-string">"Point"</span>, <span class="lg-highlight-attr">coordinates</span>: <!-- -->[ <!-- -->-<span class="lg-highlight-number">73.9667</span>, <span class="lg-highlight-number">40.78</span> ] }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">spherical</span>: <span class="lg-highlight-literal">true</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">query</span>: <!-- -->{ <span class="lg-highlight-attr">category</span>: <span class="lg-highlight-string">"Parks"</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">distanceField</span>: <span class="lg-highlight-string">"calcDistance"</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx">}</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> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Run other pipeline stages as needed. </p> <p class="leafygreen-ui-1kp3ins"> Add stages as needed to complete your aggregation pipeline. You might add <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/out/#mongodb-pipeline-pipe.-out"> <code class="leafygreen-ui-1l06pbn"> $out </code> </a> or <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/merge/#mongodb-pipeline-pipe.-merge"> <code class="leafygreen-ui-1l06pbn"> $merge </code> </a> to write the results to a view or the current collection. </p> </li> </ol> </section> </div> </div> </div> </div> </div> </div> </div> </div> <span class="leafygreen-ui-1qnjd6d" id="std-label-geospatial-query-examples"> </span> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Examples <a class="headerlink leafygreen-ui-1kepx47" href="#examples" 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="examples"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> Create a collection <code class="leafygreen-ui-1l06pbn"> places </code> with the following documents: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.places.insertMany( [\n {\n name: \"Central Park\",\n location: { type: \"Point\", coordinates: [ -73.97, 40.77 ] },\n category: \"Parks\"\n },\n {\n name: \"Sara D. Roosevelt Park\",\n location: { type: \"Point\", coordinates: [ -73.9928, 40.7193 ] },\n category: \"Parks\"\n },\n {\n name: \"Polo Grounds\",\n location: { type: \"Point\", coordinates: [ -73.9375, 40.8303 ] },\n category: \"Stadiums\"\n }\n] )","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><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">places</span>.<span class="lg-highlight-title lg-highlight-function">insertMany</span>( <!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">name</span>: <span class="lg-highlight-string">"Central Park"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">location</span>: <!-- -->{ <span class="lg-highlight-attr">type</span>: <span class="lg-highlight-string">"Point"</span>, <span class="lg-highlight-attr">coordinates</span>: <!-- -->[ <!-- -->-<span class="lg-highlight-number">73.97</span>, <span class="lg-highlight-number">40.77</span> ] }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">category</span>: <span class="lg-highlight-string">"Parks"</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">name</span>: <span class="lg-highlight-string">"Sara D. Roosevelt Park"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">location</span>: <!-- -->{ <span class="lg-highlight-attr">type</span>: <span class="lg-highlight-string">"Point"</span>, <span class="lg-highlight-attr">coordinates</span>: <!-- -->[ <!-- -->-<span class="lg-highlight-number">73.9928</span>, <span class="lg-highlight-number">40.7193</span> ] }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">category</span>: <span class="lg-highlight-string">"Parks"</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">name</span>: <span class="lg-highlight-string">"Polo Grounds"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">location</span>: <!-- -->{ <span class="lg-highlight-attr">type</span>: <span class="lg-highlight-string">"Point"</span>, <span class="lg-highlight-attr">coordinates</span>: <!-- -->[ <!-- -->-<span class="lg-highlight-number">73.9375</span>, <span class="lg-highlight-number">40.8303</span> ] }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">category</span>: <span class="lg-highlight-string">"Stadiums"</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">] )</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 operation creates a <code class="leafygreen-ui-1l06pbn"> 2dsphere </code> index on the <code class="leafygreen-ui-1l06pbn"> location </code> field: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.places.createIndex( { location: \"2dsphere\" } )","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">places</span>.<span class="lg-highlight-title lg-highlight-function">createIndex</span>( <!-- -->{ <span class="lg-highlight-attr">location</span>: <span class="lg-highlight-string">"2dsphere"</span> } )</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 <code class="leafygreen-ui-1l06pbn"> places </code> collection above has a <code class="leafygreen-ui-1l06pbn"> 2dsphere </code> index. The following query uses the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/query/near/#mongodb-query-op.-near"> <code class="leafygreen-ui-1l06pbn"> $near </code> </a> operator to return documents that are at least 1000 meters from and at most 5000 meters from the specified GeoJSON point, sorted in order from nearest to farthest: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.places.find(\n {\n location:\n { $near:\n {\n $geometry: { type: \"Point\", coordinates: [ -73.9667, 40.78 ] },\n $minDistance: 1000,\n $maxDistance: 5000\n }\n }\n }\n)","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><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">places</span>.<span class="lg-highlight-title lg-highlight-function">find</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">location</span>:</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">$near</span>:</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">$geometry</span>: <!-- -->{ <span class="lg-highlight-attr">type</span>: <span class="lg-highlight-string">"Point"</span>, <span class="lg-highlight-attr">coordinates</span>: <!-- -->[ <!-- -->-<span class="lg-highlight-number">73.9667</span>, <span class="lg-highlight-number">40.78</span> ] }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">$minDistance</span>: <span class="lg-highlight-number">1000</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">$maxDistance</span>: <span class="lg-highlight-number">5000</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">)</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 operation uses the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/geoNear/#mongodb-pipeline-pipe.-geoNear"> <code class="leafygreen-ui-1l06pbn"> $geoNear </code> </a> aggregation operation to return documents that match the query filter <code class="leafygreen-ui-1l06pbn"> { category: "Parks" } </code> , sorted in order of nearest to farthest to the specified GeoJSON point: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.places.aggregate( [\n {\n $geoNear: {\n near: { type: \"Point\", coordinates: [ -73.9667, 40.78 ] },\n spherical: true,\n query: { category: \"Parks\" },\n distanceField: \"calcDistance\"\n }\n }\n] )","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><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">places</span>.<span class="lg-highlight-title lg-highlight-function">aggregate</span>( <!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">$geoNear</span>: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">near</span>: <!-- -->{ <span class="lg-highlight-attr">type</span>: <span class="lg-highlight-string">"Point"</span>, <span class="lg-highlight-attr">coordinates</span>: <!-- -->[ <!-- -->-<span class="lg-highlight-number">73.9667</span>, <span class="lg-highlight-number">40.78</span> ] }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">spherical</span>: <span class="lg-highlight-literal">true</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">query</span>: <!-- -->{ <span class="lg-highlight-attr">category</span>: <span class="lg-highlight-string">"Parks"</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">distanceField</span>: <span class="lg-highlight-string">"calcDistance"</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">] )</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> </section> </section>
https://www.mongodb.com/docs/manual/tutorial/geospatial-tutorial/
<section> <h1 class="contains-headerlink leafygreen-ui-41fr9s" weight="medium"> Find Restaurants with Geospatial Queries <a class="headerlink leafygreen-ui-1kepx47" href="#find-restaurants-with-geospatial-queries" 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="find-restaurants-with-geospatial-queries"> </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="#overview" target="_self"> <span> Overview </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#distortion" target="_self"> <span> Distortion </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#searching-for-restaurants" target="_self"> <span> Searching for Restaurants </span> </a> </li> </ul> </div> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Overview <a class="headerlink leafygreen-ui-1kepx47" href="#overview" 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="overview"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> MongoDB's <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-geospatial"> geospatial </a> indexing allows you to efficiently execute spatial queries on a collection that contains geospatial shapes and points. To showcase the capabilities of geospatial features and compare different approaches, this tutorial will guide you through the process of writing queries for a simple geospatial application. </p> <p class="leafygreen-ui-1kp3ins"> This tutorial will briefly introduce the concepts of geospatial indexes, and then demonstrate their use with <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/query/geoWithin/#mongodb-query-op.-geoWithin"> <code class="leafygreen-ui-1l06pbn"> $geoWithin </code> </a> , <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/query/geoIntersects/#mongodb-query-op.-geoIntersects"> <code class="leafygreen-ui-1l06pbn"> $geoIntersects </code> </a> , and <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/query/nearSphere/#mongodb-query-op.-nearSphere"> <code class="leafygreen-ui-1l06pbn"> $nearSphere </code> . </a> </p> <p class="leafygreen-ui-1kp3ins"> Suppose you are designing a mobile application to help users find restaurants in New York City. The application must: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Determine the user's current neighborhood using <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/query/geoIntersects/#mongodb-query-op.-geoIntersects"> <code class="leafygreen-ui-1l06pbn"> $geoIntersects </code> , </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Show the number of restaurants in that neighborhood using <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/query/geoWithin/#mongodb-query-op.-geoWithin"> <code class="leafygreen-ui-1l06pbn"> $geoWithin </code> </a> , and </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Find restaurants within a specified distance of the user using <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/query/nearSphere/#mongodb-query-op.-nearSphere"> <code class="leafygreen-ui-1l06pbn"> $nearSphere </code> . </a> </p> </li> </ul> <p class="leafygreen-ui-1kp3ins"> This tutorial will use a <code class="leafygreen-ui-1l06pbn"> 2dsphere </code> index to query for this data on spherical geometry. </p> <p class="leafygreen-ui-1kp3ins"> For more information on spherical and flat geometries, see <a class="leafygreen-ui-tqgtui" href="/docs/manual/geospatial-queries/#std-label-geospatial-geometry"> Geospatial Models <!-- --> . </a> </p> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Distortion <a class="headerlink leafygreen-ui-1kepx47" href="#distortion" 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="distortion"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> Spherical geometry will appear distorted when visualized on a map due to the nature of projecting a three dimensional sphere, such as the earth, onto a flat plane. </p> <p class="leafygreen-ui-1kp3ins"> For example, take the specification of the spherical square defined by the longitude latitude points <code class="leafygreen-ui-1l06pbn"> (0,0) </code> , <code class="leafygreen-ui-1l06pbn"> (80,0) </code> , <code class="leafygreen-ui-1l06pbn"> (80,80) </code> , and <code class="leafygreen-ui-1l06pbn"> (0,80) </code> . The following figure depicts the area covered by this region: </p> <div class="css-18h91be ej97su30"> <div role="button" tabindex="-1"> <div class="gatsby-image-wrapper gatsby-image-wrapper-constrained leafygreen-ui-12xaq6r" data-gatsby-image-wrapper=""> <div style="max-width:1194px;display:block"> <img alt="" aria-hidden="true" role="presentation" src="data:image/svg+xml;charset=utf-8,%3Csvg%20height='1170'%20width='1194'%20xmlns='http://www.w3.org/2000/svg'%20version='1.1'%3E%3C/svg%3E" style="max-width:100%;display:block;position:static"/> </div> <div aria-hidden="true" data-placeholder-image="" style="opacity:1;transition:opacity 500ms linear"> </div> <img alt="Diagram of a square projected onto a sphere." data-main-image="" decoding="async" height="1170" loading="lazy" sizes="(min-width: 1194px) 1194px, 100vw" src="/docs/manual/static/3dc97d5ac62601b63ead0ecdd6118792/86600/geospatial-spherical-square.webp" srcset="/docs/manual/static/3dc97d5ac62601b63ead0ecdd6118792/65cef/geospatial-spherical-square.webp 299w,/docs/manual/static/3dc97d5ac62601b63ead0ecdd6118792/02df5/geospatial-spherical-square.webp 597w,/docs/manual/static/3dc97d5ac62601b63ead0ecdd6118792/86600/geospatial-spherical-square.webp 1194w" style="--border-color:#C1C7C6;opacity:0" width="1194"/> <noscript> <img alt="Diagram of a square projected onto a sphere." data-gatsby-image-ssr="" data-main-image="" decoding="async" height="1170" loading="lazy" sizes="(min-width: 1194px) 1194px, 100vw" src="/docs/manual/static/3dc97d5ac62601b63ead0ecdd6118792/86600/geospatial-spherical-square.webp" srcset="/docs/manual/static/3dc97d5ac62601b63ead0ecdd6118792/65cef/geospatial-spherical-square.webp 299w,/docs/manual/static/3dc97d5ac62601b63ead0ecdd6118792/02df5/geospatial-spherical-square.webp 597w,/docs/manual/static/3dc97d5ac62601b63ead0ecdd6118792/86600/geospatial-spherical-square.webp 1194w" style="--border-color:#C1C7C6;opacity:0" width="1194"/> </noscript> <script type="module"> const t="undefined"!=typeof HTMLImageElement&&"loading"in HTMLImageElement.prototype;if(t){const t=document.querySelectorAll("img[data-main-image]");for(let e of t){e.dataset.src&&(e.setAttribute("src",e.dataset.src),e.removeAttribute("data-src")),e.dataset.srcset&&(e.setAttribute("srcset",e.dataset.srcset),e.removeAttribute("data-srcset"));const t=e.parentNode.querySelectorAll("source[data-srcset]");for(let e of t)e.setAttribute("srcset",e.dataset.srcset),e.removeAttribute("data-srcset");e.complete&&(e.style.opacity=1,e.parentNode.parentNode.querySelector("[data-placeholder-image]").style.opacity=0)}} </script> </div> <div class="css-19pi7x2 ej97su31" style="--color:#444"> click to enlarge </div> </div> </div> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Searching for Restaurants <a class="headerlink leafygreen-ui-1kepx47" href="#searching-for-restaurants" 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="searching-for-restaurants"> </div> </a> </h2> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Prerequisites <a class="headerlink leafygreen-ui-1kepx47" href="#prerequisites" 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="prerequisites"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> Download the example datasets from <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://raw.githubusercontent.com/mongodb/docs-assets/geospatial/neighborhoods.json" rel="noopener noreferrer"> <span> https://raw.githubusercontent.com/mongodb/docs-assets/geospatial/neighborhoods.json </span> <svg alt="" aria-hidden="true" class="leafygreen-ui-1ie5kuq" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M13.823 2.4491C13.8201 2.30008 13.6999 2.17994 13.5509 2.17704L9.5062 2.09836C9.25654 2.09351 9.12821 2.39519 9.30482 2.5718L10.3856 3.65257L7.93433 6.10383C7.87964 6.15852 7.83047 6.21665 7.78683 6.27752L5.99909 8.06525C5.46457 8.59977 5.46457 9.4664 5.99909 10.0009C6.53361 10.5354 7.40023 10.5354 7.93475 10.0009L9.72249 8.21317C9.78336 8.16953 9.84148 8.12037 9.89618 8.06567L12.3474 5.61441L13.4282 6.69518C13.6048 6.87179 13.9065 6.74347 13.9016 6.4938L13.823 2.4491Z" fill="currentColor"> </path> <path d="M7.25 3.12893C7.66421 3.12893 8 3.46472 8 3.87893C8 4.29315 7.66421 4.62893 7.25 4.62893H4C3.72386 4.62893 3.5 4.85279 3.5 5.12893V11.9929C3.5 12.2691 3.72386 12.4929 4 12.4929H10.864C11.1401 12.4929 11.364 12.2691 11.364 11.9929V8.75C11.364 8.33579 11.6998 8 12.114 8C12.5282 8 12.864 8.33579 12.864 8.75V11.9929C12.864 13.0975 11.9686 13.9929 10.864 13.9929H4C2.89543 13.9929 2 13.0975 2 11.9929V5.12893C2 4.02436 2.89543 3.12893 4 3.12893H7.25Z" fill="currentColor"> </path> </svg> </a> and <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://raw.githubusercontent.com/mongodb/docs-assets/geospatial/restaurants.json" rel="noopener noreferrer"> <span> https://raw.githubusercontent.com/mongodb/docs-assets/geospatial/restaurants.json </span> <svg alt="" aria-hidden="true" class="leafygreen-ui-1ie5kuq" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M13.823 2.4491C13.8201 2.30008 13.6999 2.17994 13.5509 2.17704L9.5062 2.09836C9.25654 2.09351 9.12821 2.39519 9.30482 2.5718L10.3856 3.65257L7.93433 6.10383C7.87964 6.15852 7.83047 6.21665 7.78683 6.27752L5.99909 8.06525C5.46457 8.59977 5.46457 9.4664 5.99909 10.0009C6.53361 10.5354 7.40023 10.5354 7.93475 10.0009L9.72249 8.21317C9.78336 8.16953 9.84148 8.12037 9.89618 8.06567L12.3474 5.61441L13.4282 6.69518C13.6048 6.87179 13.9065 6.74347 13.9016 6.4938L13.823 2.4491Z" fill="currentColor"> </path> <path d="M7.25 3.12893C7.66421 3.12893 8 3.46472 8 3.87893C8 4.29315 7.66421 4.62893 7.25 4.62893H4C3.72386 4.62893 3.5 4.85279 3.5 5.12893V11.9929C3.5 12.2691 3.72386 12.4929 4 12.4929H10.864C11.1401 12.4929 11.364 12.2691 11.364 11.9929V8.75C11.364 8.33579 11.6998 8 12.114 8C12.5282 8 12.864 8.33579 12.864 8.75V11.9929C12.864 13.0975 11.9686 13.9929 10.864 13.9929H4C2.89543 13.9929 2 13.0975 2 11.9929V5.12893C2 4.02436 2.89543 3.12893 4 3.12893H7.25Z" fill="currentColor"> </path> </svg> </a> . These contain the collections <code class="leafygreen-ui-1l06pbn"> restaurants </code> and <code class="leafygreen-ui-1l06pbn"> neighborhoods </code> respectively. </p> <p class="leafygreen-ui-1kp3ins"> After downloading the datasets, import them into the database: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"mongoimport &lt;path&gt; -c=restaurants\nmongoimport &lt;path&gt; -c=neighborhoods","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">mongoimport <!-- -->&lt;<!-- -->path to restaurants.<span class="lg-highlight-property">json</span>&gt; <!-- -->-<!-- -->c<!-- -->=<!-- -->restaurants</td></tr><tr class=""><td class="leafygreen-ui-7razhx">mongoimport <!-- -->&lt;<!-- -->path to neighborhoods.<span class="lg-highlight-property">json</span>&gt; <!-- -->-<!-- -->c<!-- -->=<!-- -->neighborhoods</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"> A geospatial index, and almost always improves performance of <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/query/geoWithin/#mongodb-query-op.-geoWithin"> <code class="leafygreen-ui-1l06pbn"> $geoWithin </code> </a> and <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/query/geoIntersects/#mongodb-query-op.-geoIntersects"> <code class="leafygreen-ui-1l06pbn"> $geoIntersects </code> </a> queries. </p> <p class="leafygreen-ui-1kp3ins"> Because this data is geographical, create a <code class="leafygreen-ui-1l06pbn"> 2dsphere </code> index on each collection using <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/mongodb-shell/#mongodb-binary-bin.mongosh" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongosh </code> : </span> </a> </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.restaurants.createIndex({ location: \"2dsphere\" })\ndb.neighborhoods.createIndex({ geometry: \"2dsphere\" })","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">restaurants</span>.<span class="lg-highlight-title lg-highlight-function">createIndex</span>(<!-- -->{ <span class="lg-highlight-attr">location</span>: <span class="lg-highlight-string">"2dsphere"</span> })</td></tr><tr class=""><td class="leafygreen-ui-7razhx">db.<span class="lg-highlight-property">neighborhoods</span>.<span class="lg-highlight-title lg-highlight-function">createIndex</span>(<!-- -->{ <span class="lg-highlight-attr">geometry</span>: <span class="lg-highlight-string">"2dsphere"</span> })</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> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Exploring the Data <a class="headerlink leafygreen-ui-1kepx47" href="#exploring-the-data" 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="exploring-the-data"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> Inspect an entry in the newly-created <code class="leafygreen-ui-1l06pbn"> restaurants </code> collection in <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/mongodb-shell/#mongodb-binary-bin.mongosh" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongosh </code> : </span> </a> </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.restaurants.findOne()","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">restaurants</span>.<span class="lg-highlight-title lg-highlight-function">findOne</span>(<!-- -->)</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"> This query returns a document like the following: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{\n location: {\n type: \"Point\",\n coordinates: [-73.856077, 40.848447]\n },\n name: \"Morris Park Bake Shop\"\n}","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">location</span>: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">type</span>: <span class="lg-highlight-string">"Point"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">coordinates</span>: <!-- -->[<!-- -->-<span class="lg-highlight-number">73.856077</span>, <span class="lg-highlight-number">40.848447</span>]</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">name</span>: <span class="lg-highlight-string">"Morris Park Bake Shop"</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx">}</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"> This restaurant document corresponds to the location shown in the following figure: </p> <div class="figure css-5vkxs0" style="width:500px"> <div class="gatsby-image-wrapper gatsby-image-wrapper-constrained leafygreen-ui-12xaq6r" data-gatsby-image-wrapper=""> <div style="max-width:526px;display:block"> <img alt="" aria-hidden="true" role="presentation" src="data:image/svg+xml;charset=utf-8,%3Csvg%20height='472.00000000000006'%20width='526'%20xmlns='http://www.w3.org/2000/svg'%20version='1.1'%3E%3C/svg%3E" style="max-width:100%;display:block;position:static"/> </div> <div aria-hidden="true" data-placeholder-image="" style="opacity:1;transition:opacity 500ms linear"> </div> <img alt="Map of a single geospatial point." data-main-image="" decoding="async" height="472.00000000000006" loading="lazy" sizes="(min-width: 526px) 526px, 100vw" src="/docs/manual/static/727d307582367d1714511b088bcb0d5d/d5a20/geospatial-single-point.webp" srcset="/docs/manual/static/727d307582367d1714511b088bcb0d5d/9c822/geospatial-single-point.webp 132w,/docs/manual/static/727d307582367d1714511b088bcb0d5d/fd4f5/geospatial-single-point.webp 263w,/docs/manual/static/727d307582367d1714511b088bcb0d5d/d5a20/geospatial-single-point.webp 526w" style="--border-color:#C1C7C6;opacity:0" width="526"/> <noscript> <img alt="Map of a single geospatial point." data-gatsby-image-ssr="" data-main-image="" decoding="async" height="472.00000000000006" loading="lazy" sizes="(min-width: 526px) 526px, 100vw" src="/docs/manual/static/727d307582367d1714511b088bcb0d5d/d5a20/geospatial-single-point.webp" srcset="/docs/manual/static/727d307582367d1714511b088bcb0d5d/9c822/geospatial-single-point.webp 132w,/docs/manual/static/727d307582367d1714511b088bcb0d5d/fd4f5/geospatial-single-point.webp 263w,/docs/manual/static/727d307582367d1714511b088bcb0d5d/d5a20/geospatial-single-point.webp 526w" style="--border-color:#C1C7C6;opacity:0" width="526"/> </noscript> <script type="module"> const t="undefined"!=typeof HTMLImageElement&&"loading"in HTMLImageElement.prototype;if(t){const t=document.querySelectorAll("img[data-main-image]");for(let e of t){e.dataset.src&&(e.setAttribute("src",e.dataset.src),e.removeAttribute("data-src")),e.dataset.srcset&&(e.setAttribute("srcset",e.dataset.srcset),e.removeAttribute("data-srcset"));const t=e.parentNode.querySelectorAll("source[data-srcset]");for(let e of t)e.setAttribute("srcset",e.dataset.srcset),e.removeAttribute("data-srcset");e.complete&&(e.style.opacity=1,e.parentNode.parentNode.querySelector("[data-placeholder-image]").style.opacity=0)}} </script> </div> </div> <p class="leafygreen-ui-1kp3ins"> Because the tutorial uses a <code class="leafygreen-ui-1l06pbn"> 2dsphere </code> index, the geometry data in the <code class="leafygreen-ui-1l06pbn"> location </code> field must follow the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/geojson/#std-label-geospatial-indexes-store-geojson"> GeoJSON format <!-- --> . </a> </p> <p class="leafygreen-ui-1kp3ins"> Now inspect an entry in the <code class="leafygreen-ui-1l06pbn"> neighborhoods </code> collection: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.neighborhoods.findOne()","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">neighborhoods</span>.<span class="lg-highlight-title lg-highlight-function">findOne</span>(<!-- -->)</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"> This query will return a document like the following: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{\n geometry: {\n type: \"Polygon\",\n coordinates: [[\n [ -73.99, 40.75 ],\n ...\n [ -73.98, 40.76 ],\n [ -73.99, 40.75 ]\n ]]\n },\n name: \"Hell's Kitchen\"\n}","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">geometry</span>: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">type</span>: <span class="lg-highlight-string">"Polygon"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">coordinates</span>: <!-- -->[<!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->[ <!-- -->-<span class="lg-highlight-number">73.99</span>, <span class="lg-highlight-number">40.75</span> ]<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->...</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->[ <!-- -->-<span class="lg-highlight-number">73.98</span>, <span class="lg-highlight-number">40.76</span> ]<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->[ <!-- -->-<span class="lg-highlight-number">73.99</span>, <span class="lg-highlight-number">40.75</span> ]</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> ]]</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">name</span>: <span class="lg-highlight-string">"Hell's Kitchen"</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx">}</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"> This geometry corresponds to the region depicted in the following figure: </p> <div class="css-18h91be ej97su30"> <div role="button" tabindex="-1"> <div class="gatsby-image-wrapper gatsby-image-wrapper-constrained leafygreen-ui-12xaq6r" data-gatsby-image-wrapper=""> <div style="max-width:866px;display:block"> <img alt="" aria-hidden="true" role="presentation" src="data:image/svg+xml;charset=utf-8,%3Csvg%20height='744'%20width='866'%20xmlns='http://www.w3.org/2000/svg'%20version='1.1'%3E%3C/svg%3E" style="max-width:100%;display:block;position:static"/> </div> <div aria-hidden="true" data-placeholder-image="" style="opacity:1;transition:opacity 500ms linear"> </div> <img alt="Map of a geospatial polygon." data-main-image="" decoding="async" height="744" loading="lazy" sizes="(min-width: 866px) 866px, 100vw" src="/docs/manual/static/964f6285c2091eba2fceb444db5d8299/0bd87/geospatial-polygon-hells-kitchen.webp" srcset="/docs/manual/static/964f6285c2091eba2fceb444db5d8299/96d57/geospatial-polygon-hells-kitchen.webp 217w,/docs/manual/static/964f6285c2091eba2fceb444db5d8299/32111/geospatial-polygon-hells-kitchen.webp 433w,/docs/manual/static/964f6285c2091eba2fceb444db5d8299/0bd87/geospatial-polygon-hells-kitchen.webp 866w" style="--border-color:#C1C7C6;opacity:0" width="866"/> <noscript> <img alt="Map of a geospatial polygon." data-gatsby-image-ssr="" data-main-image="" decoding="async" height="744" loading="lazy" sizes="(min-width: 866px) 866px, 100vw" src="/docs/manual/static/964f6285c2091eba2fceb444db5d8299/0bd87/geospatial-polygon-hells-kitchen.webp" srcset="/docs/manual/static/964f6285c2091eba2fceb444db5d8299/96d57/geospatial-polygon-hells-kitchen.webp 217w,/docs/manual/static/964f6285c2091eba2fceb444db5d8299/32111/geospatial-polygon-hells-kitchen.webp 433w,/docs/manual/static/964f6285c2091eba2fceb444db5d8299/0bd87/geospatial-polygon-hells-kitchen.webp 866w" style="--border-color:#C1C7C6;opacity:0" width="866"/> </noscript> <script type="module"> const t="undefined"!=typeof HTMLImageElement&&"loading"in HTMLImageElement.prototype;if(t){const t=document.querySelectorAll("img[data-main-image]");for(let e of t){e.dataset.src&&(e.setAttribute("src",e.dataset.src),e.removeAttribute("data-src")),e.dataset.srcset&&(e.setAttribute("srcset",e.dataset.srcset),e.removeAttribute("data-srcset"));const t=e.parentNode.querySelectorAll("source[data-srcset]");for(let e of t)e.setAttribute("srcset",e.dataset.srcset),e.removeAttribute("data-srcset");e.complete&&(e.style.opacity=1,e.parentNode.parentNode.querySelector("[data-placeholder-image]").style.opacity=0)}} </script> </div> <div class="css-19pi7x2 ej97su31" style="--color:#444"> click to enlarge </div> </div> </div> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Find the Current Neighborhood <a class="headerlink leafygreen-ui-1kepx47" href="#find-the-current-neighborhood" 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="find-the-current-neighborhood"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> Assuming the user's mobile device can give a reasonably accurate location for the user, it is simple to find the user's current neighborhood with <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/query/geoIntersects/#mongodb-query-op.-geoIntersects"> <code class="leafygreen-ui-1l06pbn"> $geoIntersects </code> . </a> </p> <p class="leafygreen-ui-1kp3ins"> Suppose the user is located at -73.93414657 longitude and 40.82302903 latitude. To find the current neighborhood, you will specify a point using the special <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/query/geometry/#mongodb-query-op.-geometry"> <code class="leafygreen-ui-1l06pbn"> $geometry </code> </a> field in <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-GeoJSON"> GeoJSON </a> format: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.neighborhoods.findOne({ geometry: { $geoIntersects: { $geometry: { type: \"Point\", coordinates: [ -73.93414657, 40.82302903 ] } } } })","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-1q4bxgx" tabindex="0"><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">neighborhoods</span>.<span class="lg-highlight-title lg-highlight-function">findOne</span>(<!-- -->{ <span class="lg-highlight-attr">geometry</span>: <!-- -->{ <span class="lg-highlight-attr">$geoIntersects</span>: <!-- -->{ <span class="lg-highlight-attr">$geometry</span>: <!-- -->{ <span class="lg-highlight-attr">type</span>: <span class="lg-highlight-string">"Point"</span>, <span class="lg-highlight-attr">coordinates</span>: <!-- -->[ <!-- -->-<span class="lg-highlight-number">73.93414657</span>, <span class="lg-highlight-number">40.82302903</span> ] } } } })</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"> This query will return the following result: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{\n \"_id\" : ObjectId(\"55cb9c666c522cafdb053a68\"),\n \"geometry\" : {\n \"type\" : \"Polygon\",\n \"coordinates\" : [\n [\n [\n -73.93383000695911,\n 40.81949109558767\n ],\n ...\n ]\n ]\n },\n \"name\" : \"Central Harlem North-Polo Grounds\"\n}","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">ObjectId</span>(<span class="lg-highlight-string">"55cb9c666c522cafdb053a68"</span>)<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"geometry"</span> <!-- -->: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"type"</span> <!-- -->: <span class="lg-highlight-string">"Polygon"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"coordinates"</span> <!-- -->: <!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->-<span class="lg-highlight-number">73.93383000695911</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-number">40.81949109558767</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> ]<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->...</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> ]</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> ]</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"name"</span> <!-- -->: <span class="lg-highlight-string">"Central Harlem North-Polo Grounds"</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx">}</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> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Find all Restaurants in the Neighborhood <a class="headerlink leafygreen-ui-1kepx47" href="#find-all-restaurants-in-the-neighborhood" 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="find-all-restaurants-in-the-neighborhood"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> You can also query to find all restaurants contained in a given neighborhood. Run the following in <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/mongodb-shell/#mongodb-binary-bin.mongosh" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongosh </code> </span> </a> to find the neighborhood containing the user, and then count the restaurants within that neighborhood: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"var neighborhood = db.neighborhoods.findOne( { geometry: { $geoIntersects: { $geometry: { type: \"Point\", coordinates: [ -73.93414657, 40.82302903 ] } } } } )\ndb.restaurants.find( { location: { $geoWithin: { $geometry: neighborhood.geometry } } } ).count()","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-keyword">var</span> neighborhood <!-- -->= <!-- -->db.<span class="lg-highlight-property">neighborhoods</span>.<span class="lg-highlight-title lg-highlight-function">findOne</span>( <!-- -->{ <span class="lg-highlight-attr">geometry</span>: <!-- -->{ <span class="lg-highlight-attr">$geoIntersects</span>: <!-- -->{ <span class="lg-highlight-attr">$geometry</span>: <!-- -->{ <span class="lg-highlight-attr">type</span>: <span class="lg-highlight-string">"Point"</span>, <span class="lg-highlight-attr">coordinates</span>: <!-- -->[ <!-- -->-<span class="lg-highlight-number">73.93414657</span>, <span class="lg-highlight-number">40.82302903</span> ] } } } } )</td></tr><tr class=""><td class="leafygreen-ui-7razhx">db.<span class="lg-highlight-property">restaurants</span>.<span class="lg-highlight-title lg-highlight-function">find</span>( <!-- -->{ <span class="lg-highlight-attr">location</span>: <!-- -->{ <span class="lg-highlight-attr">$geoWithin</span>: <!-- -->{ <span class="lg-highlight-attr">$geometry</span>: <!-- -->neighborhood.<span class="lg-highlight-property">geometry</span> } } } ).<span class="lg-highlight-title lg-highlight-function">count</span>(<!-- -->)</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"> This query will tell you that there are 127 restaurants in the requested neighborhood, visualized in the following figure: </p> <div class="css-18h91be ej97su30"> <div role="button" tabindex="-1"> <div class="gatsby-image-wrapper gatsby-image-wrapper-constrained leafygreen-ui-12xaq6r" data-gatsby-image-wrapper=""> <div style="max-width:984px;display:block"> <img alt="" aria-hidden="true" role="presentation" src="data:image/svg+xml;charset=utf-8,%3Csvg%20height='1096'%20width='984'%20xmlns='http://www.w3.org/2000/svg'%20version='1.1'%3E%3C/svg%3E" style="max-width:100%;display:block;position:static"/> </div> <div aria-hidden="true" data-placeholder-image="" style="opacity:1;transition:opacity 500ms linear"> </div> <img alt="Map of all restaurants in a geospatial polygon." data-main-image="" decoding="async" height="1096" loading="lazy" sizes="(min-width: 984px) 984px, 100vw" src="/docs/manual/static/759209df93ce3d780bdd71a9462151e9/ec7dc/geospatial-all-restaurants.webp" srcset="/docs/manual/static/759209df93ce3d780bdd71a9462151e9/51e77/geospatial-all-restaurants.webp 246w,/docs/manual/static/759209df93ce3d780bdd71a9462151e9/e8c5f/geospatial-all-restaurants.webp 492w,/docs/manual/static/759209df93ce3d780bdd71a9462151e9/ec7dc/geospatial-all-restaurants.webp 984w" style="--border-color:#C1C7C6;opacity:0" width="984"/> <noscript> <img alt="Map of all restaurants in a geospatial polygon." data-gatsby-image-ssr="" data-main-image="" decoding="async" height="1096" loading="lazy" sizes="(min-width: 984px) 984px, 100vw" src="/docs/manual/static/759209df93ce3d780bdd71a9462151e9/ec7dc/geospatial-all-restaurants.webp" srcset="/docs/manual/static/759209df93ce3d780bdd71a9462151e9/51e77/geospatial-all-restaurants.webp 246w,/docs/manual/static/759209df93ce3d780bdd71a9462151e9/e8c5f/geospatial-all-restaurants.webp 492w,/docs/manual/static/759209df93ce3d780bdd71a9462151e9/ec7dc/geospatial-all-restaurants.webp 984w" style="--border-color:#C1C7C6;opacity:0" width="984"/> </noscript> <script type="module"> const t="undefined"!=typeof HTMLImageElement&&"loading"in HTMLImageElement.prototype;if(t){const t=document.querySelectorAll("img[data-main-image]");for(let e of t){e.dataset.src&&(e.setAttribute("src",e.dataset.src),e.removeAttribute("data-src")),e.dataset.srcset&&(e.setAttribute("srcset",e.dataset.srcset),e.removeAttribute("data-srcset"));const t=e.parentNode.querySelectorAll("source[data-srcset]");for(let e of t)e.setAttribute("srcset",e.dataset.srcset),e.removeAttribute("data-srcset");e.complete&&(e.style.opacity=1,e.parentNode.parentNode.querySelector("[data-placeholder-image]").style.opacity=0)}} </script> </div> <div class="css-19pi7x2 ej97su31" style="--color:#444"> click to enlarge </div> </div> </div> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Find Restaurants within a Distance <a class="headerlink leafygreen-ui-1kepx47" href="#find-restaurants-within-a-distance" 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="find-restaurants-within-a-distance"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> To find restaurants within a specified distance of a point, you can use either <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/query/geoWithin/#mongodb-query-op.-geoWithin"> <code class="leafygreen-ui-1l06pbn"> $geoWithin </code> </a> with <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/query/centerSphere/#mongodb-query-op.-centerSphere"> <code class="leafygreen-ui-1l06pbn"> $centerSphere </code> </a> to return results in unsorted order, or <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/query/nearSphere/#mongodb-query-op.-nearSphere"> <code class="leafygreen-ui-1l06pbn"> $nearSphere </code> </a> with <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/query/maxDistance/#mongodb-query-op.-maxDistance"> <code class="leafygreen-ui-1l06pbn"> $maxDistance </code> </a> if you need results sorted by distance. </p> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Unsorted with <code class="leafygreen-ui-1l06pbn"> $geoWithin </code> <a class="headerlink leafygreen-ui-1kepx47" href="#unsorted-with--geowithin" 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="unsorted-with--geowithin"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> To find restaurants within a circular region, use <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/query/geoWithin/#mongodb-query-op.-geoWithin"> <code class="leafygreen-ui-1l06pbn"> $geoWithin </code> </a> with <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/query/centerSphere/#mongodb-query-op.-centerSphere"> <code class="leafygreen-ui-1l06pbn"> $centerSphere </code> </a> . <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/query/centerSphere/#mongodb-query-op.-centerSphere"> <code class="leafygreen-ui-1l06pbn"> $centerSphere </code> </a> is a MongoDB-specific syntax to denote a circular region by specifying the center and the radius in radians. </p> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/query/geoWithin/#mongodb-query-op.-geoWithin"> <code class="leafygreen-ui-1l06pbn"> $geoWithin </code> </a> does not return the documents in any specific order, so it may show the user the furthest documents first. </p> <p class="leafygreen-ui-1kp3ins"> The following will find all restaurants within five miles of the user: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.restaurants.find({ location:\n { $geoWithin:\n { $centerSphere: [ [ -73.93414657, 40.82302903 ], 5 / 3963.2 ] } } })","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><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">restaurants</span>.<span class="lg-highlight-title lg-highlight-function">find</span>(<!-- -->{ <span class="lg-highlight-attr">location</span>:</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">$geoWithin</span>:</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">$centerSphere</span>: <!-- -->[ <!-- -->[ <!-- -->-<span class="lg-highlight-number">73.93414657</span>, <span class="lg-highlight-number">40.82302903</span> ]<!-- -->, <span class="lg-highlight-number">5</span> <!-- -->/ <span class="lg-highlight-number">3963.2</span> ] } } })</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"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/query/centerSphere/#mongodb-query-op.-centerSphere"> <code class="leafygreen-ui-1l06pbn"> $centerSphere </code> </a> 's second argument accepts the radius in radians, so you must divide it by the radius of the earth in miles. See <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/indexes/index-types/geospatial/2d/calculate-distances/#std-label-calculate-distance-spherical-geometry"> Convert Distance to Radians for Spherical Operators </a> for more information on converting between distance units. </p> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Sorted with <code class="leafygreen-ui-1l06pbn"> $nearSphere </code> <a class="headerlink leafygreen-ui-1kepx47" href="#sorted-with--nearsphere" 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="sorted-with--nearsphere"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> You may also use <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/query/nearSphere/#mongodb-query-op.-nearSphere"> <code class="leafygreen-ui-1l06pbn"> $nearSphere </code> </a> and specify a <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/query/maxDistance/#mongodb-query-op.-maxDistance"> <code class="leafygreen-ui-1l06pbn"> $maxDistance </code> </a> term in meters. This will return all restaurants within five miles of the user in sorted order from nearest to farthest: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"var METERS_PER_MILE = 1609.34\ndb.restaurants.find({ location: { $nearSphere: { $geometry: { type: \"Point\", coordinates: [ -73.93414657, 40.82302903 ] }, $maxDistance: 5 * METERS_PER_MILE } } })","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-keyword">var</span> <span class="lg-highlight-variable lg-highlight-constant">METERS_PER_MILE</span> <!-- -->= <span class="lg-highlight-number">1609.34</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx">db.<span class="lg-highlight-property">restaurants</span>.<span class="lg-highlight-title lg-highlight-function">find</span>(<!-- -->{ <span class="lg-highlight-attr">location</span>: <!-- -->{ <span class="lg-highlight-attr">$nearSphere</span>: <!-- -->{ <span class="lg-highlight-attr">$geometry</span>: <!-- -->{ <span class="lg-highlight-attr">type</span>: <span class="lg-highlight-string">"Point"</span>, <span class="lg-highlight-attr">coordinates</span>: <!-- -->[ <!-- -->-<span class="lg-highlight-number">73.93414657</span>, <span class="lg-highlight-number">40.82302903</span> ] }<!-- -->, <span class="lg-highlight-attr">$maxDistance</span>: <span class="lg-highlight-number">5</span> <!-- -->* <span class="lg-highlight-variable lg-highlight-constant">METERS_PER_MILE</span> } } })</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> </section> </section> </section>
https://www.mongodb.com/docs/manual/reference/method/db.collection.updateOne/
<section> <h1 class="contains-headerlink leafygreen-ui-41fr9s" weight="medium"> db.collection.updateOne() <a class="headerlink leafygreen-ui-1kepx47" href="#db.collection.updateone--" 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.updateone--"> </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="#definition" target="_self"> <span> Definition </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#compatibility" target="_self"> <span> Compatibility </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#syntax" target="_self"> <span> Syntax </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#access-control" target="_self"> <span> Access Control </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#behavior" target="_self"> <span> Behavior </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#examples" target="_self"> <span> Examples </span> </a> </li> </ul> </div> <div class="leafygreen-ui-147elvs"> <p class="leafygreen-ui-1ronz74"> MongoDB with drivers </p> <div class="leafygreen-ui-18k5rfm"> <p class="leafygreen-ui-1kp3ins"> This page documents a <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/mongodb-shell/#mongodb-binary-bin.mongosh" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongosh </code> </span> </a> method. To see the equivalent method in a MongoDB driver, see the corresponding page for your programming language: </p> </div> <div class="leafygreen-ui-zgrwqu notranslate"> <a class="leafygreen-ui-v22cck" href="https://www.mongodb.com/docs/drivers/csharp/current/fundamentals/crud/write-operations/modify/#update-one-document" target="_self"> <svg class="leafygreen-ui-x3zji3" fill="none" height="24" viewbox="0 0 28 29" width="24" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_1351_59964)"> <g clip-path="url(#clip1_1351_59964)"> <path d="M25.7709 9.2495C25.7709 8.79827 25.678 8.39408 25.4827 8.04627C25.2874 7.70785 25.0084 7.42586 24.627 7.20025C21.465 5.35781 18.2937 3.51538 15.1317 1.67295C14.2761 1.17474 13.4484 1.19354 12.6021 1.70115C11.3466 2.45316 5.04112 6.10042 3.15321 7.20025C2.3813 7.65142 2 8.34705 2 9.24005C2 12.9531 2 16.6568 2 20.3698C2 20.8117 2.093 21.2064 2.279 21.5449C2.4743 21.8927 2.7626 22.1841 3.15321 22.4191C5.03182 23.5189 11.3373 27.1662 12.6021 27.9182C13.4484 28.4258 14.2761 28.4446 15.1317 27.9463C18.2937 26.1039 21.465 24.2615 24.627 22.4191C25.0177 22.1935 25.306 21.9021 25.5012 21.5449C25.6873 21.2064 25.7803 20.8117 25.7803 20.3698C25.7709 20.3698 25.7709 12.9531 25.7709 9.2495Z" fill="#A179DC"> </path> <path d="M13.9227 14.7673L2.27905 21.5449C2.47435 21.8927 2.76265 22.1841 3.15326 22.4191C5.03187 23.5189 11.3373 27.1662 12.6021 27.9182C13.4484 28.4258 14.2762 28.4445 15.1317 27.9463C18.2938 26.1039 21.4651 24.2615 24.6271 22.4191C25.0177 22.1935 25.306 21.9021 25.5013 21.5449L13.9227 14.7673Z" fill="#280068"> </path> <path d="M25.7711 9.24949C25.7711 8.79827 25.6781 8.39408 25.4828 8.04626L13.9229 14.7768L25.4921 21.5543C25.6781 21.2159 25.7711 20.8211 25.7711 20.3793C25.7711 20.3699 25.7711 12.9531 25.7711 9.24949Z" fill="#390091"> </path> <path d="M20.7771 12.2387V13.5078H22.0325V12.2387H22.6557V13.5078H23.9111V14.1376H22.6557V15.4066H23.9111V16.0364H22.6557V17.3054H22.0325V16.0364H20.7771V17.3054H20.1539V16.0364H18.8984V15.4066H20.1539V14.1376H18.8984V13.5078H20.1539V12.2387H20.7771ZM22.0325 14.1376H20.7771V15.4066H22.0325V14.1376Z" fill="white"> </path> <path d="M13.9508 5.87482C17.2151 5.87482 20.0702 7.67022 21.6047 10.3399L21.5861 10.3117L17.7452 12.5489C16.9919 11.2517 15.5969 10.3775 14.0066 10.3587H13.9601C11.5328 10.3587 9.56116 12.3515 9.56116 14.805C9.56116 15.604 9.77503 16.3654 10.1377 17.014C10.9004 18.3488 12.3232 19.2512 13.9601 19.2512C15.6062 19.2512 17.0384 18.3394 17.7917 16.9858L17.7731 17.014L21.614 19.2606C20.0981 21.9021 17.2895 23.6975 14.0531 23.7257H13.9508C10.6679 23.7257 7.81274 21.9209 6.28753 19.2418C5.54353 17.9352 5.11572 16.4124 5.11572 14.7956C5.11572 9.87931 9.06825 5.87482 13.9508 5.87482Z" fill="white"> </path> </g> </g> <defs> <clippath id="clip0_1351_59964"> <rect fill="white" height="28" transform="translate(0 0.809265)" width="28"> </rect> </clippath> <clippath id="clip1_1351_59964"> <rect fill="white" height="27" transform="translate(2 1.30966)" width="24"> </rect> </clippath> </defs> </svg> <span> C# </span> </a> <a class="leafygreen-ui-v22cck" href="https://www.mongodb.com/docs/drivers/java/sync/current/fundamentals/crud/write-operations/modify/#update" target="_self"> <svg class="leafygreen-ui-x3zji3" fill="none" height="24" viewbox="0 0 30 41" width="24" xmlns="http://www.w3.org/2000/svg"> <path d="M10.0921 30.7949C10.0921 30.7949 8.57608 31.6793 11.166 31.9636C14.2929 32.311 15.9037 32.2794 19.3464 31.6161C19.3464 31.6161 20.2623 32.1846 21.5257 32.6901C13.7876 35.9748 4.02791 32.5005 10.0921 30.7949Z" fill="#0074BD"> </path> <path d="M9.14539 26.4678C9.14539 26.4678 7.43985 27.7312 10.0298 27.9838C13.3778 28.3312 15.9992 28.3628 20.579 27.4785C20.579 27.4785 21.2107 28.1101 22.1898 28.4576C12.8724 31.2054 2.44949 28.6787 9.14539 26.4678Z" fill="#0074BD"> </path> <path d="M17.1039 19.1398C18.9989 21.3191 16.5985 23.3089 16.5985 23.3089C16.5985 23.3089 21.431 20.8138 19.2201 17.6869C17.1355 14.7811 15.5563 13.3282 24.1788 8.33789C24.1473 8.33789 10.6607 11.6858 17.1039 19.1398Z" fill="#EA2D2E"> </path> <path d="M27.3377 33.9845C27.3377 33.9845 28.4431 34.9004 26.1059 35.6269C21.6525 36.985 7.53417 37.3957 3.61769 35.6901C2.19639 35.0899 4.84949 34.2372 5.67069 34.0477C6.52347 33.8582 7.02884 33.8898 7.02884 33.8898C5.44961 32.7843 -3.10981 36.0691 2.67016 36.9851C18.4308 39.5433 31.4121 35.8164 27.3377 33.9845Z" fill="#0074BD"> </path> <path d="M10.8194 21.983C10.8194 21.983 3.6497 23.6885 8.2926 24.3203C10.2509 24.5729 14.1357 24.5097 17.7995 24.2255C20.7685 23.9728 23.7375 23.4359 23.7375 23.4359C23.7375 23.4359 22.6951 23.8781 21.9372 24.415C14.6411 26.3416 0.585992 25.4257 4.62881 23.4675C8.00839 21.7935 10.8194 21.983 10.8194 21.983Z" fill="#0074BD"> </path> <path d="M23.6745 29.1846C31.0969 25.3313 27.6542 21.6359 25.2538 22.1413C24.6537 22.2676 24.401 22.3623 24.401 22.3623C24.401 22.3623 24.6221 22.0149 25.0327 21.8886C29.7703 20.2146 33.4025 26.7842 23.5166 29.4057C23.5482 29.3741 23.6429 29.2794 23.6745 29.1846Z" fill="#0074BD"> </path> <path d="M19.2206 0.25293C19.2206 0.25293 23.3266 4.35891 15.3357 10.6758C8.92404 15.7293 13.8828 18.6351 15.3357 21.9199C11.6087 18.5403 8.86088 15.5714 10.6928 12.792C13.3775 8.74919 20.863 6.79093 19.2206 0.25293Z" fill="#EA2D2E"> </path> <path d="M11.5455 39.6068C18.6521 40.049 29.5803 39.3541 29.833 35.9746C29.833 35.9746 29.3276 37.238 23.9583 38.2487C17.894 39.3858 10.4085 39.2594 5.95508 38.533C5.95508 38.5646 6.87103 39.3225 11.5455 39.6068Z" fill="#0074BD"> </path> </svg> <span> Java Sync </span> </a> <a class="leafygreen-ui-v22cck" href="https://www.mongodb.com/docs/drivers/node/current/fundamentals/crud/write-operations/modify/#update-documents" target="_self"> <svg class="leafygreen-ui-x3zji3" fill="none" height="24" viewbox="0 0 30 30" width="24" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:R2dtdqcmqn9:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":R2dtdqcmqn9:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":R2dtdqcmqn9:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":R2dtdqcmqn9:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <span> Node.js </span> </a> <a class="leafygreen-ui-v22cck" href="https://www.mongodb.com/docs/languages/python/pymongo-driver/current/write/update/#update-one-document" target="_self"> <svg class="leafygreen-ui-x3zji3" height="24" viewbox="0 0 111.6 147" width="24" xmlns="http://www.w3.org/2000/svg"> <lineargradient gradienttransform="matrix(.5625 0 0 -.568 -160.323 -146.09)" gradientunits="userSpaceOnUse" id=":R2htdqcmqn9:aa" x1="280.848" x2="389.865" y1="-268.463" y2="-362.257"> <stop offset="0" stop-color="#5a9fd4"> </stop> <stop offset="1" stop-color="#306998"> </stop> </lineargradient> <path d="M55.3 3.2c-4.6 0-9 .4-12.8 1.1-11.3 2-13.4 6.2-13.4 13.9v10.2h26.8v3.4H19c-7.8 0-14.6 4.7-16.8 13.6C-.3 55.6-.4 62 2.2 72.7c1.9 7.9 6.5 13.6 14.2 13.6h9.2V74c0-8.8 7.7-16.7 16.7-16.7h26.8c7.5 0 13.4-6.1 13.4-13.6V18.2c0-7.3-6.1-12.7-13.4-13.9-4.4-.8-9.2-1.1-13.8-1.1zm-14.5 8.2c2.8 0 5 2.3 5 5.1s-2.3 5.1-5 5.1c-2.8 0-5-2.3-5-5.1s2.2-5.1 5-5.1z" fill="url(#:R2htdqcmqn9:aa)"> </path> <lineargradient gradienttransform="matrix(.5625 0 0 -.568 -160.323 -146.09)" gradientunits="userSpaceOnUse" id=":R2htdqcmqn9:bb" x1="432.011" x2="393.081" y1="-419.025" y2="-363.946"> <stop offset="0" stop-color="#ffd43b"> </stop> <stop offset="1" stop-color="#ffe873"> </stop> </lineargradient> <path d="M86 31.8v11.9c0 9.2-7.8 17-16.8 17H42.5c-7.3 0-13.4 6.3-13.4 13.6v25.5c0 7.3 6.3 11.5 13.4 13.6 8.5 2.5 16.6 2.9 26.8 0 6.8-2 13.4-5.9 13.4-13.6V89.7H55.9v-3.4h40.2c7.8 0 10.7-5.4 13.4-13.6 2.8-8.4 2.7-16.5 0-27.3-1.9-7.8-5.6-13.6-13.4-13.6H86zM71 96.5c2.8 0 5 2.3 5 5.1s-2.3 5.1-5 5.1c-2.8 0-5-2.3-5-5.1-.1-2.8 2.2-5.1 5-5.1z" fill="url(#:R2htdqcmqn9:bb)"> </path> <radialgradient cx="-2274.721" cy="144.526" gradienttransform="matrix(0 -.2399 -1.0547 0 208.637 -414.922)" gradientunits="userSpaceOnUse" id=":R2htdqcmqn9:cc" r="29.037"> <stop offset="0" stop-color="#b8b8b8" stop-opacity=".498"> </stop> <stop offset="1" stop-color="#7f7f7f" stop-opacity="0"> </stop> </radialgradient> <path d="M92.1 130.9c0 3.8-16.1 7-35.9 7s-35.9-3.1-35.9-7c0-3.8 16.1-7 35.9-7s35.9 3.1 35.9 7z" fill="url(#:R2htdqcmqn9:cc)" opacity=".444"> </path> </svg> <span> PyMongo </span> </a> <a class="leafygreen-ui-18cpm0b" href="https://mongoc.org/libmongoc/current/mongoc_collection_update_one.html" target="_self"> <svg class="leafygreen-ui-x3zji3" fill="none" height="24" viewbox="0 0 28 29" width="24" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_1351_59955)"> <g clip-path="url(#clip1_1351_59955)"> <path clip-rule="evenodd" d="M13.118 1.49532C13.5403 1.25103 14.0559 1.25103 14.4783 1.49532C16.5652 2.70389 22.8385 6.34889 24.9193 7.55748C25.3416 7.80172 25.6025 8.25176 25.6025 8.74672C25.6025 11.1703 25.6025 18.4539 25.6025 20.8774C25.6025 21.366 25.3416 21.8224 24.9193 22.0667C22.8385 23.2753 16.5652 26.9203 14.4783 28.1289C14.0559 28.3732 13.5403 28.3732 13.118 28.1289C11.0373 26.9139 4.76398 23.2689 2.68323 22.0603C2.26087 21.816 2 21.366 2 20.871C2 18.4474 2 11.1639 2 8.7403C2 8.25176 2.26087 7.7953 2.68323 7.55106C4.76398 6.34889 11.0373 2.70389 13.118 1.49532Z" fill="#004482" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M2.18634 21.4946C2.01863 21.2632 2 21.051 2 20.7553C2 18.351 2 11.1061 2 8.70176C2 8.21317 2.26087 7.76319 2.67702 7.51889C4.75776 6.31675 11.0062 2.69104 13.0807 1.4889C13.5031 1.24461 14.0683 1.25104 14.4907 1.49533C16.5652 2.69747 22.795 6.29104 24.8696 7.49319C25.0373 7.58963 25.1677 7.70535 25.2795 7.86606L2.18634 21.4946Z" fill="#659AD2" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M13.8011 5.8089C18.6024 5.8089 22.4968 9.83964 22.4968 14.8089C22.4968 19.7782 18.6024 23.8089 13.8011 23.8089C8.99986 23.8089 5.10547 19.7782 5.10547 14.8089C5.10547 9.83964 8.99986 5.8089 13.8011 5.8089ZM13.8011 10.3089C16.1987 10.3089 18.1489 12.3275 18.1489 14.8089C18.1489 17.2903 16.1987 19.3089 13.8011 19.3089C11.4036 19.3089 9.4533 17.2903 9.4533 14.8089C9.4533 12.3275 11.4036 10.3089 13.8011 10.3089Z" fill="white" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M25.2857 7.87247C25.6087 8.18102 25.6025 8.65034 25.6025 9.01673C25.6025 11.4596 25.5839 18.396 25.6087 20.8325C25.6087 21.0896 25.528 21.3532 25.4099 21.5589L13.5466 14.8089L25.2857 7.87247Z" fill="#00599C" fill-rule="evenodd"> </path> </g> </g> <defs> <clippath id="clip0_1351_59955"> <rect fill="white" height="28" transform="translate(0 0.809265)" width="28"> </rect> </clippath> <clippath id="clip1_1351_59955"> <rect fill="white" height="27" transform="translate(2 1.30887)" width="24"> </rect> </clippath> </defs> </svg> <span> C </span> </a> <a class="leafygreen-ui-18cpm0b" href="https://www.mongodb.com/docs/languages/cpp/cpp-driver/current/write/update/#update-one-document" target="_self"> <svg class="leafygreen-ui-x3zji3" fill="none" height="24" viewbox="0 0 28 29" width="24" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_1351_59959)"> <g clip-path="url(#clip1_1351_59959)"> <path d="M25.4013 21.5646C25.5872 21.2353 25.7034 20.8745 25.7034 20.5373V9.08012C25.7034 8.75078 25.5872 8.38217 25.4013 8.05283L13.8516 14.8127L25.4013 21.5646Z" fill="#00599C"> </path> <path d="M14.8738 28.0657L24.6729 22.3411C24.9517 22.1764 25.2151 21.8941 25.401 21.5647L13.8513 14.8127L2.30151 21.5647C2.48743 21.8941 2.74305 22.1764 3.02967 22.3411L12.8288 28.0657C13.3865 28.3951 14.316 28.3951 14.8738 28.0657Z" fill="#004482"> </path> <path d="M25.4011 8.06086C25.2152 7.73146 24.9596 7.44915 24.673 7.2845L14.8739 1.55983C14.3084 1.23046 13.3866 1.23046 12.8211 1.55983L3.02202 7.2845C2.46429 7.61385 1.99951 8.42158 1.99951 9.08033V20.5375C1.99951 20.8669 2.11571 21.2354 2.30162 21.5647L13.8514 14.8128L25.4011 8.06086Z" fill="#659AD2"> </path> <path d="M13.8512 22.8115C9.49778 22.8115 5.94995 19.2199 5.94995 14.8127C5.94995 10.4055 9.49778 6.81387 13.8512 6.81387C16.6631 6.81387 19.2813 8.34305 20.6912 10.8133L17.2751 12.813C16.5701 11.5818 15.261 10.8133 13.8512 10.8133C11.6745 10.8133 9.90055 12.6091 9.90055 14.8127C9.90055 17.0163 11.6745 18.8121 13.8512 18.8121C15.261 18.8121 16.5701 18.0436 17.2751 16.8124L20.6912 18.8121C19.2813 21.2745 16.6631 22.8115 13.8512 22.8115Z" fill="white"> </path> <path d="M21.7524 14.3657H20.8771V13.4796H19.994V14.3657H19.1187V15.2518H19.994V16.1458H20.8771V15.2518H21.7524V14.3657Z" fill="white"> </path> <path d="M25.0446 14.3657H24.1693V13.4796H23.2862V14.3657H22.4109V15.2518H23.2862V16.1458H24.1693V15.2518H25.0446V14.3657Z" fill="white"> </path> </g> </g> <defs> <clippath id="clip0_1351_59959"> <rect fill="white" height="28" transform="translate(0 0.809265)" width="28"> </rect> </clippath> <clippath id="clip1_1351_59959"> <rect fill="white" height="27" transform="translate(1.99951 1.30878)" width="24"> </rect> </clippath> </defs> </svg> <span> C++ </span> </a> <a class="leafygreen-ui-18cpm0b" href="https://www.mongodb.com/docs/drivers/go/current/fundamentals/crud/write-operations/modify/#update" target="_self"> <svg class="leafygreen-ui-x3zji3" height="24" id="Layer_1" style="fill:#00ACD7" version="1.1" viewbox="0 0 205.4 76.7" width="24" x="0" xmlns="http://www.w3.org/2000/svg" y="0"> <path class="st00" d="M15.5 23.2c-.4 0-.5-.2-.3-.5l2.1-2.7c.2-.3.7-.5 1.1-.5h35.7c.4 0 .5.3.3.6l-1.7 2.6c-.2.3-.7.6-1 .6l-36.2-.1zM.4 32.4c-.4 0-.5-.2-.3-.5l2.1-2.7c.2-.3.7-.5 1.1-.5h45.6c.4 0 .6.3.5.6l-.8 2.4c-.1.4-.5.6-.9.6l-47.3.1zM24.6 41.6c-.4 0-.5-.3-.3-.6l1.4-2.5c.2-.3.6-.6 1-.6h20c.4 0 .6.3.6.7l-.2 2.4c0 .4-.4.7-.7.7l-21.8-.1z"> </path> <g id="CXHf1q_3_"> <path class="st00" d="M128.4 21.4c-6.3 1.6-10.6 2.8-16.8 4.4-1.5.4-1.6.5-2.9-1-1.5-1.7-2.6-2.8-4.7-3.8-6.3-3.1-12.4-2.2-18.1 1.5-6.8 4.4-10.3 10.9-10.2 19 .1 8 5.6 14.6 13.5 15.7 6.8.9 12.5-1.5 17-6.6.9-1.1 1.7-2.3 2.7-3.7H89.6c-2.1 0-2.6-1.3-1.9-3 1.3-3.1 3.7-8.3 5.1-10.9.3-.6 1-1.6 2.5-1.6h36.4c-.2 2.7-.2 5.4-.6 8.1-1.1 7.2-3.8 13.8-8.2 19.6-7.2 9.5-16.6 15.4-28.5 17-9.8 1.3-18.9-.6-26.9-6.6-7.4-5.6-11.6-13-12.7-22.2-1.3-10.9 1.9-20.7 8.5-29.3C70.4 8.7 79.8 2.8 91.3.7c9.4-1.7 18.4-.6 26.5 4.9 5.3 3.5 9.1 8.3 11.6 14.1.6.9.2 1.4-1 1.7z"> </path> <path class="st00" d="M161.5 76.7c-9.1-.2-17.4-2.8-24.4-8.8-5.9-5.1-9.6-11.6-10.8-19.3-1.8-11.3 1.3-21.3 8.1-30.2 7.3-9.6 16.1-14.6 28-16.7 10.2-1.8 19.8-.8 28.5 5.1 7.9 5.4 12.8 12.7 14.1 22.3 1.7 13.5-2.2 24.5-11.5 33.9-6.6 6.7-14.7 10.9-24 12.8-2.7.5-5.4.6-8 .9zm23.8-40.4c-.1-1.3-.1-2.3-.3-3.3-1.8-9.9-10.9-15.5-20.4-13.3-9.3 2.1-15.3 8-17.5 17.4-1.8 7.8 2 15.7 9.2 18.9 5.5 2.4 11 2.1 16.3-.6 7.9-4.1 12.2-10.5 12.7-19.1z"> </path> </g> </svg> <span> Go </span> </a> <a class="leafygreen-ui-18cpm0b" href="https://www.mongodb.com/docs/languages/java/reactive-streams-driver/current/write/write-update-documents/" target="_self"> <svg class="leafygreen-ui-x3zji3" fill="none" height="24" viewbox="0 0 30 41" width="24" xmlns="http://www.w3.org/2000/svg"> <path d="M10.0921 30.7949C10.0921 30.7949 8.57608 31.6793 11.166 31.9636C14.2929 32.311 15.9037 32.2794 19.3464 31.6161C19.3464 31.6161 20.2623 32.1846 21.5257 32.6901C13.7876 35.9748 4.02791 32.5005 10.0921 30.7949Z" fill="#0074BD"> </path> <path d="M9.14539 26.4678C9.14539 26.4678 7.43985 27.7312 10.0298 27.9838C13.3778 28.3312 15.9992 28.3628 20.579 27.4785C20.579 27.4785 21.2107 28.1101 22.1898 28.4576C12.8724 31.2054 2.44949 28.6787 9.14539 26.4678Z" fill="#0074BD"> </path> <path d="M17.1039 19.1398C18.9989 21.3191 16.5985 23.3089 16.5985 23.3089C16.5985 23.3089 21.431 20.8138 19.2201 17.6869C17.1355 14.7811 15.5563 13.3282 24.1788 8.33789C24.1473 8.33789 10.6607 11.6858 17.1039 19.1398Z" fill="#EA2D2E"> </path> <path d="M27.3377 33.9845C27.3377 33.9845 28.4431 34.9004 26.1059 35.6269C21.6525 36.985 7.53417 37.3957 3.61769 35.6901C2.19639 35.0899 4.84949 34.2372 5.67069 34.0477C6.52347 33.8582 7.02884 33.8898 7.02884 33.8898C5.44961 32.7843 -3.10981 36.0691 2.67016 36.9851C18.4308 39.5433 31.4121 35.8164 27.3377 33.9845Z" fill="#0074BD"> </path> <path d="M10.8194 21.983C10.8194 21.983 3.6497 23.6885 8.2926 24.3203C10.2509 24.5729 14.1357 24.5097 17.7995 24.2255C20.7685 23.9728 23.7375 23.4359 23.7375 23.4359C23.7375 23.4359 22.6951 23.8781 21.9372 24.415C14.6411 26.3416 0.585992 25.4257 4.62881 23.4675C8.00839 21.7935 10.8194 21.983 10.8194 21.983Z" fill="#0074BD"> </path> <path d="M23.6745 29.1846C31.0969 25.3313 27.6542 21.6359 25.2538 22.1413C24.6537 22.2676 24.401 22.3623 24.401 22.3623C24.401 22.3623 24.6221 22.0149 25.0327 21.8886C29.7703 20.2146 33.4025 26.7842 23.5166 29.4057C23.5482 29.3741 23.6429 29.2794 23.6745 29.1846Z" fill="#0074BD"> </path> <path d="M19.2206 0.25293C19.2206 0.25293 23.3266 4.35891 15.3357 10.6758C8.92404 15.7293 13.8828 18.6351 15.3357 21.9199C11.6087 18.5403 8.86088 15.5714 10.6928 12.792C13.3775 8.74919 20.863 6.79093 19.2206 0.25293Z" fill="#EA2D2E"> </path> <path d="M11.5455 39.6068C18.6521 40.049 29.5803 39.3541 29.833 35.9746C29.833 35.9746 29.3276 37.238 23.9583 38.2487C17.894 39.3858 10.4085 39.2594 5.95508 38.533C5.95508 38.5646 6.87103 39.3225 11.5455 39.6068Z" fill="#0074BD"> </path> </svg> <span> Java RS </span> </a> <a class="leafygreen-ui-18cpm0b" href="https://www.mongodb.com/docs/drivers/kotlin/coroutine/current/fundamentals/crud/write-operations/modify/#update" target="_self"> <svg class="leafygreen-ui-x3zji3" fill="none" height="24" viewbox="0 0 28 29" width="24" xmlns="http://www.w3.org/2000/svg"> <path d="M28 29H0V1H28L14 15L28 29Z" fill="url(#:R35tdqcmqn9:paint0_linear_211_40588)"> </path> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":R35tdqcmqn9:paint0_linear_211_40588" x1="28" x2="8.34465e-07" y1="0.999999" y2="29"> <stop offset="0.00343514" stop-color="#E44857"> </stop> <stop offset="0.4689" stop-color="#C711E1"> </stop> <stop offset="1" stop-color="#7F52FF"> </stop> </lineargradient> </defs> </svg> <span> Kotlin Coroutine </span> </a> <a class="leafygreen-ui-18cpm0b" href="https://www.mongodb.com/docs/languages/kotlin/kotlin-sync-driver/current/write/update/#update-one-document" target="_self"> <svg class="leafygreen-ui-x3zji3" fill="none" height="24" viewbox="0 0 28 29" width="24" xmlns="http://www.w3.org/2000/svg"> <path d="M28 29H0V1H28L14 15L28 29Z" fill="url(#:R39tdqcmqn9:paint0_linear_211_40588)"> </path> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":R39tdqcmqn9:paint0_linear_211_40588" x1="28" x2="8.34465e-07" y1="0.999999" y2="29"> <stop offset="0.00343514" stop-color="#E44857"> </stop> <stop offset="0.4689" stop-color="#C711E1"> </stop> <stop offset="1" stop-color="#7F52FF"> </stop> </lineargradient> </defs> </svg> <span> Kotlin Sync </span> </a> <a class="leafygreen-ui-18cpm0b" href="https://www.mongodb.com/docs/php-library/current/write/update/#update-one-document" target="_self"> <svg class="leafygreen-ui-x3zji3" height="24" viewbox="0 0 700 301" width="24" x="0" xmlns="http://www.w3.org/2000/svg" y="0"> <defs> <clippath clippathunits="userSpaceOnUse" id="a"> <path d="M11.52 162C11.52 81.677 135.307 16.561 288 16.561S564.481 81.677 564.481 162c0 80.322-123.788 145.439-276.481 145.439-152.693 0-276.48-65.117-276.48-145.439"> </path> </clippath> <clippath clippathunits="userSpaceOnUse" id="c"> <path d="M0 324h576V0H0v324z"> </path> </clippath> <clippath clippathunits="userSpaceOnUse" id="d"> <path d="M0 324h576V0H0v324z"> </path> </clippath> <radialgradient cx="0" cy="0" fx="0" fy="0" gradienttransform="matrix(363.05789 0 0 -363.05789 177.52 256.307)" gradientunits="userSpaceOnUse" id="b" r="1" spreadmethod="pad"> <stop offset="0" stop-color="#aeb2d5"> </stop> <stop offset=".3" stop-color="#aeb2d5"> </stop> <stop offset=".75" stop-color="#484c89"> </stop> <stop offset="1" stop-color="#484c89"> </stop> </radialgradient> </defs> <g clip-path="url(#a)" transform="matrix(1.25 0 0 -1.25 -4.4 394.299)"> <path d="M11.52 162C11.52 81.677 135.307 16.561 288 16.561S564.481 81.677 564.481 162c0 80.322-123.788 145.439-276.481 145.439-152.693 0-276.48-65.117-276.48-145.439" fill="url(#b)"> </path> </g> <g clip-path="url(#c)" transform="matrix(1.25 0 0 -1.25 -4.4 394.299)"> <path d="M288 27.36c146.729 0 265.68 60.28 265.68 134.64 0 74.36-118.951 134.641-265.68 134.641S22.32 236.36 22.32 162.001C22.32 87.64 141.271 27.358 288 27.358" fill="#777bb3"> </path> </g> <g clip-path="url(#d)" transform="matrix(1.25 0 0 -1.25 -4.4 394.299)"> <path d="M161.734 145.307c12.065 0 21.072 2.225 26.771 6.61 5.638 4.342 9.532 11.863 11.573 22.354 1.903 9.806 1.178 16.653-2.154 20.348-3.407 3.774-10.773 5.688-21.893 5.688h-19.28l-10.69-55h15.673zm-63.063-67.75a2.998 2.998 0 00-2.944 3.572l28.328 145.75a3 3 0 002.945 2.428h61.054c19.188 0 33.47-5.21 42.447-15.487 9.025-10.331 11.812-24.772 8.283-42.921-1.436-7.394-3.906-14.261-7.34-20.41-3.44-6.154-7.985-11.85-13.512-16.93-6.616-6.191-14.104-10.681-22.236-13.323-8.003-2.607-18.28-3.93-30.548-3.93h-24.722l-7.06-36.321a3 3 0 00-2.944-2.428h-31.75z"> </path> <path d="M159.224 197.307h16.808c13.42 0 18.083-2.945 19.667-4.7 2.628-2.914 3.124-9.058 1.435-17.767-1.898-9.75-5.416-16.663-10.458-20.545-5.162-3.974-13.554-5.988-24.941-5.988H149.7l9.523 49zm28.83 35H127a6 6 0 01-5.89-4.855L92.784 81.702a6 6 0 015.889-7.144h31.75a6 6 0 015.89 4.854l6.588 33.895h22.249c12.582 0 23.174 1.372 31.479 4.077 8.54 2.775 16.399 7.48 23.354 13.984 5.752 5.292 10.49 11.232 14.08 17.657 3.59 6.427 6.17 13.594 7.668 21.302 3.715 19.104.697 34.402-8.97 45.466-9.571 10.958-24.613 16.514-44.705 16.514m-45.633-90h19.313c12.8 0 22.336 2.411 28.6 7.234 6.267 4.824 10.493 12.875 12.689 24.157 2.1 10.832 1.144 18.476-2.871 22.93-4.02 4.452-12.06 6.68-24.121 6.68h-21.754l-11.856-61m45.633 84c18.367 0 31.766-4.82 40.188-14.462 8.42-9.64 10.957-23.098 7.597-40.375-1.383-7.117-3.722-13.624-7.015-19.519-3.297-5.899-7.602-11.293-12.922-16.184-6.34-5.933-13.383-10.16-21.133-12.679-7.75-2.525-17.621-3.782-29.621-3.782h-27.196l-7.531-38.75h-31.75L127 226.307h61.055" fill="#fff"> </path> <path d="M311.583 116.307c-.896 0-1.745.4-2.314 1.092a2.994 2.994 0 00-.631 2.48l12.531 64.489c1.192 6.133.898 10.535-.827 12.395-1.056 1.137-4.228 3.044-13.607 3.044h-22.702l-15.755-81.072a3 3 0 00-2.945-2.428h-31.5a2.998 2.998 0 00-2.945 3.572l28.328 145.75a3 3 0 002.945 2.428h31.5a3 3 0 002.945-3.572l-6.836-35.178h24.422c18.605 0 31.221-3.28 38.569-10.028 7.49-6.884 9.827-17.891 6.947-32.72l-13.18-67.824a3 3 0 00-2.945-2.428h-32z"> </path> <path d="M293.661 271.057h-31.5a6 6 0 01-5.89-4.855l-28.328-145.75a5.998 5.998 0 015.89-7.145h31.5a6 6 0 015.89 4.855l15.283 78.645h20.23c9.362 0 11.327-2 11.406-2.086.568-.61 1.315-3.44.082-9.78l-12.53-64.49a5.998 5.998 0 015.89-7.144h32a6 6 0 015.89 4.855l13.178 67.825c3.093 15.921.447 27.864-7.86 35.5-7.929 7.281-21.209 10.82-40.6 10.82h-20.784l6.143 31.605a6.001 6.001 0 01-5.89 7.145m0-6l-7.53-38.75h28.061c17.657 0 29.836-3.082 36.54-9.238 6.702-6.16 8.71-16.14 6.031-29.938l-13.18-67.824h-32l12.531 64.488c1.426 7.336.902 12.34-1.574 15.008-2.477 2.668-7.746 4.004-15.805 4.004H281.56l-16.226-83.5h-31.5l28.328 145.75h31.5" fill="#fff"> </path> <path d="M409.55 145.307c12.065 0 21.072 2.225 26.77 6.61 5.639 4.34 9.533 11.862 11.575 22.354 1.903 9.806 1.178 16.653-2.155 20.348-3.407 3.774-10.773 5.688-21.893 5.688h-19.281l-10.69-55h15.674zm-63.062-67.75a2.999 2.999 0 00-2.945 3.572l28.328 145.75a3.002 3.002 0 002.946 2.428h61.053c19.189 0 33.47-5.21 42.448-15.487 9.025-10.33 11.81-24.771 8.283-42.921-1.438-7.394-3.907-14.261-7.342-20.41-3.44-6.154-7.984-11.85-13.511-16.93-6.616-6.191-14.104-10.681-22.236-13.323-8.003-2.607-18.281-3.93-30.548-3.93H388.24l-7.057-36.321a3.001 3.001 0 00-2.946-2.428h-31.75z"> </path> <path d="M407.04 197.307h16.807c13.421 0 18.083-2.945 19.667-4.7 2.63-2.914 3.125-9.058 1.435-17.766-1.898-9.75-5.417-16.664-10.458-20.546-5.162-3.974-13.554-5.988-24.94-5.988h-12.034l9.522 49zm28.83 35h-61.054a6 6 0 01-5.889-4.855L340.6 81.702a6 6 0 015.889-7.144h31.75a6 6 0 015.89 4.854l6.587 33.895h22.25c12.581 0 23.173 1.372 31.478 4.077 8.541 2.775 16.401 7.481 23.356 13.986 5.752 5.291 10.488 11.23 14.078 17.655 3.591 6.427 6.171 13.594 7.668 21.302 3.715 19.105.697 34.403-8.969 45.467-9.572 10.957-24.613 16.513-44.706 16.513m-45.632-90h19.312c12.801 0 22.336 2.411 28.601 7.234 6.267 4.824 10.492 12.875 12.688 24.157 2.102 10.832 1.145 18.476-2.87 22.93-4.02 4.452-12.06 6.68-24.122 6.68h-21.754l-11.855-61m45.632 84c18.367 0 31.766-4.82 40.188-14.462 8.422-9.64 10.957-23.098 7.597-40.375-1.383-7.117-3.722-13.624-7.015-19.519-3.297-5.899-7.602-11.293-12.922-16.184-6.34-5.933-13.383-10.16-21.133-12.679-7.75-2.525-17.62-3.782-29.62-3.782h-27.197l-7.53-38.75h-31.75l28.328 145.75h61.054" fill="#fff"> </path> </g> </svg> <span> PHP </span> </a> <a class="leafygreen-ui-18cpm0b" href="https://www.mongodb.com/docs/mongoid/master/api/Mongoid/Persistable/Updatable.html#update_attribute-instance_method" target="_self"> <svg class="leafygreen-ui-x3zji3" height="24" preserveaspectratio="xMidYMid" viewbox="0 0 300 240" width="24" xmlns="http://www.w3.org/2000/svg"> <defs> <lineargradient id=":R3htdqcmqn9:a" x1="84.75%" x2="58.254%" y1="111.399%" y2="64.584%"> <stop offset="0%" stop-color="#FB7655"> </stop> <stop offset="0%" stop-color="#FB7655"> </stop> <stop offset="41%" stop-color="#E42B1E"> </stop> <stop offset="99%" stop-color="#900"> </stop> <stop offset="100%" stop-color="#900"> </stop> </lineargradient> <lineargradient id=":R3htdqcmqn9:b" x1="116.651%" x2="1.746%" y1="60.89%" y2="19.288%"> <stop offset="0%" stop-color="#871101"> </stop> <stop offset="0%" stop-color="#871101"> </stop> <stop offset="99%" stop-color="#911209"> </stop> <stop offset="100%" stop-color="#911209"> </stop> </lineargradient> <lineargradient id=":R3htdqcmqn9:c" x1="75.774%" x2="38.978%" y1="219.327%" y2="7.829%"> <stop offset="0%" stop-color="#871101"> </stop> <stop offset="0%" stop-color="#871101"> </stop> <stop offset="99%" stop-color="#911209"> </stop> <stop offset="100%" stop-color="#911209"> </stop> </lineargradient> <lineargradient id=":R3htdqcmqn9:d" x1="50.012%" x2="66.483%" y1="7.234%" y2="79.135%"> <stop offset="0%" stop-color="#FFF"> </stop> <stop offset="0%" stop-color="#FFF"> </stop> <stop offset="23%" stop-color="#E57252"> </stop> <stop offset="46%" stop-color="#DE3B20"> </stop> <stop offset="99%" stop-color="#A60003"> </stop> <stop offset="100%" stop-color="#A60003"> </stop> </lineargradient> <lineargradient id=":R3htdqcmqn9:e" x1="46.174%" x2="49.932%" y1="16.348%" y2="83.047%"> <stop offset="0%" stop-color="#FFF"> </stop> <stop offset="0%" stop-color="#FFF"> </stop> <stop offset="23%" stop-color="#E4714E"> </stop> <stop offset="56%" stop-color="#BE1A0D"> </stop> <stop offset="99%" stop-color="#A80D00"> </stop> <stop offset="100%" stop-color="#A80D00"> </stop> </lineargradient> <lineargradient id=":R3htdqcmqn9:f" x1="36.965%" x2="49.528%" y1="15.594%" y2="92.478%"> <stop offset="0%" stop-color="#FFF"> </stop> <stop offset="0%" stop-color="#FFF"> </stop> <stop offset="18%" stop-color="#E46342"> </stop> <stop offset="40%" stop-color="#C82410"> </stop> <stop offset="99%" stop-color="#A80D00"> </stop> <stop offset="100%" stop-color="#A80D00"> </stop> </lineargradient> <lineargradient id=":R3htdqcmqn9:g" x1="13.609%" x2="85.764%" y1="58.346%" y2="-46.717%"> <stop offset="0%" stop-color="#FFF"> </stop> <stop offset="0%" stop-color="#FFF"> </stop> <stop offset="54%" stop-color="#C81F11"> </stop> <stop offset="99%" stop-color="#BF0905"> </stop> <stop offset="100%" stop-color="#BF0905"> </stop> </lineargradient> <lineargradient id=":R3htdqcmqn9:h" x1="27.624%" x2="50.745%" y1="21.135%" y2="79.056%"> <stop offset="0%" stop-color="#FFF"> </stop> <stop offset="0%" stop-color="#FFF"> </stop> <stop offset="31%" stop-color="#DE4024"> </stop> <stop offset="99%" stop-color="#BF190B"> </stop> <stop offset="100%" stop-color="#BF190B"> </stop> </lineargradient> <lineargradient id=":R3htdqcmqn9:i" x1="-20.667%" x2="104.242%" y1="122.282%" y2="-6.342%"> <stop offset="0%" stop-color="#BD0012"> </stop> <stop offset="0%" stop-color="#BD0012"> </stop> <stop offset="7%" stop-color="#FFF"> </stop> <stop offset="17%" stop-color="#FFF"> </stop> <stop offset="27%" stop-color="#C82F1C"> </stop> <stop offset="33%" stop-color="#820C01"> </stop> <stop offset="46%" stop-color="#A31601"> </stop> <stop offset="72%" stop-color="#B31301"> </stop> <stop offset="99%" stop-color="#E82609"> </stop> <stop offset="100%" stop-color="#E82609"> </stop> </lineargradient> <lineargradient id=":R3htdqcmqn9:j" x1="58.792%" x2="11.964%" y1="65.205%" y2="50.128%"> <stop offset="0%" stop-color="#8C0C01"> </stop> <stop offset="0%" stop-color="#8C0C01"> </stop> <stop offset="54%" stop-color="#990C00"> </stop> <stop offset="99%" stop-color="#A80D0E"> </stop> <stop offset="100%" stop-color="#A80D0E"> </stop> </lineargradient> <lineargradient id=":R3htdqcmqn9:k" x1="79.319%" x2="23.088%" y1="62.754%" y2="17.888%"> <stop offset="0%" stop-color="#7E110B"> </stop> <stop offset="0%" stop-color="#7E110B"> </stop> <stop offset="99%" stop-color="#9E0C00"> </stop> <stop offset="100%" stop-color="#9E0C00"> </stop> </lineargradient> <lineargradient id=":R3htdqcmqn9:l" x1="92.88%" x2="59.841%" y1="74.122%" y2="39.704%"> <stop offset="0%" stop-color="#79130D"> </stop> <stop offset="0%" stop-color="#79130D"> </stop> <stop offset="99%" stop-color="#9E120B"> </stop> <stop offset="100%" stop-color="#9E120B"> </stop> </lineargradient> <lineargradient id=":R3htdqcmqn9:o" x1="56.57%" x2="3.105%" y1="101.717%" y2="11.993%"> <stop offset="0%" stop-color="#8B2114"> </stop> <stop offset="0%" stop-color="#8B2114"> </stop> <stop offset="43%" stop-color="#9E100A"> </stop> <stop offset="99%" stop-color="#B3100C"> </stop> <stop offset="100%" stop-color="#B3100C"> </stop> </lineargradient> <lineargradient id=":R3htdqcmqn9:p" x1="30.87%" x2="92.471%" y1="35.599%" y2="100.694%"> <stop offset="0%" stop-color="#B31000"> </stop> <stop offset="0%" stop-color="#B31000"> </stop> <stop offset="44%" stop-color="#910F08"> </stop> <stop offset="99%" stop-color="#791C12"> </stop> <stop offset="100%" stop-color="#791C12"> </stop> </lineargradient> <radialgradient cx="32.001%" cy="40.21%" fx="32.001%" fy="40.21%" id=":R3htdqcmqn9:m" r="69.573%"> <stop offset="0%" stop-color="#A80D00"> </stop> <stop offset="0%" stop-color="#A80D00"> </stop> <stop offset="99%" stop-color="#7E0E08"> </stop> <stop offset="100%" stop-color="#7E0E08"> </stop> </radialgradient> <radialgradient cx="13.549%" cy="40.86%" fx="13.549%" fy="40.86%" id=":R3htdqcmqn9:n" r="88.386%"> <stop offset="0%" stop-color="#A30C00"> </stop> <stop offset="0%" stop-color="#A30C00"> </stop> <stop offset="99%" stop-color="#800E08"> </stop> <stop offset="100%" stop-color="#800E08"> </stop> </radialgradient> </defs> <path d="M197.467 167.764l-145.52 86.41 188.422-12.787L254.88 51.393l-57.414 116.37z" fill="url(#:R3htdqcmqn9:a)"> </path> <path d="M240.677 241.257L224.482 129.48l-44.113 58.25 60.308 53.528z" fill="url(#:R3htdqcmqn9:b)"> </path> <path d="M240.896 241.257l-118.646-9.313-69.674 21.986 188.32-12.673z" fill="url(#:R3htdqcmqn9:c)"> </path> <path d="M52.744 253.955l29.64-97.1L17.16 170.8l35.583 83.154z" fill="url(#:R3htdqcmqn9:d)"> </path> <path d="M180.358 188.05L153.085 81.226l-78.047 73.16 105.32 33.666z" fill="url(#:R3htdqcmqn9:e)"> </path> <path d="M248.693 82.73l-73.777-60.256-20.544 66.418 94.321-6.162z" fill="url(#:R3htdqcmqn9:f)"> </path> <path d="M214.191.99L170.8 24.97 143.424.669l70.767.322z" fill="url(#:R3htdqcmqn9:g)"> </path> <path d="M0 203.372l18.177-33.151-14.704-39.494L0 203.372z" fill="url(#:R3htdqcmqn9:h)"> </path> <path d="M2.496 129.48l14.794 41.963 64.283-14.422 73.39-68.207 20.712-65.787L143.063 0 87.618 20.75c-17.469 16.248-51.366 48.396-52.588 49-1.21.618-22.384 40.639-32.534 59.73z" fill="#FFF"> </path> <path d="M54.442 54.094c37.86-37.538 86.667-59.716 105.397-40.818 18.72 18.898-1.132 64.823-38.992 102.349-37.86 37.525-86.062 60.925-104.78 42.027-18.73-18.885.515-66.032 38.375-103.558z" fill="url(#:R3htdqcmqn9:i)"> </path> <path d="M52.744 253.916l29.408-97.409 97.665 31.376c-35.312 33.113-74.587 61.106-127.073 66.033z" fill="url(#:R3htdqcmqn9:j)"> </path> <path d="M155.092 88.622l25.073 99.313c29.498-31.016 55.972-64.36 68.938-105.603l-94.01 6.29z" fill="url(#:R3htdqcmqn9:k)"> </path> <path d="M248.847 82.833c10.035-30.282 12.35-73.725-34.966-81.791l-38.825 21.445 73.791 60.346z" fill="url(#:R3htdqcmqn9:l)"> </path> <path d="M0 202.935c1.39 49.979 37.448 50.724 52.808 51.162l-35.48-82.86L0 202.935z" fill="#9E1209"> </path> <path d="M155.232 88.777c22.667 13.932 68.35 41.912 69.276 42.426 1.44.81 19.695-30.784 23.838-48.64l-93.114 6.214z" fill="url(#:R3htdqcmqn9:m)"> </path> <path d="M82.113 156.507l39.313 75.848c23.246-12.607 41.45-27.967 58.121-44.42l-97.434-31.428z" fill="url(#:R3htdqcmqn9:n)"> </path> <path d="M17.174 171.34l-5.57 66.328c10.51 14.357 24.97 15.605 40.136 14.486-10.973-27.311-32.894-81.92-34.566-80.814z" fill="url(#:R3htdqcmqn9:o)"> </path> <path d="M174.826 22.654l78.1 10.96c-4.169-17.662-16.969-29.06-38.787-32.623l-39.313 21.663z" fill="url(#:R3htdqcmqn9:p)"> </path> </svg> <span> Mongoid </span> </a> <a class="leafygreen-ui-18cpm0b" href="https://www.mongodb.com/docs/drivers/rust/current/fundamentals/crud/write-operations/change/#update-documents" target="_self"> <svg class="leafygreen-ui-x3zji3" height="24" viewbox="0 0 30 30" width="24" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_5454_14623)"> <path d="M15.2561 3.08398C8.56014 3.08398 3.11035 8.53634 3.11035 15.2297C3.11035 21.9231 8.56271 27.3755 15.2561 27.3755C21.9495 27.3755 27.4019 21.9231 27.4019 15.2297C27.4019 8.53634 21.9495 3.08398 15.2561 3.08398ZM15.2381 4.16315C15.4458 4.16853 15.6432 4.25509 15.7881 4.40437C15.9331 4.55365 16.0142 4.75384 16.0141 4.96225C16.0141 5.17418 15.9299 5.37744 15.7801 5.5273C15.6302 5.67715 15.4269 5.76134 15.215 5.76134C15.0031 5.76134 14.7998 5.67715 14.65 5.5273C14.5001 5.37744 14.4159 5.17418 14.4159 4.96225C14.4159 4.85533 14.4373 4.7495 14.4789 4.65101C14.5205 4.55252 14.5814 4.46338 14.6581 4.38887C14.7347 4.31435 14.8256 4.25598 14.9252 4.21721C15.0249 4.17844 15.1313 4.16006 15.2381 4.16315ZM17.0676 5.47871C18.4704 5.74146 19.7992 6.30644 20.9617 7.13439C22.1242 7.96235 23.0926 9.03345 23.7995 10.2733L22.8565 12.4008C22.6947 12.7682 22.8617 13.1999 23.2265 13.3643L25.0406 14.1686C25.0968 14.7356 25.1037 15.3065 25.0611 15.8747H24.0513C23.9511 15.8747 23.91 15.9415 23.91 16.0391V16.5016C23.91 17.5911 23.2959 17.83 22.7563 17.8891C22.2424 17.9482 21.6746 17.6733 21.6026 17.3598C21.2994 15.6563 20.7958 15.294 19.9993 14.6645C20.9885 14.0375 22.0163 13.11 22.0163 11.8715C22.0163 10.5328 21.099 9.69002 20.4747 9.27634C19.5959 8.69822 18.6247 8.5826 18.3626 8.5826H7.93063C9.37312 6.97114 11.3066 5.88021 13.4318 5.47871L14.6626 6.76857C14.9401 7.05891 15.4 7.07176 15.6903 6.79169L17.0676 5.47871ZM5.71063 11.3936C5.91853 11.3996 6.11589 11.4864 6.26079 11.6356C6.40568 11.7849 6.48669 11.9847 6.4866 12.1927C6.4866 12.4046 6.40241 12.6079 6.25255 12.7577C6.10269 12.9076 5.89944 12.9918 5.6875 12.9918C5.47557 12.9918 5.27232 12.9076 5.12246 12.7577C4.9726 12.6079 4.88841 12.4046 4.88841 12.1927C4.88836 12.0858 4.90977 11.9799 4.95137 11.8814C4.99297 11.7829 5.0539 11.6938 5.13057 11.6193C5.20724 11.5448 5.29809 11.4864 5.39772 11.4476C5.49736 11.4089 5.60376 11.3905 5.71063 11.3936ZM24.7631 11.4295C24.971 11.4356 25.1683 11.5224 25.3132 11.6716C25.4581 11.8208 25.5391 12.0206 25.539 12.2286C25.539 12.4406 25.4548 12.6438 25.305 12.7937C25.1551 12.9435 24.9519 13.0277 24.7399 13.0277C24.528 13.0277 24.3247 12.9435 24.1749 12.7937C24.025 12.6438 23.9408 12.4406 23.9408 12.2286C23.9408 12.1217 23.9622 12.0159 24.0038 11.9174C24.0454 11.8189 24.1063 11.7298 24.183 11.6553C24.2597 11.5807 24.3505 11.5224 24.4502 11.4836C24.5498 11.4448 24.6562 11.4264 24.7631 11.4295ZM7.21632 11.558H8.60896V17.8377H5.79799C5.45083 16.6186 5.34264 15.3439 5.47938 14.0838L7.20091 13.3181C7.56834 13.1536 7.73535 12.7245 7.57091 12.3571L7.21632 11.558ZM13.0284 11.6248H16.3456C16.5177 11.6248 17.5558 11.8227 17.5558 12.6012C17.5558 13.2461 16.7592 13.4774 16.104 13.4774H13.0258L13.0284 11.6248ZM13.0284 16.1368H15.5696C15.8008 16.1368 16.8106 16.2036 17.1318 17.4934C17.232 17.8891 17.4556 19.179 17.6072 19.5927C17.7588 20.0552 18.3729 20.9802 19.0281 20.9802H23.1751C22.8972 21.3524 22.5933 21.7044 22.2656 22.0336L20.5774 21.6713C20.1843 21.5866 19.7963 21.8384 19.7115 22.2315L19.3107 24.102C18.0217 24.6859 16.622 24.9848 15.2069 24.9781C13.7919 24.9714 12.395 24.6595 11.1116 24.0635L10.7108 22.1929C10.626 21.7998 10.2406 21.548 9.84743 21.6328L8.19528 21.9874C7.88869 21.6711 7.6037 21.3346 7.34223 20.9802H15.3769C15.4668 20.9802 15.5285 20.9647 15.5285 20.88V18.0381C15.5285 17.9559 15.4668 17.9379 15.3769 17.9379H13.0258L13.0284 16.1368ZM9.3207 22.6452C9.5286 22.6512 9.72596 22.738 9.87085 22.8872C10.0157 23.0364 10.0968 23.2363 10.0967 23.4443C10.0967 23.6562 10.0125 23.8594 9.86262 24.0093C9.71276 24.1592 9.50951 24.2434 9.29757 24.2434C9.08564 24.2434 8.88239 24.1592 8.73253 24.0093C8.58267 23.8594 8.49848 23.6562 8.49848 23.4443C8.49843 23.3373 8.51984 23.2315 8.56144 23.133C8.60303 23.0345 8.66397 22.9454 8.74064 22.8709C8.81731 22.7964 8.90815 22.738 9.00779 22.6992C9.10743 22.6605 9.21383 22.6421 9.3207 22.6452ZM21.153 22.6811C21.3609 22.6872 21.5583 22.774 21.7031 22.9232C21.848 23.0724 21.929 23.2722 21.929 23.4802C21.929 23.6922 21.8448 23.8954 21.6949 24.0453C21.5451 24.1951 21.3418 24.2793 21.1299 24.2793C20.9179 24.2793 20.7147 24.1951 20.5648 24.0453C20.415 23.8954 20.3308 23.6922 20.3308 23.4802C20.3307 23.3733 20.3521 23.2675 20.3937 23.169C20.4353 23.0705 20.4963 22.9814 20.5729 22.9068C20.6496 22.8323 20.7404 22.774 20.8401 22.7352C20.9397 22.6964 21.0461 22.678 21.153 22.6811Z" fill="black"> </path> <path clip-rule="evenodd" d="M26.7232 15.2304C26.7232 18.2717 25.515 21.1885 23.3645 23.3391C21.2139 25.4896 18.2971 26.6978 15.2558 26.6978C12.2144 26.6978 9.29761 25.4896 7.14705 23.3391C4.99649 21.1885 3.78832 18.2717 3.78832 15.2304C3.78832 12.189 4.99649 9.27222 7.14705 7.12166C9.29761 4.9711 12.2144 3.76293 15.2558 3.76293C18.2971 3.76293 21.2139 4.9711 23.3645 7.12166C25.515 9.27222 26.7232 12.189 26.7232 15.2304ZM26.5073 14.1229L28.2957 15.2304L26.5073 16.3378L28.0439 17.7741L26.0757 18.5115L27.3039 20.2202L25.2252 20.5594L26.0988 22.4762L23.9944 22.4017L24.4775 24.4521L22.4271 23.969L22.5016 26.0734L20.5848 25.1998L20.2456 27.2785L18.5369 26.0503L17.7995 28.0185L16.3632 26.482L15.2558 28.2703L14.1483 26.482L12.712 28.0185L11.9746 26.0503L10.2659 27.2785L9.92672 25.1998L8.00992 26.0734L8.08443 23.969L6.03401 24.4521L6.51707 22.4017L4.4127 22.4762L5.28631 20.5594L3.20763 20.2202L4.43582 18.5115L2.46763 17.7741L4.00415 16.3378L2.21582 15.2304L4.00415 14.1229L2.46763 12.6866L4.43582 11.9492L3.20763 10.2405L5.28631 9.90133L4.4127 7.98453L6.51707 8.05904L6.03401 6.00862L8.08443 6.49168L8.00992 4.3873L9.92672 5.26092L10.2659 3.18223L11.9746 4.41043L12.712 2.44224L14.1483 3.97876L15.2558 2.19043L16.3632 3.97876L17.7995 2.44224L18.5369 4.41043L20.2456 3.18223L20.5848 5.26092L22.5016 4.3873L22.4271 6.49168L24.4775 6.00862L23.9944 8.05904L26.0988 7.98453L25.2252 9.90133L27.3039 10.2405L26.0757 11.9492L28.0439 12.6866L26.5073 14.1229Z" fill="black" fill-rule="evenodd" stroke-linecap="round" stroke-linejoin="round"> </path> </g> <defs> <clippath id="clip0_5454_14623"> <rect fill="black" height="30" width="30"> </rect> </clippath> </defs> </svg> <span> Rust </span> </a> <a class="leafygreen-ui-18cpm0b" href="https://www.mongodb.com/docs/languages/scala/scala-driver/current/tutorials/write-ops/#update-a-single-document" target="_self"> <svg class="leafygreen-ui-x3zji3" height="24" viewbox="0 0 70 70" width="24" xmlns="http://www.w3.org/2000/svg"> <defs> <lineargradient id=":R3ptdqcmqn9:aaa" x1=".006%" x2="96.837%" y1="49.998%" y2="49.998%"> <stop offset="0%" stop-color="#CD413F"> </stop> <stop offset="75.091%" stop-color="#CD4543"> </stop> <stop offset="100%" stop-color="#D04543"> </stop> </lineargradient> </defs> <g fill="none" fill-rule="nonzero"> <path d="M13 39v5c0 .843 17.73 2.255 29.28 5 5.582-1.327 9.72-2.966 9.72-5v-5c0-2.034-4.138-3.673-9.72-5C30.73 36.745 13 38.157 13 39M13 20v5c0 .843 17.73 2.255 29.28 5 5.582-1.327 9.72-2.966 9.72-5v-5c0-2.034-4.138-3.673-9.72-5C30.73 17.745 13 19.157 13 20" fill="#731818"> </path> <g fill="url(#:R3ptdqcmqn9:aaa)" transform="translate(13)"> <path d="M0 29.53v14.766c0-1.232 39-3.692 39-9.844V19.686c0 6.152-39 8.612-39 9.844M0 9.843V24.61c0-1.231 39-3.691 39-9.843V0C39 6.152 0 8.612 0 9.843M0 49.216v14.766c0-1.231 39-3.691 39-9.843V39.373c0 6.151-39 8.612-39 9.843"> </path> </g> </g> </svg> <span> Scala </span> </a> </div> <button class="leafygreen-ui-ki2t97"> Show all <svg aria-label="Chevron Down Icon" class="" fill="none" height="16" role="img" viewbox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M1.636 5.364a1 1 0 0 0 0 1.414l4.95 4.95.707.707a1 1 0 0 0 1.414 0l.707-.707 4.95-4.95a1 1 0 0 0 0-1.414l-.707-.707a1 1 0 0 0-1.414 0L8 8.899 3.757 4.657a1 1 0 0 0-1.414 0l-.707.707Z" fill="currentColor" fill-rule="evenodd"> </path> </svg> </button> </div> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Definition <a class="headerlink leafygreen-ui-1kepx47" href="#definition" 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="definition"> </div> </a> </h2> <dl class="method"> <dt> <code class="leafygreen-ui-1l06pbn"> db.collection.updateOne(filter, update, options) </code> <a class="headerlink leafygreen-ui-1kepx47" href="#mongodb-method-db.collection.updateOne" title="Permalink to this definition"> <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="mongodb-method-db.collection.updateOne"> </div> </a> </dt> <dd> <p class="leafygreen-ui-1kp3ins"> Updates a single document within the collection based on the filter. </p> </dd> </dl> </section> <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 <code class="leafygreen-ui-1l06pbn"> db.collection.updateOne() </code> 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"> Syntax <a class="headerlink leafygreen-ui-1kepx47" href="#syntax" 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="syntax"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> The <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-method-db.collection.updateOne" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> updateOne() </code> </span> </a> method has the following syntax: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.collection.updateOne(\n &lt;filter&gt;,\n &lt;update&gt;,\n {\n upsert: &lt;boolean&gt;,\n writeConcern: &lt;document&gt;,\n collation: &lt;document&gt;,\n arrayFilters: [ &lt;filterdocument1&gt;, ... ],\n hint: &lt;document|string&gt;,\n let: &lt;document&gt;,\n sort: &lt;document&gt;\n }\n)","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">updateOne</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> &lt;<!-- -->filter<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->&lt;<!-- -->update<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">upsert</span>: &lt;<!-- -->boolean<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">writeConcern</span>: &lt;<span class="lg-highlight-variable lg-highlight-language">document</span>&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">collation</span>: &lt;<span class="lg-highlight-variable lg-highlight-language">document</span>&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">arrayFilters</span>: <!-- -->[ &lt;<!-- -->filterdocument1<!-- -->&gt;<!-- -->,<!-- --> <!-- -->...<!-- --> ]<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">hint</span>: <!-- -->&lt;document|string&gt;,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> let: &lt;document&gt;,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> sort: &lt;document&gt;</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">)</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> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Parameters <a class="headerlink leafygreen-ui-1kepx47" href="#parameters" 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="parameters"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> The <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-method-db.collection.updateOne" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> db.collection.updateOne() </code> </span> </a> method takes the following parameters: </p> <div class="leafygreen-ui-skkc39" tabindex="0"> <table class="leafygreen-ui-hr8lsv"> <colgroup> <col style="width:20%"/> <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> Parameter </div> </div> </th> <th class="leafygreen-ui-13uteka" role="columnheader" scope="col"> <div class="leafygreen-ui-ui0te9"> <div> Type </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="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-update-one-filter" target="_self"> <span> filter </span> </a> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> document </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <span class="leafygreen-ui-1qnjd6d" id="std-label-update-one-filter"> </span> <p class="leafygreen-ui-1kp3ins"> The selection criteria for the update. The same <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/query/#std-label-query-selectors"> query selectors </a> as in the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/db.collection.find/#mongodb-method-db.collection.find"> <code class="leafygreen-ui-1l06pbn"> find() </code> </a> method are available. </p> <p class="leafygreen-ui-1kp3ins"> Specify an empty document <code class="leafygreen-ui-1l06pbn"> { } </code> to update the first document returned in the collection. </p> </div> </div> </td> </tr> <tr class=""> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-update-one-update" target="_self"> <span> update </span> </a> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> document or pipeline </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <span class="leafygreen-ui-1qnjd6d" id="std-label-update-one-update"> </span> <p class="leafygreen-ui-1kp3ins"> The modifications to apply. Can be one of the following: </p> <div class="leafygreen-ui-skkc39" tabindex="0"> <table class="leafygreen-ui-hr8lsv"> <colgroup> <col style="width:40%"/> <col style="width:80%"/> </colgroup> <thead class="leafygreen-ui-a9ho40"> </thead> <tbody> <tr class=""> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-update-one-method-update-document" target="_self"> <span> Update document </span> </a> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <span class="leafygreen-ui-1qnjd6d" id="std-label-update-one-method-update-document"> </span> <p class="leafygreen-ui-1kp3ins"> Contains only <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/update/#std-label-update-operators"> update operator expressions <!-- --> . </a> </p> <p class="leafygreen-ui-1kp3ins"> For more information, see <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-updateOne-behavior-update-expressions" target="_self"> <span> Update with an Update Operator Expressions Document </span> </a> </p> </div> </div> </td> </tr> <tr class=""> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-update-one-method-agg-pipeline" target="_self"> <span> Aggregation pipeline </span> </a> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <span class="leafygreen-ui-1qnjd6d" id="std-label-update-one-method-agg-pipeline"> </span> <p class="leafygreen-ui-1kp3ins"> Contains only the following aggregation 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> <p class="leafygreen-ui-1kp3ins"> For more information, see <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-updateOne-behavior-aggregation-pipeline" target="_self"> <span> Update with an Aggregation Pipeline <!-- --> . </span> </a> </p> </div> </div> </td> </tr> </tbody> </table> </div> <p class="leafygreen-ui-1kp3ins"> To update with a replacement document, see <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/db.collection.replaceOne/#mongodb-method-db.collection.replaceOne"> <code class="leafygreen-ui-1l06pbn"> db.collection.replaceOne() </code> . </a> </p> </div> </div> </td> </tr> <tr class=""> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> upsert </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> boolean </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <p class="leafygreen-ui-1kp3ins"> Optional. When <code class="leafygreen-ui-1l06pbn"> true </code> , <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-method-db.collection.updateOne" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> updateOne() </code> </span> </a> either: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Creates a new document if no documents match the <code class="leafygreen-ui-1l06pbn"> filter </code> . For more details see <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/db.collection.update/#std-label-upsert-behavior"> upsert behavior <!-- --> . </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Updates a single document that matches the <code class="leafygreen-ui-1l06pbn"> filter </code> . </p> </li> </ul> <p class="leafygreen-ui-1kp3ins"> To avoid multiple <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-upsert"> upserts </a> , ensure that the <code class="leafygreen-ui-1l06pbn"> filter </code> field(s) are <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/index-unique/#std-label-index-type-unique"> uniquely indexed <!-- --> . </a> </p> <p class="leafygreen-ui-1kp3ins"> Defaults to <code class="leafygreen-ui-1l06pbn"> false </code> , which does <em> not </em> insert a new document when no match is found. </p> </div> </div> </td> </tr> <tr class=""> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> writeConcern </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> document </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <p class="leafygreen-ui-1kp3ins"> Optional. A document expressing the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/write-concern/"> write concern </a> . Omit to use the default write concern. </p> <p class="leafygreen-ui-1kp3ins"> Do not explicitly set the write concern for the operation if run in a transaction. To use write concern with transactions, see <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/transactions/#std-label-transactions-write-concern"> Transactions and Write Concern <!-- --> . </a> </p> </div> </div> </td> </tr> <tr class=""> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> collation </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> document </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <p class="leafygreen-ui-1kp3ins"> Optional. </p> <p class="leafygreen-ui-1kp3ins"> Specifies the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/collation/#std-label-collation"> collation </a> to use for the operation. </p> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/collation/#std-label-collation"> Collation </a> allows users to specify language-specific rules for string comparison, such as rules for lettercase and accent marks. </p> <p class="leafygreen-ui-1kp3ins"> The collation option has the following syntax: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"collation: {\n locale: &lt;string&gt;,\n caseLevel: &lt;boolean&gt;,\n caseFirst: &lt;string&gt;,\n strength: &lt;int&gt;,\n numericOrdering: &lt;boolean&gt;,\n alternate: &lt;string&gt;,\n maxVariable: &lt;string&gt;,\n backwards: &lt;boolean&gt;\n}"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" tabindex="-1"><code class="lg-highlight-hljs-light none leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">collation: {</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> locale: &lt;string&gt;,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> caseLevel: &lt;boolean&gt;,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> caseFirst: &lt;string&gt;,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> strength: &lt;int&gt;,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> numericOrdering: &lt;boolean&gt;,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> alternate: &lt;string&gt;,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> maxVariable: &lt;string&gt;,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> backwards: &lt;boolean&gt;</td></tr><tr class=""><td class="leafygreen-ui-7razhx">}</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"> When specifying collation, the <code class="leafygreen-ui-1l06pbn"> locale </code> field is mandatory; all other collation fields are optional. For descriptions of the fields, see <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/collation/#std-label-collation-document-fields"> Collation Document <!-- --> . </a> </p> <p class="leafygreen-ui-1kp3ins"> If the collation is unspecified but the collection has a default collation (see <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/db.createCollection/#mongodb-method-db.createCollection"> <code class="leafygreen-ui-1l06pbn"> db.createCollection() </code> </a> ), the operation uses the collation specified for the collection. </p> <p class="leafygreen-ui-1kp3ins"> If no collation is specified for the collection or for the operations, MongoDB uses the simple binary comparison used in prior versions for string comparisons. </p> <p class="leafygreen-ui-1kp3ins"> You cannot specify multiple collations for an operation. For example, you cannot specify different collations per field, or if performing a find with a sort, you cannot use one collation for the find and another for the sort. </p> </div> </div> </td> </tr> <tr class=""> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> arrayFilters </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> array </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <p class="leafygreen-ui-1kp3ins"> Optional. An array of filter documents that determine which array elements to modify for an update operation on an array field. </p> <p class="leafygreen-ui-1kp3ins"> In the update document, use the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/update/positional-filtered/#mongodb-update-up.---identifier--"> <code class="leafygreen-ui-1l06pbn"> $[&lt;identifier&gt;] </code> </a> filtered positional operator to define an identifier, which you then reference in the array filter documents. You cannot have an array filter document for an identifier if the identifier is not included in the update document. </p> <p class="leafygreen-ui-1kp3ins"> The <code class="leafygreen-ui-1l06pbn"> &lt;identifier&gt; </code> must begin with a lowercase letter and contain only alphanumeric characters. </p> <p class="leafygreen-ui-1kp3ins"> You can include the same identifier multiple times in the update document; however, for each distinct identifier ( <code class="leafygreen-ui-1l06pbn"> $[identifier] </code> ) in the update document, you must specify <strong> exactly one </strong> corresponding array filter document. That is, you cannot specify multiple array filter documents for the same identifier. For example, if the update statement includes the identifier <code class="leafygreen-ui-1l06pbn"> x </code> (possibly multiple times), you cannot specify the following for <code class="leafygreen-ui-1l06pbn"> arrayFilters </code> that includes 2 separate filter documents for <code class="leafygreen-ui-1l06pbn"> x </code> : </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"// INVALID\n\n[\n { \"x.a\": { $gt: 85 } },\n { \"x.b\": { $gt: 80 } }\n]","programmingLanguage":"JavaScript"} </script> <div class="css-1lju8ps"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1jheeh3"> <pre class="leafygreen-ui-1453az5" 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"><span class="lg-highlight-comment">// INVALID</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"><div class="leafygreen-ui-ihxujy"></div></td></tr><tr class=""><td class="leafygreen-ui-7razhx">[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"x.a"</span>: <!-- -->{ <span class="lg-highlight-attr">$gt</span>: <span class="lg-highlight-number">85</span> } }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"x.b"</span>: <!-- -->{ <span class="lg-highlight-attr">$gt</span>: <span class="lg-highlight-number">80</span> } }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">]</td></tr></tbody></table></code></pre> </div> </div> </div> <p class="leafygreen-ui-1kp3ins"> However, you can specify compound conditions on the same identifier in a single filter document, such as in the following examples: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"// Example 1\n[\n { $or: [{\"x.a\": {$gt: 85}}, {\"x.b\": {$gt: 80}}] }\n]\n// Example 2\n[\n { $and: [{\"x.a\": {$gt: 85}}, {\"x.b\": {$gt: 80}}] }\n]\n// Example 3\n[\n { \"x.a\": { $gt: 85 }, \"x.b\": { $gt: 80 } }\n]","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-comment">// Example 1</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx">[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">$or</span>: <!-- -->[<!-- -->{<span class="lg-highlight-string">"x.a"</span>: <!-- -->{<span class="lg-highlight-attr">$gt</span>: <span class="lg-highlight-number">85</span>}}<!-- -->, <!-- -->{<span class="lg-highlight-string">"x.b"</span>: <!-- -->{<span class="lg-highlight-attr">$gt</span>: <span class="lg-highlight-number">80</span>}}] }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">]</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-comment">// Example 2</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx">[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">$and</span>: <!-- -->[<!-- -->{<span class="lg-highlight-string">"x.a"</span>: <!-- -->{<span class="lg-highlight-attr">$gt</span>: <span class="lg-highlight-number">85</span>}}<!-- -->, <!-- -->{<span class="lg-highlight-string">"x.b"</span>: <!-- -->{<span class="lg-highlight-attr">$gt</span>: <span class="lg-highlight-number">80</span>}}] }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">]</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-comment">// Example 3</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx">[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"x.a"</span>: <!-- -->{ <span class="lg-highlight-attr">$gt</span>: <span class="lg-highlight-number">85</span> }<!-- -->, <span class="lg-highlight-string">"x.b"</span>: <!-- -->{ <span class="lg-highlight-attr">$gt</span>: <span class="lg-highlight-number">80</span> } }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">]</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"> For examples, see <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-updateOne-arrayFilters" target="_self"> <span> Specify <code class="leafygreen-ui-1l06pbn"> arrayFilters </code> for an Array Update Operations <!-- --> . </span> </a> </p> </div> </div> </td> </tr> <tr class=""> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-update-one-hint" target="_self"> <span> hint </span> </a> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Document or string </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <span class="leafygreen-ui-1qnjd6d" id="std-label-update-one-hint"> </span> <p class="leafygreen-ui-1kp3ins"> Optional. A document or string that specifies the <a class="leafygreen-ui-tqgtui" href="/docs/manual/indexes/#std-label-indexes"> index </a> to use to support the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-update-one-filter" target="_self"> <span> query predicate <!-- --> . </span> </a> </p> <p class="leafygreen-ui-1kp3ins"> The option can take an index specification document or the index name string. </p> <p class="leafygreen-ui-1kp3ins"> If you specify an index that does not exist, the operation errors. </p> <p class="leafygreen-ui-1kp3ins"> For an example, see <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-ex-update-one-hint" target="_self"> <span> Specify <code class="leafygreen-ui-1l06pbn"> hint </code> for Update Operations <!-- --> . </span> </a> </p> </div> </div> </td> </tr> <tr class=""> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> let </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Document </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <span class="leafygreen-ui-1qnjd6d" id="std-label-updateOne-let-syntax"> </span> <p class="leafygreen-ui-1kp3ins"> Optional. </p> <p class="leafygreen-ui-1kp3ins"> Specifies a document with a list of variables. This allows you to improve command readability by separating the variables from the query text. </p> <p class="leafygreen-ui-1kp3ins"> The document syntax is: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{\n &lt;variable_name_1&gt;: &lt;expression_1&gt;,\n ...,\n &lt;variable_name_n&gt;: &lt;expression_n&gt;\n}","programmingLanguage":"JavaScript"} </script> <div class="css-1lju8ps"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1jheeh3"> <pre class="leafygreen-ui-1453az5" 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">{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> &lt;<!-- -->variable_name_1<!-- -->&gt;<!-- -->: &lt;<!-- -->expression_1<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->...<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> &lt;<!-- -->variable_name_n<!-- -->&gt;<!-- -->: &lt;<!-- -->expression_n<!-- -->&gt;</td></tr><tr class=""><td class="leafygreen-ui-7razhx">}</td></tr></tbody></table></code></pre> </div> </div> </div> <p class="leafygreen-ui-1kp3ins"> The variable is set to the value returned by the expression, and cannot be changed afterwards. </p> <p class="leafygreen-ui-1kp3ins"> To access the value of a variable in the command, use the double dollar sign prefix ( <code class="leafygreen-ui-1l06pbn"> $$ </code> ) together with your variable name in the form <code class="leafygreen-ui-1l06pbn"> $$&lt;variable_name&gt; </code> . For example: <code class="leafygreen-ui-1l06pbn"> $$targetTotal </code> . </p> <p class="leafygreen-ui-1kp3ins"> To use a variable to filter results, you must access the variable within the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/query/expr/#mongodb-query-op.-expr"> <code class="leafygreen-ui-1l06pbn"> $expr </code> </a> operator. </p> <p class="leafygreen-ui-1kp3ins"> For a complete example using <code class="leafygreen-ui-1l06pbn"> let </code> and variables, see <a class="leafygreen-ui-tqgtui" href="/docs/manual/tutorial/update-documents-with-aggregation-pipeline/#std-label-updateMany-let-example"> Update with let Variables <!-- --> . </a> </p> </div> </div> </td> </tr> <tr class=""> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> sort </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Document </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <span class="leafygreen-ui-1qnjd6d" id="std-label-updateOne-document-syntax"> </span> <p class="leafygreen-ui-1kp3ins"> Optional. </p> <p class="leafygreen-ui-1kp3ins"> Determines which document the operation updates if the query selects multiple documents. <code class="leafygreen-ui-1l06pbn"> updateOne </code> updates the first document in the sort order specified by this argument. </p> <p class="leafygreen-ui-1kp3ins"> If the sort argument is not a document, the operation errors. </p> <p class="leafygreen-ui-1kp3ins"> MongoDB does not store documents in a collection in a particular order. When sorting on a field which contains duplicate values, documents containing those values may be returned in any order. </p> <p class="leafygreen-ui-1kp3ins"> If consistent sort order is desired, include at least one field in your sort that contains unique values. The easiest way to guarantee this is to include the <code class="leafygreen-ui-1l06pbn"> _id </code> field in your sort query. </p> <p class="leafygreen-ui-1kp3ins"> See <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/cursor.sort/#std-label-sort-cursor-consistent-sorting"> Sort Consistency </a> for more information. </p> <div> <p> <em> New <!-- --> in version <!-- --> 8.0 </em> . </p> </div> </div> </div> </td> </tr> </tbody> </table> </div> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Returns <a class="headerlink leafygreen-ui-1kepx47" href="#returns" 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="returns"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> The method returns a document that contains: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <code class="leafygreen-ui-1l06pbn"> matchedCount </code> containing the number of matched documents </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <code class="leafygreen-ui-1l06pbn"> modifiedCount </code> containing the number of modified documents </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <code class="leafygreen-ui-1l06pbn"> upsertedId </code> containing the <code class="leafygreen-ui-1l06pbn"> _id </code> for the upserted document </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <code class="leafygreen-ui-1l06pbn"> upsertedCount </code> containing the number of upserted documents </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> A boolean <code class="leafygreen-ui-1l06pbn"> acknowledged </code> as <code class="leafygreen-ui-1l06pbn"> true </code> if the operation ran with <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-write-concern"> write concern </a> or <code class="leafygreen-ui-1l06pbn"> false </code> if write concern was disabled </p> </li> </ul> </section> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Access Control <a class="headerlink leafygreen-ui-1kepx47" href="#access-control" 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="access-control"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> On deployments running with <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/configuration-options/#mongodb-setting-security.authorization"> <code class="leafygreen-ui-1l06pbn"> authorization </code> </a> , the user must have access that includes the following privileges: </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/privilege-actions/#mongodb-authaction-update"> <code class="leafygreen-ui-1l06pbn"> update </code> </a> action on the specified collection(s). </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/privilege-actions/#mongodb-authaction-find"> <code class="leafygreen-ui-1l06pbn"> find </code> </a> action on the specified collection(s). </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/privilege-actions/#mongodb-authaction-insert"> <code class="leafygreen-ui-1l06pbn"> insert </code> </a> action on the specified collection(s) if the operation results in an upsert. </p> </li> </ul> <p class="leafygreen-ui-1kp3ins"> The built-in role <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/built-in-roles/#mongodb-authrole-readWrite"> <code class="leafygreen-ui-1l06pbn"> readWrite </code> </a> provides the required privileges. </p> <span class="leafygreen-ui-1qnjd6d" id="std-label-updateOne-behavior"> </span> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Behavior <a class="headerlink leafygreen-ui-1kepx47" href="#behavior" 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="behavior"> </div> </a> </h2> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Updates a Single Document <a class="headerlink leafygreen-ui-1kepx47" href="#updates-a-single-document" 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="updates-a-single-document"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-method-db.collection.updateOne" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> db.collection.updateOne() </code> </span> </a> finds the first document that matches the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-update-one-filter" target="_self"> <span> filter </span> </a> and applies the specified <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-update-one-update" target="_self"> <span> update </span> </a> modifications. </p> <span class="leafygreen-ui-1qnjd6d" id="std-label-updateOne-behavior-update-expressions"> </span> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Update with an Update Operator Expressions Document <a class="headerlink leafygreen-ui-1kepx47" href="#update-with-an-update-operator-expressions-document" 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="update-with-an-update-operator-expressions-document"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> For the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-update-one-update" target="_self"> <span> update specifications </span> </a> , the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-method-db.collection.updateOne" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> db.collection.updateOne() </code> </span> </a> method can accept a document that only contains <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/update/#std-label-update-operators"> update operator </a> expressions. </p> <p class="leafygreen-ui-1kp3ins"> For example: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.collection.updateOne(\n &lt;query&gt;,\n { $set: { status: \"D\" }, $inc: { quantity: 2 } },\n ...\n)","programmingLanguage":"JavaScript"} </script> <div class="css-1lju8ps"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1jheeh3"> <pre class="leafygreen-ui-1453az5" 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">updateOne</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> &lt;<!-- -->query<!-- -->&gt;<!-- -->,</td></tr><tr class="leafygreen-ui-1wr1lm6"><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">$set</span>: <!-- -->{ <span class="lg-highlight-attr">status</span>: <span class="lg-highlight-string">"D"</span> }<!-- -->, <span class="lg-highlight-attr">$inc</span>: <!-- -->{ <span class="lg-highlight-attr">quantity</span>: <span class="lg-highlight-number">2</span> } }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->...</td></tr><tr class=""><td class="leafygreen-ui-7razhx">)</td></tr></tbody></table></code></pre> </div> </div> </div> <span class="leafygreen-ui-1qnjd6d" id="std-label-updateOne-behavior-aggregation-pipeline"> </span> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Update with an Aggregation Pipeline <a class="headerlink leafygreen-ui-1kepx47" href="#update-with-an-aggregation-pipeline" 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="update-with-an-aggregation-pipeline"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> The <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-method-db.collection.updateOne" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> db.collection.updateOne() </code> </span> </a> method can accept an <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/aggregation-pipeline/#std-label-aggregation-pipeline"> aggregation pipeline </a> <code class="leafygreen-ui-1l06pbn"> [ &lt;stage1&gt;, &lt;stage2&gt;, ... ] </code> that specifies the modifications to perform. 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> <p class="leafygreen-ui-1kp3ins"> Using the aggregation pipeline allows for a more expressive update statement, such as expressing conditional updates based on current field values or updating one field using the value of another field(s). </p> <p class="leafygreen-ui-1kp3ins"> For example: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.collection.updateOne(\n &lt;query&gt;,\n [\n { $set: { status: \"Modified\", comments: [ \"$misc1\", \"$misc2\" ] } },\n { $unset: [ \"misc1\", \"misc2\" ] }\n ]\n ...\n)","programmingLanguage":"JavaScript"} </script> <div class="css-1lju8ps"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-tyg50d"> <pre class="leafygreen-ui-1453az5" tabindex="0"><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">updateOne</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> &lt;<!-- -->query<!-- -->&gt;<!-- -->,</td></tr><tr class="leafygreen-ui-1wr1lm6"><td class="leafygreen-ui-7razhx"> <!-- -->[</td></tr><tr class="leafygreen-ui-1wr1lm6"><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">$set</span>: <!-- -->{ <span class="lg-highlight-attr">status</span>: <span class="lg-highlight-string">"Modified"</span>, <span class="lg-highlight-attr">comments</span>: <!-- -->[ <span class="lg-highlight-string">"$misc1"</span>, <span class="lg-highlight-string">"$misc2"</span> ] } }<!-- -->,</td></tr><tr class="leafygreen-ui-1wr1lm6"><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">$unset</span>: <!-- -->[ <span class="lg-highlight-string">"misc1"</span>, <span class="lg-highlight-string">"misc2"</span> ] }</td></tr><tr class="leafygreen-ui-1wr1lm6"><td class="leafygreen-ui-7razhx"> ]</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->...</td></tr><tr class=""><td class="leafygreen-ui-7razhx">)</td></tr></tbody></table></code></pre> </div> </div> </div> <div class="leafygreen-ui-15mdk4" role="note"> <h2 class="leafygreen-ui-6n7b7d"> Note </h2> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> The <code class="leafygreen-ui-1l06pbn"> $set </code> and <code class="leafygreen-ui-1l06pbn"> $unset </code> used in the pipeline refers to the aggregation stages <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/set/#mongodb-pipeline-pipe.-set"> <code class="leafygreen-ui-1l06pbn"> $set </code> </a> and <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/unset/#mongodb-pipeline-pipe.-unset"> <code class="leafygreen-ui-1l06pbn"> $unset </code> </a> respectively, and not the update operators <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/update/set/#mongodb-update-up.-set"> <code class="leafygreen-ui-1l06pbn"> $set </code> </a> and <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/update/unset/#mongodb-update-up.-unset"> <code class="leafygreen-ui-1l06pbn"> $unset </code> . </a> </p> </div> </div> <p class="leafygreen-ui-1kp3ins"> For examples, see <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-updateOne-example-agg" target="_self"> <span> Update with Aggregation Pipeline <!-- --> . </span> </a> </p> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Upsert <a class="headerlink leafygreen-ui-1kepx47" href="#upsert" 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="upsert"> </div> </a> </h3> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Starting in MongoDB 7.1, if you specify <code class="leafygreen-ui-1l06pbn"> upsert: true </code> on a sharded collection, you <strong> do not </strong> need to include the full shard key in the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-update-one-filter" target="_self"> <span> filter <!-- --> . </span> </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> If <code class="leafygreen-ui-1l06pbn"> upsert: true </code> and no documents match the <code class="leafygreen-ui-1l06pbn"> filter </code> , <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-method-db.collection.updateOne" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> db.collection.updateOne() </code> </span> </a> creates a new document based on the <code class="leafygreen-ui-1l06pbn"> filter </code> criteria and <code class="leafygreen-ui-1l06pbn"> update </code> modifications. See <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-updateOne-example-update-with-upsert" target="_self"> <span> Update with Upsert <!-- --> . </span> </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> For additional <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-method-db.collection.updateOne" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> db.collection.updateOne() </code> </span> </a> behavior on a sharded collection, see <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-updateOne-sharded-collection" target="_self"> <span> Sharded Collections <!-- --> . </span> </a> </p> </li> </ul> <span class="leafygreen-ui-1qnjd6d" id="std-label-updateOne-capped-collection"> </span> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Capped Collection <a class="headerlink leafygreen-ui-1kepx47" href="#capped-collection" 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="capped-collection"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> If an update operation changes the document size, the operation will fail. </p> <span class="leafygreen-ui-1qnjd6d" id="std-label-updateOne-sharded-collection"> </span> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Sharded Collections <a class="headerlink leafygreen-ui-1kepx47" href="#sharded-collections" 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="sharded-collections"> </div> </a> </h3> <span class="leafygreen-ui-1qnjd6d" id="std-label-updateOne-sharded-upsert"> </span> <section> <h4 class="contains-headerlink leafygreen-ui-1vzlt5f"> <code class="leafygreen-ui-1l06pbn"> upsert </code> on a Sharded Collection <a class="headerlink leafygreen-ui-1kepx47" href="#upsert-on-a-sharded-collection" 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="upsert-on-a-sharded-collection"> </div> </a> </h4> <p class="leafygreen-ui-1kp3ins"> To use <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-method-db.collection.updateOne" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> db.collection.updateOne() </code> </span> </a> on a sharded collection: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Starting in MongoDB 7.1, if you specify <code class="leafygreen-ui-1l06pbn"> upsert: true </code> on a sharded collection, you <strong> do not </strong> need to include the full shard key in the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-update-one-filter" target="_self"> <span> filter <!-- --> . </span> </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> If you don't specify <code class="leafygreen-ui-1l06pbn"> upsert: true </code> , you must include an exact match on the <code class="leafygreen-ui-1l06pbn"> _id </code> field or target a single shard (such as by including the shard key in the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-update-one-filter" target="_self"> <span> filter </span> </a> ). </p> </li> </ul> <p class="leafygreen-ui-1kp3ins"> However, documents in a sharded collection can be <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/sharding-shard-key/#std-label-shard-key-missing"> missing the shard key fields </a> . To target a document that is missing the shard key, you can use the <code class="leafygreen-ui-1l06pbn"> null </code> equality match <strong class="css-4dei7l"> in conjunction with </strong> another filter condition (such as on the <code class="leafygreen-ui-1l06pbn"> _id </code> field). For example: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ _id: &lt;value&gt;, &lt;shardkeyfield&gt;: null } // _id of the document missing shard key","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-1q4bxgx" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-attr">_id</span>: &lt;<!-- -->value<!-- -->&gt;<!-- -->,<!-- --> <!-- -->&lt;<!-- -->shardkeyfield<!-- -->&gt;<!-- -->: <span class="lg-highlight-literal">null</span> } <span class="lg-highlight-comment">// _id of</span><span class="lg-highlight-comment"> the document missing </span><span class="lg-highlight-comment">shard key</span></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> <span class="leafygreen-ui-1qnjd6d" id="std-label-updateOne-shard-key-modification"> </span> </section> <section> <h4 class="contains-headerlink leafygreen-ui-1vzlt5f"> Shard Key Modification <a class="headerlink leafygreen-ui-1kepx47" href="#shard-key-modification" 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="shard-key-modification"> </div> </a> </h4> <p class="leafygreen-ui-1kp3ins"> You can update a document's shard key value unless the shard key field is the immutable <code class="leafygreen-ui-1l06pbn"> _id </code> field. </p> <div class="leafygreen-ui-1sjx7ru" role="note"> <h2 class="leafygreen-ui-29m78u"> Warning </h2> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> Documents in sharded collections can be missing the shard key fields. Take precaution to avoid accidentally removing the shard key when changing a document's shard key value. </p> </div> </div> <p class="leafygreen-ui-1kp3ins"> To modify the <strong> existing </strong> shard key value with <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-method-db.collection.updateOne" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> db.collection.updateOne() </code> : </span> </a> </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> You <strong class="css-4dei7l"> must </strong> run on a <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongos/#mongodb-binary-bin.mongos"> <code class="leafygreen-ui-1l06pbn"> mongos </code> </a> . Do <strong class="css-4dei7l"> not </strong> issue the operation directly on the shard. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> You <strong class="css-4dei7l"> must </strong> run either in a <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/transactions/"> transaction </a> or as a <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/retryable-writes/"> retryable write <!-- --> . </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> You <strong class="css-4dei7l"> must </strong> include an equality <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-update-one-filter" target="_self"> <span> filter </span> </a> on the full shard key. </p> </li> </ul> <p class="leafygreen-ui-1kp3ins"> See also <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-updateOne-sharded-upsert" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> upsert </code> on a Sharded Collection <!-- --> . </span> </a> </p> <span class="leafygreen-ui-1qnjd6d" id="std-label-updateOne-missing-shard-key"> </span> </section> <section> <h4 class="contains-headerlink leafygreen-ui-1vzlt5f"> Missing Shard Key <a class="headerlink leafygreen-ui-1kepx47" href="#missing-shard-key" 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="missing-shard-key"> </div> </a> </h4> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Starting in version 7.1, you do not need to provide the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-shard-key"> shard key </a> or <code class="leafygreen-ui-1l06pbn"> _id </code> field in the query specification. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Documents in a sharded collection can be <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/sharding-shard-key/#std-label-shard-key-missing"> missing the shard key fields </a> . To use <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-method-db.collection.updateOne" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> db.collection.updateOne() </code> </span> </a> to set a <strong> missing </strong> shard key, you <strong class="css-4dei7l"> must </strong> run on a <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongos/#mongodb-binary-bin.mongos"> <code class="leafygreen-ui-1l06pbn"> mongos </code> </a> . Do <strong class="css-4dei7l"> not </strong> issue the operation directly on the shard. </p> <p class="leafygreen-ui-1kp3ins"> In addition, the following requirements also apply: </p> <div class="leafygreen-ui-skkc39" tabindex="0"> <table class="leafygreen-ui-hr8lsv"> <colgroup> <col style="width:30%"/> <col style="width:70%"/> </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> Task </div> </div> </th> <th class="leafygreen-ui-13uteka" role="columnheader" scope="col"> <div class="leafygreen-ui-ui0te9"> <div> Requirements </div> </div> </th> </tr> </thead> <tbody> <tr class=""> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> To set to <code class="leafygreen-ui-1l06pbn"> null </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Requires equality filter on the full shard key if <code class="leafygreen-ui-1l06pbn"> upsert: true </code> . </div> </div> </td> </tr> <tr class=""> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> To set to a non- <code class="leafygreen-ui-1l06pbn"> null </code> value </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <p class="leafygreen-ui-1kp3ins"> <strong class="css-4dei7l"> Must </strong> be performed either inside a <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/transactions/#std-label-transactions"> transaction </a> or as a <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/retryable-writes/#std-label-retryable-writes"> retryable write <!-- --> . </a> </p> <p class="leafygreen-ui-1kp3ins"> Requires equality filter on the full shard key if <code class="leafygreen-ui-1l06pbn"> upsert: true </code> . </p> </div> </div> </td> </tr> </tbody> </table> </div> <div class="leafygreen-ui-13vw3ie" role="note"> <h2 class="leafygreen-ui-1fn4p2b"> Tip </h2> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> Since a missing key value is returned as part of a null equality match, to avoid updating a null-valued key, include additional query conditions (such as on the <code class="leafygreen-ui-1l06pbn"> _id </code> field) as appropriate. </p> </div> </div> </li> </ul> <p class="leafygreen-ui-1kp3ins"> See also: </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="#std-label-updateOne-sharded-upsert" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> upsert </code> on a Sharded Collection </span> </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/sharding-shard-key/#std-label-shard-key-missing"> Missing Shard Key Fields </a> </p> </li> </ul> </section> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Explainability <a class="headerlink leafygreen-ui-1kepx47" href="#explainability" 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="explainability"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-method-db.collection.updateOne" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> updateOne() </code> </span> </a> is not compatible with <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/db.collection.explain/#mongodb-method-db.collection.explain"> <code class="leafygreen-ui-1l06pbn"> db.collection.explain() </code> . </a> </p> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Transactions <a class="headerlink leafygreen-ui-1kepx47" href="#transactions" 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="transactions"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-method-db.collection.updateOne" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> db.collection.updateOne() </code> </span> </a> can be used inside <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/transactions/#std-label-transactions"> distributed transactions <!-- --> . </a> </p> <div class="leafygreen-ui-85da11" role="note"> <h2 class="leafygreen-ui-1ac4g5h"> Important </h2> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> In most cases, a distributed transaction incurs a greater performance cost over single document writes, and the availability of distributed transactions should not be a replacement for effective schema design. For many scenarios, the <a class="leafygreen-ui-tqgtui" href="/docs/manual/data-modeling/concepts/embedding-vs-references/#std-label-data-modeling-embedding"> denormalized data model (embedded documents and arrays) </a> will continue to be optimal for your data and use cases. That is, for many scenarios, modeling your data appropriately will minimize the need for distributed transactions. </p> <p class="leafygreen-ui-1kp3ins"> For additional transactions usage considerations (such as runtime limit and oplog size limit), see also <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/transactions-production-consideration/#std-label-production-considerations"> Production Considerations <!-- --> . </a> </p> </div> </div> <section> <h4 class="contains-headerlink leafygreen-ui-1vzlt5f"> Upsert within Transactions <a class="headerlink leafygreen-ui-1kepx47" href="#upsert-within-transactions" 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="upsert-within-transactions"> </div> </a> </h4> <p class="leafygreen-ui-1kp3ins"> You can create collections and indexes inside a <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/transactions/#std-label-transactions-create-collections-indexes"> distributed transaction </a> if the transaction is <strong class="css-4dei7l"> not </strong> a cross-shard write transaction. </p> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-method-db.collection.updateOne" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> db.collection.updateOne() </code> </span> </a> with <code class="leafygreen-ui-1l06pbn"> upsert: true </code> can be run on an existing collection or a non-existing collection. If run on a non-existing collection, the operation creates the collection. </p> <div class="leafygreen-ui-13vw3ie" role="note"> <h2 class="leafygreen-ui-1fn4p2b"> Tip </h2> <h3 class="leafygreen-ui-144d5kf"> <strong> See also: </strong> </h3> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/transactions/#std-label-transactions-create-collections-indexes"> Create Collections and Indexes in a Transaction </a> </p> </div> </div> </section> <section> <h4 class="contains-headerlink leafygreen-ui-1vzlt5f"> Write Concerns and Transactions <a class="headerlink leafygreen-ui-1kepx47" href="#write-concerns-and-transactions" 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="write-concerns-and-transactions"> </div> </a> </h4> <p class="leafygreen-ui-1kp3ins"> Do not explicitly set the write concern for the operation if run in a transaction. To use write concern with transactions, see <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/transactions/#std-label-transactions-write-concern"> Transactions and Write Concern <!-- --> . </a> </p> </section> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Oplog Entries <a class="headerlink leafygreen-ui-1kepx47" href="#oplog-entries" 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="oplog-entries"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> If a <code class="leafygreen-ui-1l06pbn"> db.collection.updateOne() </code> operation successfully updates a document, the operation adds an entry on the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-oplog"> oplog </a> (operations log). If the operation fails or does not find a document to update, the operation does not add an entry on the oplog. </p> <span class="leafygreen-ui-1qnjd6d" id="std-label-updateOne-method-examples"> </span> </section> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Examples <a class="headerlink leafygreen-ui-1kepx47" href="#examples" 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="examples"> </div> </a> </h2> <span class="leafygreen-ui-1qnjd6d" id="std-label-updateOne-example-update"> </span> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Update using Update Operator Expressions <a class="headerlink leafygreen-ui-1kepx47" href="#update-using-update-operator-expressions" 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="update-using-update-operator-expressions"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> The <code class="leafygreen-ui-1l06pbn"> restaurant </code> collection contains the following documents: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ \"_id\" : 1, \"name\" : \"Central Perk Cafe\", \"Borough\" : \"Manhattan\" },\n{ \"_id\" : 2, \"name\" : \"Rock A Feller Bar and Grill\", \"Borough\" : \"Queens\", \"violations\" : 2 },\n{ \"_id\" : 3, \"name\" : \"Empire State Pub\", \"Borough\" : \"Brooklyn\", \"violations\" : 0 }","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">1</span>, <span class="lg-highlight-string">"name"</span> <!-- -->: <span class="lg-highlight-string">"Central Perk Cafe"</span>, <span class="lg-highlight-string">"Borough"</span> <!-- -->: <span class="lg-highlight-string">"Manhattan"</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">2</span>, <span class="lg-highlight-string">"name"</span> <!-- -->: <span class="lg-highlight-string">"Rock A Feller Bar and Grill"</span>, <span class="lg-highlight-string">"Borough"</span> <!-- -->: <span class="lg-highlight-string">"Queens"</span>, <span class="lg-highlight-string">"violations"</span> <!-- -->: <span class="lg-highlight-number">2</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">3</span>, <span class="lg-highlight-string">"name"</span> <!-- -->: <span class="lg-highlight-string">"Empire State Pub"</span>, <span class="lg-highlight-string">"Borough"</span> <!-- -->: <span class="lg-highlight-string">"Brooklyn"</span>, <span class="lg-highlight-string">"violations"</span> <!-- -->: <span class="lg-highlight-number">0</span> }</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 operation updates a single document where <code class="leafygreen-ui-1l06pbn"> name: "Central Perk Cafe" </code> with the <code class="leafygreen-ui-1l06pbn"> violations </code> field: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"try {\n db.restaurant.updateOne(\n { \"name\" : \"Central Perk Cafe\" },\n { $set: { \"violations\" : 3 } }\n );\n} catch (e) {\n print(e);\n}","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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"><span class="lg-highlight-keyword">try</span> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->db.<span class="lg-highlight-property">restaurant</span>.<span class="lg-highlight-title lg-highlight-function">updateOne</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"name"</span> <!-- -->: <span class="lg-highlight-string">"Central Perk Cafe"</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">$set</span>: <!-- -->{ <span class="lg-highlight-string">"violations"</span> <!-- -->: <span class="lg-highlight-number">3</span> } }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> )<!-- -->;</td></tr><tr class=""><td class="leafygreen-ui-7razhx">} <span class="lg-highlight-keyword">catch</span> <!-- -->(<!-- -->e) <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-title lg-highlight-function">print</span>(<!-- -->e)<!-- -->;</td></tr><tr class=""><td class="leafygreen-ui-7razhx">}</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 operation returns: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ \"acknowledged\" : true, \"matchedCount\" : 1, \"modifiedCount\" : 1 }","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-1q4bxgx" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"acknowledged"</span> <!-- -->: <span class="lg-highlight-literal">true</span>, <span class="lg-highlight-string">"matchedCount"</span> <!-- -->: <span class="lg-highlight-number">1</span>, <span class="lg-highlight-string">"modifiedCount"</span> <!-- -->: <span class="lg-highlight-number">1</span> }</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"> If no matches were found, the operation instead returns: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ \"acknowledged\" : true, \"matchedCount\" : 0, \"modifiedCount\" : 0 }","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-1q4bxgx" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"acknowledged"</span> <!-- -->: <span class="lg-highlight-literal">true</span>, <span class="lg-highlight-string">"matchedCount"</span> <!-- -->: <span class="lg-highlight-number">0</span>, <span class="lg-highlight-string">"modifiedCount"</span> <!-- -->: <span class="lg-highlight-number">0</span> }</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"> Setting <code class="leafygreen-ui-1l06pbn"> upsert: true </code> would insert the document if no match was found. See <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-updateOne-example-update-with-upsert" target="_self"> <span> Update with Upsert </span> </a> </p> <span class="leafygreen-ui-1qnjd6d" id="std-label-updateOne-example-agg"> </span> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Update with Aggregation Pipeline <a class="headerlink leafygreen-ui-1kepx47" href="#update-with-aggregation-pipeline" 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="update-with-aggregation-pipeline"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> The <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-method-db.collection.updateOne" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> db.collection.updateOne() </code> </span> </a> can use an aggregation pipeline for the update. 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> <p class="leafygreen-ui-1kp3ins"> Using the aggregation pipeline allows for a more expressive update statement, such as expressing conditional updates based on current field values or updating one field using the value of another field(s). </p> <section> <h4 class="contains-headerlink leafygreen-ui-1vzlt5f"> Example 1 <a class="headerlink leafygreen-ui-1kepx47" href="#example-1" 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="example-1"> </div> </a> </h4> <p class="leafygreen-ui-1kp3ins"> The following examples uses the aggregation pipeline to modify a field using the values of the other fields in the document. </p> <p class="leafygreen-ui-1kp3ins"> Create a <code class="leafygreen-ui-1l06pbn"> students </code> collection with the following documents: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.students.insertMany( [\n { \"_id\" : 1, \"student\" : \"Skye\", \"points\" : 75, \"commentsSemester1\" : \"great at math\", \"commentsSemester2\" : \"loses temper\", \"lastUpdate\" : ISODate(\"2019-01-01T00:00:00Z\") },\n { \"_id\" : 2, \"student\" : \"Elizabeth\", \"points\" : 60, \"commentsSemester1\" : \"well behaved\", \"commentsSemester2\" : \"needs improvement\", \"lastUpdate\" : ISODate(\"2019-01-01T00:00:00Z\") }\n] )","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><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">students</span>.<span class="lg-highlight-title lg-highlight-function">insertMany</span>( <!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">1</span>, <span class="lg-highlight-string">"student"</span> <!-- -->: <span class="lg-highlight-string">"Skye"</span>, <span class="lg-highlight-string">"points"</span> <!-- -->: <span class="lg-highlight-number">75</span>, <span class="lg-highlight-string">"commentsSemester1"</span> <!-- -->: <span class="lg-highlight-string">"great at math"</span>, <span class="lg-highlight-string">"commentsSemester2"</span> <!-- -->: <span class="lg-highlight-string">"loses temper"</span>, <span class="lg-highlight-string">"lastUpdate"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">ISODate</span>(<span class="lg-highlight-string">"2019-01-01T00:00:00Z"</span>) }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">2</span>, <span class="lg-highlight-string">"student"</span> <!-- -->: <span class="lg-highlight-string">"Elizabeth"</span>, <span class="lg-highlight-string">"points"</span> <!-- -->: <span class="lg-highlight-number">60</span>, <span class="lg-highlight-string">"commentsSemester1"</span> <!-- -->: <span class="lg-highlight-string">"well behaved"</span>, <span class="lg-highlight-string">"commentsSemester2"</span> <!-- -->: <span class="lg-highlight-string">"needs improvement"</span>, <span class="lg-highlight-string">"lastUpdate"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">ISODate</span>(<span class="lg-highlight-string">"2019-01-01T00:00:00Z"</span>) }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">] )</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"> Assume that instead of separate <code class="leafygreen-ui-1l06pbn"> commentsSemester1 </code> and <code class="leafygreen-ui-1l06pbn"> commentsSemester2 </code> fields in the first document, you want to gather these into a <code class="leafygreen-ui-1l06pbn"> comments </code> field, like the second document. The following update operation uses an aggregation pipeline to: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> add the new <code class="leafygreen-ui-1l06pbn"> comments </code> field and set the <code class="leafygreen-ui-1l06pbn"> lastUpdate </code> field. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> remove the <code class="leafygreen-ui-1l06pbn"> commentsSemester1 </code> and <code class="leafygreen-ui-1l06pbn"> commentsSemester2 </code> fields for all documents in the collection. </p> </li> </ul> <p class="leafygreen-ui-1kp3ins"> Make sure that the filter in the update command targets a unique document. The field <code class="leafygreen-ui-1l06pbn"> id </code> in the code below is an example of such a filter: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.students.updateOne(\n { _id: 1 },\n [\n { $set: { status: \"Modified\", comments: [ \"$commentsSemester1\", \"$commentsSemester2\" ], lastUpdate: \"$$NOW\" } },\n { $unset: [ \"commentsSemester1\", \"commentsSemester2\" ] }\n ]\n)","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><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">students</span>.<span class="lg-highlight-title lg-highlight-function">updateOne</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">1</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">$set</span>: <!-- -->{ <span class="lg-highlight-attr">status</span>: <span class="lg-highlight-string">"Modified"</span>, <span class="lg-highlight-attr">comments</span>: <!-- -->[ <span class="lg-highlight-string">"$commentsSemester1"</span>, <span class="lg-highlight-string">"$commentsSemester2"</span> ]<!-- -->, <span class="lg-highlight-attr">lastUpdate</span>: <span class="lg-highlight-string">"$$NOW"</span> } }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">$unset</span>: <!-- -->[ <span class="lg-highlight-string">"commentsSemester1"</span>, <span class="lg-highlight-string">"commentsSemester2"</span> ] }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> ]</td></tr><tr class=""><td class="leafygreen-ui-7razhx">)</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-15mdk4" role="note"> <h2 class="leafygreen-ui-6n7b7d"> Note </h2> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> The <code class="leafygreen-ui-1l06pbn"> $set </code> and <code class="leafygreen-ui-1l06pbn"> $unset </code> used in the pipeline refers to the aggregation stages <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/set/#mongodb-pipeline-pipe.-set"> <code class="leafygreen-ui-1l06pbn"> $set </code> </a> and <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/unset/#mongodb-pipeline-pipe.-unset"> <code class="leafygreen-ui-1l06pbn"> $unset </code> </a> respectively, and not the update operators <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/update/set/#mongodb-update-up.-set"> <code class="leafygreen-ui-1l06pbn"> $set </code> </a> and <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/update/unset/#mongodb-update-up.-unset"> <code class="leafygreen-ui-1l06pbn"> $unset </code> . </a> </p> </div> </div> <dl> <dt> First Stage </dt> <dd class="css-1ufxuu7"> <p class="leafygreen-ui-1kp3ins"> The <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/set/#mongodb-pipeline-pipe.-set"> <code class="leafygreen-ui-1l06pbn"> $set </code> </a> stage: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> creates a new array field <code class="leafygreen-ui-1l06pbn"> comments </code> whose elements are the current content of the <code class="leafygreen-ui-1l06pbn"> misc1 </code> and <code class="leafygreen-ui-1l06pbn"> misc2 </code> fields and </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> sets the field <code class="leafygreen-ui-1l06pbn"> lastUpdate </code> to the value of the aggregation variable <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/aggregation-variables/#mongodb-variable-variable.NOW"> <code class="leafygreen-ui-1l06pbn"> NOW </code> </a> . The aggregation variable <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/aggregation-variables/#mongodb-variable-variable.NOW"> <code class="leafygreen-ui-1l06pbn"> NOW </code> </a> resolves to the current datetime value and remains the same throughout the pipeline. To access aggregation variables, prefix the variable with double dollar signs <code class="leafygreen-ui-1l06pbn"> $$ </code> and enclose in quotes. </p> </li> </ul> </dd> <dt> Second Stage </dt> <dd class="css-1ufxuu7"> The <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/unset/#mongodb-pipeline-pipe.-unset"> <code class="leafygreen-ui-1l06pbn"> $unset </code> </a> stage removes the <code class="leafygreen-ui-1l06pbn"> commentsSemester1 </code> and <code class="leafygreen-ui-1l06pbn"> commentsSemester2 </code> fields. </dd> </dl> <p class="leafygreen-ui-1kp3ins"> After the command, the collection contains the following documents: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ \"_id\" : 2, \"student\" : \"Elizabeth\", \"status\" : \"Modified\", \"points\" : 60, \"lastUpdate\" : ISODate(\"2020-01-23T05:11:45.784Z\"), \"comments\" : [ \"well behaved\", \"needs improvement\" ] }\n{ _id: 1, student: 'Skye', points: 75, commentsSemester1: 'great at math', commentsSemester2: 'loses temper', lastUpdate: ISODate(\"2019-01-01T00:00:00.000Z\") }","programmingLanguage":"JavaScript"} </script> <div class="css-1lju8ps"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-tyg50d"> <pre class="leafygreen-ui-1453az5" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">2</span>, <span class="lg-highlight-string">"student"</span> <!-- -->: <span class="lg-highlight-string">"Elizabeth"</span>, <span class="lg-highlight-string">"status"</span> <!-- -->: <span class="lg-highlight-string">"Modified"</span>, <span class="lg-highlight-string">"points"</span> <!-- -->: <span class="lg-highlight-number">60</span>, <span class="lg-highlight-string">"lastUpdate"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">ISODate</span>(<span class="lg-highlight-string">"2020-01-23T05:11:45.784Z"</span>)<!-- -->, <span class="lg-highlight-string">"comments"</span> <!-- -->: <!-- -->[ <span class="lg-highlight-string">"well behaved"</span>, <span class="lg-highlight-string">"needs improvement"</span> ] }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">1</span>, <span class="lg-highlight-attr">student</span>: <span class="lg-highlight-string">'Skye'</span>, <span class="lg-highlight-attr">points</span>: <span class="lg-highlight-number">75</span>, <span class="lg-highlight-attr">commentsSemester1</span>: <span class="lg-highlight-string">'great at math'</span>, <span class="lg-highlight-attr">commentsSemester2</span>: <span class="lg-highlight-string">'loses temper'</span>, <span class="lg-highlight-attr">lastUpdate</span>: <span class="lg-highlight-title lg-highlight-class">ISODate</span>(<span class="lg-highlight-string">"2019-01-01T00:00:00.000Z"</span>) }</td></tr></tbody></table></code></pre> </div> </div> </div> <p class="leafygreen-ui-1kp3ins"> Note that after introducing a sort, only the first document encountered in the sort order is modified and the remaining documents are left untouched. </p> </section> <section> <h4 class="contains-headerlink leafygreen-ui-1vzlt5f"> Example 2 <a class="headerlink leafygreen-ui-1kepx47" href="#example-2" 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="example-2"> </div> </a> </h4> <p class="leafygreen-ui-1kp3ins"> The aggregation pipeline allows the update to perform conditional updates based on the current field values as well as use current field values to calculate a separate field value. </p> <p class="leafygreen-ui-1kp3ins"> For example, create a <code class="leafygreen-ui-1l06pbn"> students3 </code> collection with the following documents: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.students3.insertMany( [\n { \"_id\" : 1, \"tests\" : [ 95, 92, 90 ], \"average\" : 92, \"grade\" : \"A\", \"lastUpdate\" : ISODate(\"2020-01-23T05:18:40.013Z\") },\n { \"_id\" : 2, \"tests\" : [ 94, 88, 90 ], \"average\" : 91, \"grade\" : \"A\", \"lastUpdate\" : ISODate(\"2020-01-23T05:18:40.013Z\") },\n { \"_id\" : 3, \"tests\" : [ 70, 75, 82 ], \"lastUpdate\" : ISODate(\"2019-01-01T00:00:00Z\") }\n] )","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><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">students3</span>.<span class="lg-highlight-title lg-highlight-function">insertMany</span>( <!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">1</span>, <span class="lg-highlight-string">"tests"</span> <!-- -->: <!-- -->[ <span class="lg-highlight-number">95</span>, <span class="lg-highlight-number">92</span>, <span class="lg-highlight-number">90</span> ]<!-- -->, <span class="lg-highlight-string">"average"</span> <!-- -->: <span class="lg-highlight-number">92</span>, <span class="lg-highlight-string">"grade"</span> <!-- -->: <span class="lg-highlight-string">"A"</span>, <span class="lg-highlight-string">"lastUpdate"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">ISODate</span>(<span class="lg-highlight-string">"2020-01-23T05:18:40.013Z"</span>) }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">2</span>, <span class="lg-highlight-string">"tests"</span> <!-- -->: <!-- -->[ <span class="lg-highlight-number">94</span>, <span class="lg-highlight-number">88</span>, <span class="lg-highlight-number">90</span> ]<!-- -->, <span class="lg-highlight-string">"average"</span> <!-- -->: <span class="lg-highlight-number">91</span>, <span class="lg-highlight-string">"grade"</span> <!-- -->: <span class="lg-highlight-string">"A"</span>, <span class="lg-highlight-string">"lastUpdate"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">ISODate</span>(<span class="lg-highlight-string">"2020-01-23T05:18:40.013Z"</span>) }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">3</span>, <span class="lg-highlight-string">"tests"</span> <!-- -->: <!-- -->[ <span class="lg-highlight-number">70</span>, <span class="lg-highlight-number">75</span>, <span class="lg-highlight-number">82</span> ]<!-- -->, <span class="lg-highlight-string">"lastUpdate"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">ISODate</span>(<span class="lg-highlight-string">"2019-01-01T00:00:00Z"</span>) }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">] )</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 third document <code class="leafygreen-ui-1l06pbn"> _id: 3 </code> is missing the <code class="leafygreen-ui-1l06pbn"> average </code> and <code class="leafygreen-ui-1l06pbn"> grade </code> fields. Using an aggregation pipeline, you can update the document with the calculated grade average and letter grade. </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.students3.updateOne(\n { _id: 3 },\n [\n { $set: { average: { $trunc: [ { $avg: \"$tests\" }, 0 ] }, lastUpdate: \"$$NOW\" } },\n { $set: { grade: { $switch: {\n branches: [\n { case: { $gte: [ \"$average\", 90 ] }, then: \"A\" },\n { case: { $gte: [ \"$average\", 80 ] }, then: \"B\" },\n { case: { $gte: [ \"$average\", 70 ] }, then: \"C\" },\n { case: { $gte: [ \"$average\", 60 ] }, then: \"D\" }\n ],\n default: \"F\"\n } } } }\n ]\n)","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><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">students3</span>.<span class="lg-highlight-title lg-highlight-function">updateOne</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">3</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">$set</span>: <!-- -->{ <span class="lg-highlight-attr">average</span>: <!-- -->{ <span class="lg-highlight-attr">$trunc</span>: <!-- -->[ <!-- -->{ <span class="lg-highlight-attr">$avg</span>: <span class="lg-highlight-string">"$tests"</span> }<!-- -->, <span class="lg-highlight-number">0</span> ] }<!-- -->, <span class="lg-highlight-attr">lastUpdate</span>: <span class="lg-highlight-string">"$$NOW"</span> } }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">$set</span>: <!-- -->{ <span class="lg-highlight-attr">grade</span>: <!-- -->{ <span class="lg-highlight-attr">$switch</span>: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">branches</span>: <!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">case</span>: <!-- -->{ <span class="lg-highlight-attr">$gte</span>: <!-- -->[ <span class="lg-highlight-string">"$average"</span>, <span class="lg-highlight-number">90</span> ] }<!-- -->, <span class="lg-highlight-attr">then</span>: <span class="lg-highlight-string">"A"</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">case</span>: <!-- -->{ <span class="lg-highlight-attr">$gte</span>: <!-- -->[ <span class="lg-highlight-string">"$average"</span>, <span class="lg-highlight-number">80</span> ] }<!-- -->, <span class="lg-highlight-attr">then</span>: <span class="lg-highlight-string">"B"</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">case</span>: <!-- -->{ <span class="lg-highlight-attr">$gte</span>: <!-- -->[ <span class="lg-highlight-string">"$average"</span>, <span class="lg-highlight-number">70</span> ] }<!-- -->, <span class="lg-highlight-attr">then</span>: <span class="lg-highlight-string">"C"</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">case</span>: <!-- -->{ <span class="lg-highlight-attr">$gte</span>: <!-- -->[ <span class="lg-highlight-string">"$average"</span>, <span class="lg-highlight-number">60</span> ] }<!-- -->, <span class="lg-highlight-attr">then</span>: <span class="lg-highlight-string">"D"</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> ]<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">default</span>: <span class="lg-highlight-string">"F"</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> } } } }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> ]</td></tr><tr class=""><td class="leafygreen-ui-7razhx">)</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-15mdk4" role="note"> <h2 class="leafygreen-ui-6n7b7d"> Note </h2> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> The <code class="leafygreen-ui-1l06pbn"> $set </code> used in the pipeline refers to the aggregation stage <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/set/#mongodb-pipeline-pipe.-set"> <code class="leafygreen-ui-1l06pbn"> $set </code> </a> , and not the update operators <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/update/set/#mongodb-update-up.-set"> <code class="leafygreen-ui-1l06pbn"> $set </code> . </a> </p> </div> </div> <dl> <dt> First Stage </dt> <dd class="css-1ufxuu7"> <p class="leafygreen-ui-1kp3ins"> The <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/set/#mongodb-pipeline-pipe.-set"> <code class="leafygreen-ui-1l06pbn"> $set </code> </a> stage: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> calculates a new field <code class="leafygreen-ui-1l06pbn"> average </code> based on the average of the <code class="leafygreen-ui-1l06pbn"> tests </code> field. See <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/avg/#mongodb-group-grp.-avg"> <code class="leafygreen-ui-1l06pbn"> $avg </code> </a> for more information on the <code class="leafygreen-ui-1l06pbn"> $avg </code> aggregation operator and <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/trunc/#mongodb-expression-exp.-trunc"> <code class="leafygreen-ui-1l06pbn"> $trunc </code> </a> for more information on the <code class="leafygreen-ui-1l06pbn"> $trunc </code> truncate aggregation operator. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> sets the field <code class="leafygreen-ui-1l06pbn"> lastUpdate </code> to the value of the aggregation variable <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/aggregation-variables/#mongodb-variable-variable.NOW"> <code class="leafygreen-ui-1l06pbn"> NOW </code> </a> . The aggregation variable <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/aggregation-variables/#mongodb-variable-variable.NOW"> <code class="leafygreen-ui-1l06pbn"> NOW </code> </a> resolves to the current datetime value and remains the same throughout the pipeline. To access aggregation variables, prefix the variable with double dollar signs <code class="leafygreen-ui-1l06pbn"> $$ </code> and enclose in quotes. </p> </li> </ul> </dd> <dt> Second Stage </dt> <dd class="css-1ufxuu7"> The <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/set/#mongodb-pipeline-pipe.-set"> <code class="leafygreen-ui-1l06pbn"> $set </code> </a> stage calculates a new field <code class="leafygreen-ui-1l06pbn"> grade </code> based on the <code class="leafygreen-ui-1l06pbn"> average </code> field calculated in the previous stage. See <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/switch/#mongodb-expression-exp.-switch"> <code class="leafygreen-ui-1l06pbn"> $switch </code> </a> for more information on the <code class="leafygreen-ui-1l06pbn"> $switch </code> aggregation operator. </dd> </dl> <p class="leafygreen-ui-1kp3ins"> After the command, the collection contains the following documents: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ \"_id\" : 1, \"tests\" : [ 95, 92, 90 ], \"average\" : 92, \"grade\" : \"A\", \"lastUpdate\" : ISODate(\"2020-01-23T05:18:40.013Z\") }\n{ \"_id\" : 2, \"tests\" : [ 94, 88, 90 ], \"average\" : 91, \"grade\" : \"A\", \"lastUpdate\" : ISODate(\"2020-01-23T05:18:40.013Z\") }\n{ \"_id\" : 3, \"tests\" : [ 70, 75, 82 ], \"lastUpdate\" : ISODate(\"2020-01-24T17:33:30.674Z\"), \"average\" : 75, \"grade\" : \"C\" }","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">1</span>, <span class="lg-highlight-string">"tests"</span> <!-- -->: <!-- -->[ <span class="lg-highlight-number">95</span>, <span class="lg-highlight-number">92</span>, <span class="lg-highlight-number">90</span> ]<!-- -->, <span class="lg-highlight-string">"average"</span> <!-- -->: <span class="lg-highlight-number">92</span>, <span class="lg-highlight-string">"grade"</span> <!-- -->: <span class="lg-highlight-string">"A"</span>, <span class="lg-highlight-string">"lastUpdate"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">ISODate</span>(<span class="lg-highlight-string">"2020-01-23T05:18:40.013Z"</span>) }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">2</span>, <span class="lg-highlight-string">"tests"</span> <!-- -->: <!-- -->[ <span class="lg-highlight-number">94</span>, <span class="lg-highlight-number">88</span>, <span class="lg-highlight-number">90</span> ]<!-- -->, <span class="lg-highlight-string">"average"</span> <!-- -->: <span class="lg-highlight-number">91</span>, <span class="lg-highlight-string">"grade"</span> <!-- -->: <span class="lg-highlight-string">"A"</span>, <span class="lg-highlight-string">"lastUpdate"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">ISODate</span>(<span class="lg-highlight-string">"2020-01-23T05:18:40.013Z"</span>) }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">3</span>, <span class="lg-highlight-string">"tests"</span> <!-- -->: <!-- -->[ <span class="lg-highlight-number">70</span>, <span class="lg-highlight-number">75</span>, <span class="lg-highlight-number">82</span> ]<!-- -->, <span class="lg-highlight-string">"lastUpdate"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">ISODate</span>(<span class="lg-highlight-string">"2020-01-24T17:33:30.674Z"</span>)<!-- -->, <span class="lg-highlight-string">"average"</span> <!-- -->: <span class="lg-highlight-number">75</span>, <span class="lg-highlight-string">"grade"</span> <!-- -->: <span class="lg-highlight-string">"C"</span> }</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-13vw3ie" role="note"> <h2 class="leafygreen-ui-1fn4p2b"> Tip </h2> <h3 class="leafygreen-ui-144d5kf"> <strong> See also: </strong> </h3> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/tutorial/update-documents-with-aggregation-pipeline/"> Updates with Aggregation Pipeline </a> </p> </div> </div> <span class="leafygreen-ui-1qnjd6d" id="std-label-updateOne-example-update-with-upsert"> </span> </section> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Update with Upsert <a class="headerlink leafygreen-ui-1kepx47" href="#update-with-upsert" 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="update-with-upsert"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> The <code class="leafygreen-ui-1l06pbn"> restaurant </code> collection contains the following documents: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ \"_id\" : 1, \"name\" : \"Central Perk Cafe\", \"Borough\" : \"Manhattan\", \"violations\" : 3 },\n{ \"_id\" : 2, \"name\" : \"Rock A Feller Bar and Grill\", \"Borough\" : \"Queens\", \"violations\" : 2 },\n{ \"_id\" : 3, \"name\" : \"Empire State Pub\", \"Borough\" : \"Brooklyn\", \"violations\" : \"0\" }","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">1</span>, <span class="lg-highlight-string">"name"</span> <!-- -->: <span class="lg-highlight-string">"Central Perk Cafe"</span>, <span class="lg-highlight-string">"Borough"</span> <!-- -->: <span class="lg-highlight-string">"Manhattan"</span>, <span class="lg-highlight-string">"violations"</span> <!-- -->: <span class="lg-highlight-number">3</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">2</span>, <span class="lg-highlight-string">"name"</span> <!-- -->: <span class="lg-highlight-string">"Rock A Feller Bar and Grill"</span>, <span class="lg-highlight-string">"Borough"</span> <!-- -->: <span class="lg-highlight-string">"Queens"</span>, <span class="lg-highlight-string">"violations"</span> <!-- -->: <span class="lg-highlight-number">2</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">3</span>, <span class="lg-highlight-string">"name"</span> <!-- -->: <span class="lg-highlight-string">"Empire State Pub"</span>, <span class="lg-highlight-string">"Borough"</span> <!-- -->: <span class="lg-highlight-string">"Brooklyn"</span>, <span class="lg-highlight-string">"violations"</span> <!-- -->: <span class="lg-highlight-string">"0"</span> }</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 operation attempts to update the document with <code class="leafygreen-ui-1l06pbn"> name : "Pizza Rat's Pizzaria" </code> , while <code class="leafygreen-ui-1l06pbn"> upsert: true </code> : </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"try {\n db.restaurant.updateOne(\n { \"name\" : \"Pizza Rat's Pizzaria\" },\n { $set: {\"_id\" : 4, \"violations\" : 7, \"borough\" : \"Manhattan\" } },\n { upsert: true }\n );\n} catch (e) {\n print(e);\n}","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-keyword">try</span> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->db.<span class="lg-highlight-property">restaurant</span>.<span class="lg-highlight-title lg-highlight-function">updateOne</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"name"</span> <!-- -->: <span class="lg-highlight-string">"Pizza Rat's Pizzaria"</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">$set</span>: <!-- -->{<span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">4</span>, <span class="lg-highlight-string">"violations"</span> <!-- -->: <span class="lg-highlight-number">7</span>, <span class="lg-highlight-string">"borough"</span> <!-- -->: <span class="lg-highlight-string">"Manhattan"</span> } }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">upsert</span>: <span class="lg-highlight-literal">true</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> )<!-- -->;</td></tr><tr class=""><td class="leafygreen-ui-7razhx">} <span class="lg-highlight-keyword">catch</span> <!-- -->(<!-- -->e) <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-title lg-highlight-function">print</span>(<!-- -->e)<!-- -->;</td></tr><tr class=""><td class="leafygreen-ui-7razhx">}</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"> Since <code class="leafygreen-ui-1l06pbn"> upsert:true </code> the document is <code class="leafygreen-ui-1l06pbn"> inserted </code> based on the <code class="leafygreen-ui-1l06pbn"> filter </code> and <code class="leafygreen-ui-1l06pbn"> update </code> criteria. The operation returns: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{\n \"acknowledged\" : true,\n \"matchedCount\" : 0,\n \"modifiedCount\" : 0,\n \"upsertedId\" : 4,\n \"upsertedCount\": 1\n}","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"acknowledged"</span> <!-- -->: <span class="lg-highlight-literal">true</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"matchedCount"</span> <!-- -->: <span class="lg-highlight-number">0</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"modifiedCount"</span> <!-- -->: <span class="lg-highlight-number">0</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"upsertedId"</span> <!-- -->: <span class="lg-highlight-number">4</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"upsertedCount"</span>: <span class="lg-highlight-number">1</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx">}</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 collection now contains the following documents: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ \"_id\" : 1, \"name\" : \"Central Perk Cafe\", \"Borough\" : \"Manhattan\", \"violations\" : 3 },\n{ \"_id\" : 2, \"name\" : \"Rock A Feller Bar and Grill\", \"Borough\" : \"Queens\", \"violations\" : 2 },\n{ \"_id\" : 3, \"name\" : \"Empire State Pub\", \"Borough\" : \"Brooklyn\", \"violations\" : 4 },\n{ \"_id\" : 4, \"name\" : \"Pizza Rat's Pizzaria\", \"Borough\" : \"Manhattan\", \"violations\" : 7 }","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">1</span>, <span class="lg-highlight-string">"name"</span> <!-- -->: <span class="lg-highlight-string">"Central Perk Cafe"</span>, <span class="lg-highlight-string">"Borough"</span> <!-- -->: <span class="lg-highlight-string">"Manhattan"</span>, <span class="lg-highlight-string">"violations"</span> <!-- -->: <span class="lg-highlight-number">3</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">2</span>, <span class="lg-highlight-string">"name"</span> <!-- -->: <span class="lg-highlight-string">"Rock A Feller Bar and Grill"</span>, <span class="lg-highlight-string">"Borough"</span> <!-- -->: <span class="lg-highlight-string">"Queens"</span>, <span class="lg-highlight-string">"violations"</span> <!-- -->: <span class="lg-highlight-number">2</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">3</span>, <span class="lg-highlight-string">"name"</span> <!-- -->: <span class="lg-highlight-string">"Empire State Pub"</span>, <span class="lg-highlight-string">"Borough"</span> <!-- -->: <span class="lg-highlight-string">"Brooklyn"</span>, <span class="lg-highlight-string">"violations"</span> <!-- -->: <span class="lg-highlight-number">4</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">4</span>, <span class="lg-highlight-string">"name"</span> <!-- -->: <span class="lg-highlight-string">"Pizza Rat's Pizzaria"</span>, <span class="lg-highlight-string">"Borough"</span> <!-- -->: <span class="lg-highlight-string">"Manhattan"</span>, <span class="lg-highlight-string">"violations"</span> <!-- -->: <span class="lg-highlight-number">7</span> }</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 <code class="leafygreen-ui-1l06pbn"> name </code> field was filled in using the <code class="leafygreen-ui-1l06pbn"> filter </code> criteria, while the <code class="leafygreen-ui-1l06pbn"> update </code> operators were used to create the rest of the document. </p> <p class="leafygreen-ui-1kp3ins"> The following operation updates the first document with <code class="leafygreen-ui-1l06pbn"> violations </code> that are greater than <code class="leafygreen-ui-1l06pbn"> 10 </code> : </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"try {\n db.restaurant.updateOne(\n { \"violations\" : { $gt: 10} },\n { $set: { \"Closed\" : true } },\n { upsert: true }\n );\n} catch (e) {\n print(e);\n}","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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"><span class="lg-highlight-keyword">try</span> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->db.<span class="lg-highlight-property">restaurant</span>.<span class="lg-highlight-title lg-highlight-function">updateOne</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"violations"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-attr">$gt</span>: <span class="lg-highlight-number">10</span>} }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">$set</span>: <!-- -->{ <span class="lg-highlight-string">"Closed"</span> <!-- -->: <span class="lg-highlight-literal">true</span> } }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">upsert</span>: <span class="lg-highlight-literal">true</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> )<!-- -->;</td></tr><tr class=""><td class="leafygreen-ui-7razhx">} <span class="lg-highlight-keyword">catch</span> <!-- -->(<!-- -->e) <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-title lg-highlight-function">print</span>(<!-- -->e)<!-- -->;</td></tr><tr class=""><td class="leafygreen-ui-7razhx">}</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 operation returns: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{\n \"acknowledged\" : true,\n \"matchedCount\" : 0,\n \"modifiedCount\" : 0,\n \"upsertedId\" : ObjectId(\"56310c3c0c5cbb6031cafaea\")\n}","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"acknowledged"</span> <!-- -->: <span class="lg-highlight-literal">true</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"matchedCount"</span> <!-- -->: <span class="lg-highlight-number">0</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"modifiedCount"</span> <!-- -->: <span class="lg-highlight-number">0</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"upsertedId"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">ObjectId</span>(<span class="lg-highlight-string">"56310c3c0c5cbb6031cafaea"</span>)</td></tr><tr class=""><td class="leafygreen-ui-7razhx">}</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 collection now contains the following documents: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ \"_id\" : 1, \"name\" : \"Central Perk Cafe\", \"Borough\" : \"Manhattan\", \"violations\" : 3 },\n{ \"_id\" : 2, \"name\" : \"Rock A Feller Bar and Grill\", \"Borough\" : \"Queens\", \"violations\" : 2 },\n{ \"_id\" : 3, \"name\" : \"Empire State Pub\", \"Borough\" : \"Brooklyn\", \"violations\" : 4 },\n{ \"_id\" : 4, \"name\" : \"Pizza Rat's Pizzaria\", \"Borough\" : \"Manhattan\", \"grade\" : 7 }\n{ \"_id\" : ObjectId(\"56310c3c0c5cbb6031cafaea\"), \"Closed\" : true }","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">1</span>, <span class="lg-highlight-string">"name"</span> <!-- -->: <span class="lg-highlight-string">"Central Perk Cafe"</span>, <span class="lg-highlight-string">"Borough"</span> <!-- -->: <span class="lg-highlight-string">"Manhattan"</span>, <span class="lg-highlight-string">"violations"</span> <!-- -->: <span class="lg-highlight-number">3</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">2</span>, <span class="lg-highlight-string">"name"</span> <!-- -->: <span class="lg-highlight-string">"Rock A Feller Bar and Grill"</span>, <span class="lg-highlight-string">"Borough"</span> <!-- -->: <span class="lg-highlight-string">"Queens"</span>, <span class="lg-highlight-string">"violations"</span> <!-- -->: <span class="lg-highlight-number">2</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">3</span>, <span class="lg-highlight-string">"name"</span> <!-- -->: <span class="lg-highlight-string">"Empire State Pub"</span>, <span class="lg-highlight-string">"Borough"</span> <!-- -->: <span class="lg-highlight-string">"Brooklyn"</span>, <span class="lg-highlight-string">"violations"</span> <!-- -->: <span class="lg-highlight-number">4</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">4</span>, <span class="lg-highlight-string">"name"</span> <!-- -->: <span class="lg-highlight-string">"Pizza Rat's Pizzaria"</span>, <span class="lg-highlight-string">"Borough"</span> <!-- -->: <span class="lg-highlight-string">"Manhattan"</span>, <span class="lg-highlight-string">"grade"</span> <!-- -->: <span class="lg-highlight-number">7</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">ObjectId</span>(<span class="lg-highlight-string">"56310c3c0c5cbb6031cafaea"</span>)<!-- -->, <span class="lg-highlight-string">"Closed"</span> <!-- -->: <span class="lg-highlight-literal">true</span> }</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"> Since no documents matched the filter, and <code class="leafygreen-ui-1l06pbn"> upsert </code> was <code class="leafygreen-ui-1l06pbn"> true </code> , <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-method-db.collection.updateOne" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> updateOne() </code> </span> </a> inserted the document with a generated <code class="leafygreen-ui-1l06pbn"> _id </code> and the <code class="leafygreen-ui-1l06pbn"> update </code> criteria only. </p> <span class="leafygreen-ui-1qnjd6d" id="std-label-updateOne-example-update-with-write-concern"> </span> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Update with Write Concern <a class="headerlink leafygreen-ui-1kepx47" href="#update-with-write-concern" 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="update-with-write-concern"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> Given a three member replica set, the following operation specifies a <code class="leafygreen-ui-1l06pbn"> w </code> of <code class="leafygreen-ui-1l06pbn"> majority </code> , <code class="leafygreen-ui-1l06pbn"> wtimeout </code> of <code class="leafygreen-ui-1l06pbn"> 100 </code> : </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"try {\n db.restaurant.updateOne(\n { \"name\" : \"Pizza Rat's Pizzaria\" },\n { $inc: { \"violations\" : 3}, $set: { \"Closed\" : true } },\n { w: \"majority\", wtimeout: 100 }\n );\n} catch (e) {\n print(e);\n}","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-keyword">try</span> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->db.<span class="lg-highlight-property">restaurant</span>.<span class="lg-highlight-title lg-highlight-function">updateOne</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"name"</span> <!-- -->: <span class="lg-highlight-string">"Pizza Rat's Pizzaria"</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">$inc</span>: <!-- -->{ <span class="lg-highlight-string">"violations"</span> <!-- -->: <span class="lg-highlight-number">3</span>}<!-- -->, <span class="lg-highlight-attr">$set</span>: <!-- -->{ <span class="lg-highlight-string">"Closed"</span> <!-- -->: <span class="lg-highlight-literal">true</span> } }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">w</span>: <span class="lg-highlight-string">"majority"</span>, <span class="lg-highlight-attr">wtimeout</span>: <span class="lg-highlight-number">100</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> )<!-- -->;</td></tr><tr class=""><td class="leafygreen-ui-7razhx">} <span class="lg-highlight-keyword">catch</span> <!-- -->(<!-- -->e) <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-title lg-highlight-function">print</span>(<!-- -->e)<!-- -->;</td></tr><tr class=""><td class="leafygreen-ui-7razhx">}</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"> If the primary and at least one secondary acknowledge each write operation within 100 milliseconds, it returns: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ \"acknowledged\" : true, \"matchedCount\" : 1, \"modifiedCount\" : 1 }","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-1q4bxgx" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"acknowledged"</span> <!-- -->: <span class="lg-highlight-literal">true</span>, <span class="lg-highlight-string">"matchedCount"</span> <!-- -->: <span class="lg-highlight-number">1</span>, <span class="lg-highlight-string">"modifiedCount"</span> <!-- -->: <span class="lg-highlight-number">1</span> }</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"> If the acknowledgment takes longer than the <code class="leafygreen-ui-1l06pbn"> wtimeout </code> limit, the following exception is thrown: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"WriteConcernError({\n \"code\" : 64,\n \"errmsg\" : \"waiting for replication timed out\",\n \"errInfo\" : {\n \"wtimeout\" : true,\n \"writeConcern\" : {\n \"w\" : \"majority\",\n \"wtimeout\" : 100,\n \"provenance\" : \"getLastErrorDefaults\"\n }\n }\n})","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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"><span class="lg-highlight-title lg-highlight-class">WriteConcernError</span>(<!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"code"</span> <!-- -->: <span class="lg-highlight-number">64</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"errmsg"</span> <!-- -->: <span class="lg-highlight-string">"waiting for replication timed out"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"errInfo"</span> <!-- -->: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"wtimeout"</span> <!-- -->: <span class="lg-highlight-literal">true</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"writeConcern"</span> <!-- -->: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"w"</span> <!-- -->: <span class="lg-highlight-string">"majority"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"wtimeout"</span> <!-- -->: <span class="lg-highlight-number">100</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"provenance"</span> <!-- -->: <span class="lg-highlight-string">"getLastErrorDefaults"</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">})</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 table explains the possible values of <code class="leafygreen-ui-1l06pbn"> errInfo.writeConcern.provenance </code> : </p> <div class="leafygreen-ui-skkc39" tabindex="0"> <table class="leafygreen-ui-hr8lsv"> <colgroup> <col style="width:20%"/> <col style="width:40%"/> </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> Provenance </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> <code class="leafygreen-ui-1l06pbn"> clientSupplied </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> The write concern was specified in the application. </div> </div> </td> </tr> <tr class=""> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> customDefault </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> The write concern originated from a custom defined default value. See <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/command/setDefaultRWConcern/#mongodb-dbcommand-dbcmd.setDefaultRWConcern"> <code class="leafygreen-ui-1l06pbn"> setDefaultRWConcern </code> . </a> </div> </div> </td> </tr> <tr class=""> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> getLastErrorDefaults </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> The write concern originated from the replica set's <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/replica-configuration/#mongodb-rsconf-rsconf.settings.getLastErrorDefaults"> <code class="leafygreen-ui-1l06pbn"> settings.getLastErrorDefaults </code> </a> field. </div> </div> </td> </tr> <tr class=""> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> implicitDefault </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> The write concern originated from the server in absence of all other write concern specifications. </div> </div> </td> </tr> </tbody> </table> </div> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Update with Sort <a class="headerlink leafygreen-ui-1kepx47" href="#update-with-sort" 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="update-with-sort"> </div> </a> </h3> <div> <p> <em> New <!-- --> in version <!-- --> 8.0 </em> . </p> </div> <p class="leafygreen-ui-1kp3ins"> The following example deactivates the lowest rated active user: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.people.updateOne(\n { state: \"active\" },\n { $set: { state: \"inactive\" } },\n { sort: { rating: 1 }\n)","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">people</span>.<span class="lg-highlight-title lg-highlight-function">updateOne</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">state</span>: <span class="lg-highlight-string">"active"</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">$set</span>: <!-- -->{ <span class="lg-highlight-attr">state</span>: <span class="lg-highlight-string">"inactive"</span> } }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">sort</span>: <!-- -->{ <span class="lg-highlight-attr">rating</span>: <span class="lg-highlight-number">1</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">)</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> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Specify Collation <a class="headerlink leafygreen-ui-1kepx47" href="#specify-collation" 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="specify-collation"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/collation/#std-label-collation"> Collation </a> allows users to specify language-specific rules for string comparison, such as rules for lettercase and accent marks. </p> <p class="leafygreen-ui-1kp3ins"> A collection <code class="leafygreen-ui-1l06pbn"> myColl </code> has the following documents: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ _id: 1, category: \"café\", status: \"A\" }\n{ _id: 2, category: \"cafe\", status: \"a\" }\n{ _id: 3, category: \"cafE\", status: \"a\" }","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">{ <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">1</span>, <span class="lg-highlight-attr">category</span>: <span class="lg-highlight-string">"café"</span>, <span class="lg-highlight-attr">status</span>: <span class="lg-highlight-string">"A"</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">2</span>, <span class="lg-highlight-attr">category</span>: <span class="lg-highlight-string">"cafe"</span>, <span class="lg-highlight-attr">status</span>: <span class="lg-highlight-string">"a"</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">3</span>, <span class="lg-highlight-attr">category</span>: <span class="lg-highlight-string">"cafE"</span>, <span class="lg-highlight-attr">status</span>: <span class="lg-highlight-string">"a"</span> }</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 operation includes the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/collation/#std-label-collation"> collation </a> option: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.myColl.updateOne(\n { category: \"cafe\" },\n { $set: { status: \"Updated\" } },\n { collation: { locale: \"fr\", strength: 1 } }\n);","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">myColl</span>.<span class="lg-highlight-title lg-highlight-function">updateOne</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">category</span>: <span class="lg-highlight-string">"cafe"</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">$set</span>: <!-- -->{ <span class="lg-highlight-attr">status</span>: <span class="lg-highlight-string">"Updated"</span> } }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">collation</span>: <!-- -->{ <span class="lg-highlight-attr">locale</span>: <span class="lg-highlight-string">"fr"</span>, <span class="lg-highlight-attr">strength</span>: <span class="lg-highlight-number">1</span> } }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">)<!-- -->;</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> <span class="leafygreen-ui-1qnjd6d" id="std-label-updateOne-arrayFilters"> </span> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Specify <code class="leafygreen-ui-1l06pbn"> arrayFilters </code> for an Array Update Operations <a class="headerlink leafygreen-ui-1kepx47" href="#specify-arrayfilters-for-an-array-update-operations" 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="specify-arrayfilters-for-an-array-update-operations"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> When updating an array field, you can specify <code class="leafygreen-ui-1l06pbn"> arrayFilters </code> that determine which array elements to update. </p> <section> <h4 class="contains-headerlink leafygreen-ui-1vzlt5f"> Update Elements Match <code class="leafygreen-ui-1l06pbn"> arrayFilters </code> Criteria <a class="headerlink leafygreen-ui-1kepx47" href="#update-elements-match-arrayfilters-criteria" 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="update-elements-match-arrayfilters-criteria"> </div> </a> </h4> <p class="leafygreen-ui-1kp3ins"> Create a collection <code class="leafygreen-ui-1l06pbn"> students </code> with the following documents: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.students.insertMany( [\n { \"_id\" : 1, \"grades\" : [ 95, 92, 90 ] },\n { \"_id\" : 2, \"grades\" : [ 98, 100, 102 ] },\n { \"_id\" : 3, \"grades\" : [ 95, 110, 100 ] }\n] )","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">students</span>.<span class="lg-highlight-title lg-highlight-function">insertMany</span>( <!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">1</span>, <span class="lg-highlight-string">"grades"</span> <!-- -->: <!-- -->[ <span class="lg-highlight-number">95</span>, <span class="lg-highlight-number">92</span>, <span class="lg-highlight-number">90</span> ] }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">2</span>, <span class="lg-highlight-string">"grades"</span> <!-- -->: <!-- -->[ <span class="lg-highlight-number">98</span>, <span class="lg-highlight-number">100</span>, <span class="lg-highlight-number">102</span> ] }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">3</span>, <span class="lg-highlight-string">"grades"</span> <!-- -->: <!-- -->[ <span class="lg-highlight-number">95</span>, <span class="lg-highlight-number">110</span>, <span class="lg-highlight-number">100</span> ] }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">] )</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"> To modify all elements that are greater than or equal to <code class="leafygreen-ui-1l06pbn"> 100 </code> in the <code class="leafygreen-ui-1l06pbn"> grades </code> array, use the filtered positional operator <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/update/positional-filtered/#mongodb-update-up.---identifier--"> <code class="leafygreen-ui-1l06pbn"> $[&lt;identifier&gt;] </code> </a> with the <code class="leafygreen-ui-1l06pbn"> arrayFilters </code> option in the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-method-db.collection.updateOne" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> db.collection.updateOne() </code> </span> </a> method: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.students.updateOne(\n { grades: { $gte: 100 } },\n { $set: { \"grades.$[element]\" : 100 } },\n { arrayFilters: [ { \"element\": { $gte: 100 } } ] }\n)","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">students</span>.<span class="lg-highlight-title lg-highlight-function">updateOne</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">grades</span>: <!-- -->{ <span class="lg-highlight-attr">$gte</span>: <span class="lg-highlight-number">100</span> } }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">$set</span>: <!-- -->{ <span class="lg-highlight-string">"grades.$[element]"</span> <!-- -->: <span class="lg-highlight-number">100</span> } }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">arrayFilters</span>: <!-- -->[ <!-- -->{ <span class="lg-highlight-string">"element"</span>: <!-- -->{ <span class="lg-highlight-attr">$gte</span>: <span class="lg-highlight-number">100</span> } } ] }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">)</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 operation updates the <code class="leafygreen-ui-1l06pbn"> grades </code> field of a single document, and after the operation, the collection has the following documents: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ \"_id\" : 1, \"grades\" : [ 95, 92, 90 ] }\n{ \"_id\" : 2, \"grades\" : [ 98, 100, 100 ] }\n{ \"_id\" : 3, \"grades\" : [ 95, 110, 100 ] }","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">1</span>, <span class="lg-highlight-string">"grades"</span> <!-- -->: <!-- -->[ <span class="lg-highlight-number">95</span>, <span class="lg-highlight-number">92</span>, <span class="lg-highlight-number">90</span> ] }</td></tr><tr class="leafygreen-ui-1wr1lm6"><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">2</span>, <span class="lg-highlight-string">"grades"</span> <!-- -->: <!-- -->[ <span class="lg-highlight-number">98</span>, <span class="lg-highlight-number">100</span>, <span class="lg-highlight-number">100</span> ] }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">3</span>, <span class="lg-highlight-string">"grades"</span> <!-- -->: <!-- -->[ <span class="lg-highlight-number">95</span>, <span class="lg-highlight-number">110</span>, <span class="lg-highlight-number">100</span> ] }</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> </section> <section> <h4 class="contains-headerlink leafygreen-ui-1vzlt5f"> Update Specific Elements of an Array of Documents <a class="headerlink leafygreen-ui-1kepx47" href="#update-specific-elements-of-an-array-of-documents" 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="update-specific-elements-of-an-array-of-documents"> </div> </a> </h4> <p class="leafygreen-ui-1kp3ins"> Create a collection <code class="leafygreen-ui-1l06pbn"> students2 </code> with the following documents: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.students2.insertMany( [\n {\n \"_id\" : 1,\n \"grades\" : [\n { \"grade\" : 80, \"mean\" : 75, \"std\" : 6 },\n { \"grade\" : 85, \"mean\" : 90, \"std\" : 4 },\n { \"grade\" : 85, \"mean\" : 85, \"std\" : 6 }\n ]\n },\n {\n \"_id\" : 2,\n \"grades\" : [\n { \"grade\" : 90, \"mean\" : 75, \"std\" : 6 },\n { \"grade\" : 87, \"mean\" : 90, \"std\" : 3 },\n { \"grade\" : 85, \"mean\" : 85, \"std\" : 4 }\n ]\n }\n] )","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">students2</span>.<span class="lg-highlight-title lg-highlight-function">insertMany</span>( <!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">1</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"grades"</span> <!-- -->: <!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"grade"</span> <!-- -->: <span class="lg-highlight-number">80</span>, <span class="lg-highlight-string">"mean"</span> <!-- -->: <span class="lg-highlight-number">75</span>, <span class="lg-highlight-string">"std"</span> <!-- -->: <span class="lg-highlight-number">6</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"grade"</span> <!-- -->: <span class="lg-highlight-number">85</span>, <span class="lg-highlight-string">"mean"</span> <!-- -->: <span class="lg-highlight-number">90</span>, <span class="lg-highlight-string">"std"</span> <!-- -->: <span class="lg-highlight-number">4</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"grade"</span> <!-- -->: <span class="lg-highlight-number">85</span>, <span class="lg-highlight-string">"mean"</span> <!-- -->: <span class="lg-highlight-number">85</span>, <span class="lg-highlight-string">"std"</span> <!-- -->: <span class="lg-highlight-number">6</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> ]</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">2</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"grades"</span> <!-- -->: <!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"grade"</span> <!-- -->: <span class="lg-highlight-number">90</span>, <span class="lg-highlight-string">"mean"</span> <!-- -->: <span class="lg-highlight-number">75</span>, <span class="lg-highlight-string">"std"</span> <!-- -->: <span class="lg-highlight-number">6</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"grade"</span> <!-- -->: <span class="lg-highlight-number">87</span>, <span class="lg-highlight-string">"mean"</span> <!-- -->: <span class="lg-highlight-number">90</span>, <span class="lg-highlight-string">"std"</span> <!-- -->: <span class="lg-highlight-number">3</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"grade"</span> <!-- -->: <span class="lg-highlight-number">85</span>, <span class="lg-highlight-string">"mean"</span> <!-- -->: <span class="lg-highlight-number">85</span>, <span class="lg-highlight-string">"std"</span> <!-- -->: <span class="lg-highlight-number">4</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> ]</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">] )</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"> To modify the value of the <code class="leafygreen-ui-1l06pbn"> mean </code> field for all elements in the <code class="leafygreen-ui-1l06pbn"> grades </code> array where the grade is greater than or equal to <code class="leafygreen-ui-1l06pbn"> 85 </code> , use the filtered positional operator <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/update/positional-filtered/#mongodb-update-up.---identifier--"> <code class="leafygreen-ui-1l06pbn"> $[&lt;identifier&gt;] </code> </a> with the <code class="leafygreen-ui-1l06pbn"> arrayFilters </code> in the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-method-db.collection.updateOne" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> db.collection.updateOne() </code> </span> </a> method: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.students2.updateOne(\n { },\n { $set: { \"grades.$[elem].mean\" : 100 } },\n { arrayFilters: [ { \"elem.grade\": { $gte: 85 } } ] }\n)","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">students2</span>.<span class="lg-highlight-title lg-highlight-function">updateOne</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <!-- -->}<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">$set</span>: <!-- -->{ <span class="lg-highlight-string">"grades.$[elem].mean"</span> <!-- -->: <span class="lg-highlight-number">100</span> } }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">arrayFilters</span>: <!-- -->[ <!-- -->{ <span class="lg-highlight-string">"elem.grade"</span>: <!-- -->{ <span class="lg-highlight-attr">$gte</span>: <span class="lg-highlight-number">85</span> } } ] }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">)</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 operation updates the array of a single document, and after the operation, the collection has the following documents: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{\n \"_id\" : 1,\n \"grades\" : [\n { \"grade\" : 80, \"mean\" : 75, \"std\" : 6 },\n { \"grade\" : 85, \"mean\" : 100, \"std\" : 4 },\n { \"grade\" : 85, \"mean\" : 100, \"std\" : 6 }\n ]\n}\n{\n \"_id\" : 2,\n \"grades\" : [\n { \"grade\" : 90, \"mean\" : 75, \"std\" : 6 },\n { \"grade\" : 87, \"mean\" : 90, \"std\" : 3 },\n { \"grade\" : 85, \"mean\" : 85, \"std\" : 4 }\n ]\n}","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">1</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"grades"</span> <!-- -->: <!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"grade"</span> <!-- -->: <span class="lg-highlight-number">80</span>, <span class="lg-highlight-string">"mean"</span> <!-- -->: <span class="lg-highlight-number">75</span>, <span class="lg-highlight-string">"std"</span> <!-- -->: <span class="lg-highlight-number">6</span> }<!-- -->,</td></tr><tr class="leafygreen-ui-1wr1lm6"><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"grade"</span> <!-- -->: <span class="lg-highlight-number">85</span>, <span class="lg-highlight-string">"mean"</span> <!-- -->: <span class="lg-highlight-number">100</span>, <span class="lg-highlight-string">"std"</span> <!-- -->: <span class="lg-highlight-number">4</span> }<!-- -->,</td></tr><tr class="leafygreen-ui-1wr1lm6"><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"grade"</span> <!-- -->: <span class="lg-highlight-number">85</span>, <span class="lg-highlight-string">"mean"</span> <!-- -->: <span class="lg-highlight-number">100</span>, <span class="lg-highlight-string">"std"</span> <!-- -->: <span class="lg-highlight-number">6</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> ]</td></tr><tr class=""><td class="leafygreen-ui-7razhx">}</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">2</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"grades"</span> <!-- -->: <!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"grade"</span> <!-- -->: <span class="lg-highlight-number">90</span>, <span class="lg-highlight-string">"mean"</span> <!-- -->: <span class="lg-highlight-number">75</span>, <span class="lg-highlight-string">"std"</span> <!-- -->: <span class="lg-highlight-number">6</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"grade"</span> <!-- -->: <span class="lg-highlight-number">87</span>, <span class="lg-highlight-string">"mean"</span> <!-- -->: <span class="lg-highlight-number">90</span>, <span class="lg-highlight-string">"std"</span> <!-- -->: <span class="lg-highlight-number">3</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"grade"</span> <!-- -->: <span class="lg-highlight-number">85</span>, <span class="lg-highlight-string">"mean"</span> <!-- -->: <span class="lg-highlight-number">85</span>, <span class="lg-highlight-string">"std"</span> <!-- -->: <span class="lg-highlight-number">4</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> ]</td></tr><tr class=""><td class="leafygreen-ui-7razhx">}</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> <span class="leafygreen-ui-1qnjd6d" id="std-label-ex-update-one-hint"> </span> </section> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Specify <code class="leafygreen-ui-1l06pbn"> hint </code> for Update Operations <a class="headerlink leafygreen-ui-1kepx47" href="#specify-hint-for-update-operations" 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="specify-hint-for-update-operations"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> Create a sample <code class="leafygreen-ui-1l06pbn"> students </code> collection with the following documents: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.students.insertMany( [\n { \"_id\" : 1, \"student\" : \"Richard\", \"grade\" : \"F\", \"points\" : 0, \"comments1\" : null, \"comments2\" : null },\n { \"_id\" : 2, \"student\" : \"Jane\", \"grade\" : \"A\", \"points\" : 60, \"comments1\" : \"well behaved\", \"comments2\" : \"fantastic student\" },\n { \"_id\" : 3, \"student\" : \"Ronan\", \"grade\" : \"F\", \"points\" : 0, \"comments1\" : null, \"comments2\" : null },\n { \"_id\" : 4, \"student\" : \"Noah\", \"grade\" : \"D\", \"points\" : 20, \"comments1\" : \"needs improvement\", \"comments2\" : null },\n { \"_id\" : 5, \"student\" : \"Adam\", \"grade\" : \"F\", \"points\" : 0, \"comments1\" : null, \"comments2\" : null },\n { \"_id\" : 6, \"student\" : \"Henry\", \"grade\" : \"A\", \"points\" : 86, \"comments1\" : \"fantastic student\", \"comments2\" : \"well behaved\" }\n] )","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><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">students</span>.<span class="lg-highlight-title lg-highlight-function">insertMany</span>( <!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">1</span>, <span class="lg-highlight-string">"student"</span> <!-- -->: <span class="lg-highlight-string">"Richard"</span>, <span class="lg-highlight-string">"grade"</span> <!-- -->: <span class="lg-highlight-string">"F"</span>, <span class="lg-highlight-string">"points"</span> <!-- -->: <span class="lg-highlight-number">0</span>, <span class="lg-highlight-string">"comments1"</span> <!-- -->: <span class="lg-highlight-literal">null</span>, <span class="lg-highlight-string">"comments2"</span> <!-- -->: <span class="lg-highlight-literal">null</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">2</span>, <span class="lg-highlight-string">"student"</span> <!-- -->: <span class="lg-highlight-string">"Jane"</span>, <span class="lg-highlight-string">"grade"</span> <!-- -->: <span class="lg-highlight-string">"A"</span>, <span class="lg-highlight-string">"points"</span> <!-- -->: <span class="lg-highlight-number">60</span>, <span class="lg-highlight-string">"comments1"</span> <!-- -->: <span class="lg-highlight-string">"well behaved"</span>, <span class="lg-highlight-string">"comments2"</span> <!-- -->: <span class="lg-highlight-string">"fantastic student"</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">3</span>, <span class="lg-highlight-string">"student"</span> <!-- -->: <span class="lg-highlight-string">"Ronan"</span>, <span class="lg-highlight-string">"grade"</span> <!-- -->: <span class="lg-highlight-string">"F"</span>, <span class="lg-highlight-string">"points"</span> <!-- -->: <span class="lg-highlight-number">0</span>, <span class="lg-highlight-string">"comments1"</span> <!-- -->: <span class="lg-highlight-literal">null</span>, <span class="lg-highlight-string">"comments2"</span> <!-- -->: <span class="lg-highlight-literal">null</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">4</span>, <span class="lg-highlight-string">"student"</span> <!-- -->: <span class="lg-highlight-string">"Noah"</span>, <span class="lg-highlight-string">"grade"</span> <!-- -->: <span class="lg-highlight-string">"D"</span>, <span class="lg-highlight-string">"points"</span> <!-- -->: <span class="lg-highlight-number">20</span>, <span class="lg-highlight-string">"comments1"</span> <!-- -->: <span class="lg-highlight-string">"needs improvement"</span>, <span class="lg-highlight-string">"comments2"</span> <!-- -->: <span class="lg-highlight-literal">null</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">5</span>, <span class="lg-highlight-string">"student"</span> <!-- -->: <span class="lg-highlight-string">"Adam"</span>, <span class="lg-highlight-string">"grade"</span> <!-- -->: <span class="lg-highlight-string">"F"</span>, <span class="lg-highlight-string">"points"</span> <!-- -->: <span class="lg-highlight-number">0</span>, <span class="lg-highlight-string">"comments1"</span> <!-- -->: <span class="lg-highlight-literal">null</span>, <span class="lg-highlight-string">"comments2"</span> <!-- -->: <span class="lg-highlight-literal">null</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">6</span>, <span class="lg-highlight-string">"student"</span> <!-- -->: <span class="lg-highlight-string">"Henry"</span>, <span class="lg-highlight-string">"grade"</span> <!-- -->: <span class="lg-highlight-string">"A"</span>, <span class="lg-highlight-string">"points"</span> <!-- -->: <span class="lg-highlight-number">86</span>, <span class="lg-highlight-string">"comments1"</span> <!-- -->: <span class="lg-highlight-string">"fantastic student"</span>, <span class="lg-highlight-string">"comments2"</span> <!-- -->: <span class="lg-highlight-string">"well behaved"</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">] )</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"> Create the following indexes on the collection: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.students.createIndex( { grade: 1 } )\ndb.students.createIndex( { points: 1 } )","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">students</span>.<span class="lg-highlight-title lg-highlight-function">createIndex</span>( <!-- -->{ <span class="lg-highlight-attr">grade</span>: <span class="lg-highlight-number">1</span> } )</td></tr><tr class=""><td class="leafygreen-ui-7razhx">db.<span class="lg-highlight-property">students</span>.<span class="lg-highlight-title lg-highlight-function">createIndex</span>( <!-- -->{ <span class="lg-highlight-attr">points</span>: <span class="lg-highlight-number">1</span> } )</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 update operation explicitly hints to use the index <code class="leafygreen-ui-1l06pbn"> { grade: 1 } </code> : </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"> If you specify an index that does not exist, the operation errors. </p> </div> </div> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.students.updateOne(\n { \"points\": { $lte: 20 }, \"grade\": \"F\" },\n { $set: { \"comments1\": \"failed class\" } },\n { hint: { grade: 1 } }\n)","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">students</span>.<span class="lg-highlight-title lg-highlight-function">updateOne</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"points"</span>: <!-- -->{ <span class="lg-highlight-attr">$lte</span>: <span class="lg-highlight-number">20</span> }<!-- -->, <span class="lg-highlight-string">"grade"</span>: <span class="lg-highlight-string">"F"</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">$set</span>: <!-- -->{ <span class="lg-highlight-string">"comments1"</span>: <span class="lg-highlight-string">"failed class"</span> } }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">hint</span>: <!-- -->{ <span class="lg-highlight-attr">grade</span>: <span class="lg-highlight-number">1</span> } }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">)</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 update command returns the following: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ \"acknowledged\" : true, \"matchedCount\" : 1, \"modifiedCount\" : 1 }","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-1q4bxgx" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"acknowledged"</span> <!-- -->: <span class="lg-highlight-literal">true</span>, <span class="lg-highlight-string">"matchedCount"</span> <!-- -->: <span class="lg-highlight-number">1</span>, <span class="lg-highlight-string">"modifiedCount"</span> <!-- -->: <span class="lg-highlight-number">1</span> }</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-15mdk4" role="note"> <h2 class="leafygreen-ui-6n7b7d"> Note </h2> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> Even though 3 documents match the criteria of the update, <code class="leafygreen-ui-1l06pbn"> updateOne </code> only modifies the first document it finds. Therefore, even though the students Richard, Ronan, and Adam all meet the criteria, only Richard will be updated. </p> </div> </div> <p class="leafygreen-ui-1kp3ins"> To see the index used, run <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/command/explain/#mongodb-dbcommand-dbcmd.explain"> <code class="leafygreen-ui-1l06pbn"> explain </code> </a> on the operation: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.students.explain().update(\n { \"points\": { $lte: 20 }, \"grade\": \"F\" },\n { $set: { \"comments1\": \"failed class\" } },\n { multi: true, hint: { grade: 1 } }\n)","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">students</span>.<span class="lg-highlight-title lg-highlight-function">explain</span>(<!-- -->).<span class="lg-highlight-title lg-highlight-function">update</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"points"</span>: <!-- -->{ <span class="lg-highlight-attr">$lte</span>: <span class="lg-highlight-number">20</span> }<!-- -->, <span class="lg-highlight-string">"grade"</span>: <span class="lg-highlight-string">"F"</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">$set</span>: <!-- -->{ <span class="lg-highlight-string">"comments1"</span>: <span class="lg-highlight-string">"failed class"</span> } }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">multi</span>: <span class="lg-highlight-literal">true</span>, <span class="lg-highlight-attr">hint</span>: <!-- -->{ <span class="lg-highlight-attr">grade</span>: <span class="lg-highlight-number">1</span> } }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">)</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> <span class="leafygreen-ui-1qnjd6d" id="std-label-updateOne-example-user-roles-system-variable"> </span> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> User Roles and Document Updates <a class="headerlink leafygreen-ui-1kepx47" href="#user-roles-and-document-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="user-roles-and-document-updates"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> Starting in MongoDB 7.0, you can use the new <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/aggregation-variables/#mongodb-variable-variable.USER_ROLES"> <code class="leafygreen-ui-1l06pbn"> USER_ROLES </code> </a> system variable to return user <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/authorization/#std-label-roles"> roles <!-- --> . </a> </p> <p class="leafygreen-ui-1kp3ins"> The example in this section shows updates to fields in a collection containing medical information. The example reads the current user roles from the <code class="leafygreen-ui-1l06pbn"> USER_ROLES </code> system variable and only performs the updates if the user has a specific role. </p> <p class="leafygreen-ui-1kp3ins"> To use a system variable, add <code class="leafygreen-ui-1l06pbn"> $$ </code> to the start of the variable name. Specify the <code class="leafygreen-ui-1l06pbn"> USER_ROLES </code> system variable as <code class="leafygreen-ui-1l06pbn"> $$USER_ROLES </code> . </p> <p class="leafygreen-ui-1kp3ins"> The example creates these users: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <code class="leafygreen-ui-1l06pbn"> James </code> with a <code class="leafygreen-ui-1l06pbn"> Billing </code> role. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <code class="leafygreen-ui-1l06pbn"> Michelle </code> with a <code class="leafygreen-ui-1l06pbn"> Provider </code> role. </p> </li> </ul> <p class="leafygreen-ui-1kp3ins"> Perform the following steps to create the roles, users, and collection: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"HowTo","steps":[{"@type":"HowToStep","text":"Create roles named Billing and Provider with the required\nprivileges and resources.Run:","name":"Create the roles"},{"@type":"HowToStep","text":"Create users named James and Michelle with the required\nroles.","name":"Create the users"},{"@type":"HowToStep","text":"Run:","name":"Create the collection"}],"name":"User Roles and Document Updates","image":"https://webimages.mongodb.com/_com_assets/cms/kuyj2focmkbxv7gh3-stacked_default_slate_blue.svg?auto=format%252Ccompress"} </script> <div class="css-4nyere eccljxs0"> <div class="css-1nuklj8 e1ckbxcu1"> <div class="css-18fui5z e1ckbxcu0"> <div class="css-19lsqsq e1ckbxcu2"> 1 </div> </div> <div class="css-1ed38mk"> <section> <h4 class="contains-headerlink leafygreen-ui-1vzlt5f"> Create the roles <a class="headerlink leafygreen-ui-1kepx47" href="#create-the-roles" 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="create-the-roles"> </div> </a> </h4> <p class="leafygreen-ui-1kp3ins"> Create roles named <code class="leafygreen-ui-1l06pbn"> Billing </code> and <code class="leafygreen-ui-1l06pbn"> Provider </code> with the required privileges and resources. </p> <p class="leafygreen-ui-1kp3ins"> Run: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.createRole( { role: \"Billing\", privileges: [ { resource: { db: \"test\",\n collection: \"medicalView\" }, actions: [ \"find\" ] } ], roles: [ ] } )\ndb.createRole( { role: \"Provider\", privileges: [ { resource: { db: \"test\",\n collection: \"medicalView\" }, actions: [ \"find\" ] } ], roles: [ ] } )","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><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">createRole</span>( <!-- -->{ <span class="lg-highlight-attr">role</span>: <span class="lg-highlight-string">"Billing"</span>, <span class="lg-highlight-attr">privileges</span>: <!-- -->[ <!-- -->{ <span class="lg-highlight-attr">resource</span>: <!-- -->{ <span class="lg-highlight-attr">db</span>: <span class="lg-highlight-string">"test"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">collection</span>: <span class="lg-highlight-string">"medicalView"</span> }<!-- -->, <span class="lg-highlight-attr">actions</span>: <!-- -->[ <span class="lg-highlight-string">"find"</span> ] } ]<!-- -->, <span class="lg-highlight-attr">roles</span>: <!-- -->[ <!-- -->] } )</td></tr><tr class=""><td class="leafygreen-ui-7razhx">db.<span class="lg-highlight-title lg-highlight-function">createRole</span>( <!-- -->{ <span class="lg-highlight-attr">role</span>: <span class="lg-highlight-string">"Provider"</span>, <span class="lg-highlight-attr">privileges</span>: <!-- -->[ <!-- -->{ <span class="lg-highlight-attr">resource</span>: <!-- -->{ <span class="lg-highlight-attr">db</span>: <span class="lg-highlight-string">"test"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">collection</span>: <span class="lg-highlight-string">"medicalView"</span> }<!-- -->, <span class="lg-highlight-attr">actions</span>: <!-- -->[ <span class="lg-highlight-string">"find"</span> ] } ]<!-- -->, <span class="lg-highlight-attr">roles</span>: <!-- -->[ <!-- -->] } )</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> </section> </div> </div> <div class="css-1nuklj8 e1ckbxcu1"> <div class="css-18fui5z e1ckbxcu0"> <div class="css-19lsqsq e1ckbxcu2"> 2 </div> </div> <div class="css-1ed38mk"> <section> <h4 class="contains-headerlink leafygreen-ui-1vzlt5f"> Create the users <a class="headerlink leafygreen-ui-1kepx47" href="#create-the-users" 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="create-the-users"> </div> </a> </h4> <p class="leafygreen-ui-1kp3ins"> Create users named <code class="leafygreen-ui-1l06pbn"> James </code> and <code class="leafygreen-ui-1l06pbn"> Michelle </code> with the required roles. </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.createUser( {\n user: \"James\",\n pwd: \"js008\",\n roles: [\n { role: \"Billing\", db: \"test\" }\n ]\n} )\n\ndb.createUser( {\n user: \"Michelle\",\n pwd: \"me009\",\n roles: [\n { role: \"Provider\", db: \"test\" }\n ]\n} )","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">createUser</span>( <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">user</span>: <span class="lg-highlight-string">"James"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">pwd</span>: <span class="lg-highlight-string">"js008"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">roles</span>: <!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">role</span>: <span class="lg-highlight-string">"Billing"</span>, <span class="lg-highlight-attr">db</span>: <span class="lg-highlight-string">"test"</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> ]</td></tr><tr class=""><td class="leafygreen-ui-7razhx">} )</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><div class="leafygreen-ui-ihxujy"></div></td></tr><tr class=""><td class="leafygreen-ui-7razhx">db.<span class="lg-highlight-title lg-highlight-function">createUser</span>( <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">user</span>: <span class="lg-highlight-string">"Michelle"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">pwd</span>: <span class="lg-highlight-string">"me009"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">roles</span>: <!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">role</span>: <span class="lg-highlight-string">"Provider"</span>, <span class="lg-highlight-attr">db</span>: <span class="lg-highlight-string">"test"</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> ]</td></tr><tr class=""><td class="leafygreen-ui-7razhx">} )</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> </section> </div> </div> <div class="css-1nuklj8 e1ckbxcu1"> <div class="css-18fui5z e1ckbxcu0"> <div class="css-19lsqsq e1ckbxcu2"> 3 </div> </div> <div class="css-1ed38mk"> <section> <h4 class="contains-headerlink leafygreen-ui-1vzlt5f"> Create the collection <a class="headerlink leafygreen-ui-1kepx47" href="#create-the-collection" 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="create-the-collection"> </div> </a> </h4> <p class="leafygreen-ui-1kp3ins"> Run: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.medical.insertMany( [\n {\n _id: 0,\n patientName: \"Jack Jones\",\n diagnosisCode: \"CAS 17\",\n creditCard: \"1234-5678-9012-3456\"\n },\n {\n _id: 1,\n patientName: \"Mary Smith\",\n diagnosisCode: \"ACH 01\",\n creditCard: \"6541-7534-9637-3456\"\n }\n] )","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">medical</span>.<span class="lg-highlight-title lg-highlight-function">insertMany</span>( <!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">0</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">patientName</span>: <span class="lg-highlight-string">"Jack Jones"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">diagnosisCode</span>: <span class="lg-highlight-string">"CAS 17"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">creditCard</span>: <span class="lg-highlight-string">"1234-5678-9012-3456"</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">1</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">patientName</span>: <span class="lg-highlight-string">"Mary Smith"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">diagnosisCode</span>: <span class="lg-highlight-string">"ACH 01"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">creditCard</span>: <span class="lg-highlight-string">"6541-7534-9637-3456"</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">] )</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> </section> </div> </div> </div> <p class="leafygreen-ui-1kp3ins"> Log in as as <code class="leafygreen-ui-1l06pbn"> Michelle </code> , who has the <code class="leafygreen-ui-1l06pbn"> Provider </code> role, and perform an update: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"HowTo","steps":[{"@type":"HowToStep","text":"Run:","name":"Log in as Michelle"},{"@type":"HowToStep","text":"Run:","name":"Perform update"}],"name":"User Roles and Document Updates","image":"https://webimages.mongodb.com/_com_assets/cms/kuyj2focmkbxv7gh3-stacked_default_slate_blue.svg?auto=format%252Ccompress"} </script> <div class="css-4nyere eccljxs0"> <div class="css-1nuklj8 e1ckbxcu1"> <div class="css-18fui5z e1ckbxcu0"> <div class="css-19lsqsq e1ckbxcu2"> 1 </div> </div> <div class="css-1ed38mk"> <section> <h4 class="contains-headerlink leafygreen-ui-1vzlt5f"> Log in as <code class="leafygreen-ui-1l06pbn"> Michelle </code> <a class="headerlink leafygreen-ui-1kepx47" href="#log-in-as-michelle" 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="log-in-as-michelle"> </div> </a> </h4> <p class="leafygreen-ui-1kp3ins"> Run: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.auth( \"Michelle\", \"me009\" )","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">auth</span>( <span class="lg-highlight-string">"Michelle"</span>, <span class="lg-highlight-string">"me009"</span> )</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> </section> </div> </div> <div class="css-1nuklj8 e1ckbxcu1"> <div class="css-18fui5z e1ckbxcu0"> <div class="css-19lsqsq e1ckbxcu2"> 2 </div> </div> <div class="css-1ed38mk"> <section> <h4 class="contains-headerlink leafygreen-ui-1vzlt5f"> Perform update <a class="headerlink leafygreen-ui-1kepx47" href="#perform-update" 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="perform-update"> </div> </a> </h4> <p class="leafygreen-ui-1kp3ins"> Run: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"// Attempt to update one document\ndb.medical.updateOne( {\n // User must have the Provider role to perform the update\n $expr: { $ne: [\n { $setIntersection: [ [ \"Provider\" ], \"$$USER_ROLES.role\" ] }, []\n ] } },\n // Update diagnosisCode\n { $set: { diagnosisCode: \"ACH 01\"} }\n)","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-comment">//</span><span class="lg-highlight-comment"> Attempt to update </span><span class="lg-highlight-comment">one document</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx">db.<span class="lg-highlight-property">medical</span>.<span class="lg-highlight-title lg-highlight-function">updateOne</span>( <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-comment">//</span><span class="lg-highlight-comment"> User must have </span><span class="lg-highlight-comment">the</span><span class="lg-highlight-comment"> Provider role to </span><span class="lg-highlight-comment">perform the update</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">$expr</span>: <!-- -->{ <span class="lg-highlight-attr">$ne</span>: <!-- -->[</td></tr><tr class="leafygreen-ui-1wr1lm6"><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">$setIntersection</span>: <!-- -->[ <!-- -->[ <span class="lg-highlight-string">"Provider"</span> ]<!-- -->, <span class="lg-highlight-string">"$$USER_ROLES.role"</span> ] }<!-- -->, <!-- -->[<!-- -->]</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> ] } }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-comment">// Update diagnosisCode</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">$set</span>: <!-- -->{ <span class="lg-highlight-attr">diagnosisCode</span>: <span class="lg-highlight-string">"ACH 01"</span>} }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">)</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> </section> </div> </div> </div> <p class="leafygreen-ui-1kp3ins"> The previous example uses <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/setIntersection/#mongodb-expression-exp.-setIntersection"> <code class="leafygreen-ui-1l06pbn"> $setIntersection </code> </a> to return documents where the intersection between the <code class="leafygreen-ui-1l06pbn"> "Provider" </code> string and the user roles from <code class="leafygreen-ui-1l06pbn"> $$USER_ROLES.role </code> is not empty. <code class="leafygreen-ui-1l06pbn"> Michelle </code> has the <code class="leafygreen-ui-1l06pbn"> Provider </code> role, so the update is performed. </p> <p class="leafygreen-ui-1kp3ins"> Next, log in as as <code class="leafygreen-ui-1l06pbn"> James </code> , who does not have the <code class="leafygreen-ui-1l06pbn"> Provider </code> role, and attempt to perform the same update: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"HowTo","steps":[{"@type":"HowToStep","text":"Run:","name":"Log in as James"},{"@type":"HowToStep","text":"Run:","name":"Attempt to perform update"}],"name":"User Roles and Document Updates","image":"https://webimages.mongodb.com/_com_assets/cms/kuyj2focmkbxv7gh3-stacked_default_slate_blue.svg?auto=format%252Ccompress"} </script> <div class="css-4nyere eccljxs0"> <div class="css-1nuklj8 e1ckbxcu1"> <div class="css-18fui5z e1ckbxcu0"> <div class="css-19lsqsq e1ckbxcu2"> 1 </div> </div> <div class="css-1ed38mk"> <section> <h4 class="contains-headerlink leafygreen-ui-1vzlt5f"> Log in as <code class="leafygreen-ui-1l06pbn"> James </code> <a class="headerlink leafygreen-ui-1kepx47" href="#log-in-as-james" 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="log-in-as-james"> </div> </a> </h4> <p class="leafygreen-ui-1kp3ins"> Run: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.auth( \"James\", \"js008\" )","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">auth</span>( <span class="lg-highlight-string">"James"</span>, <span class="lg-highlight-string">"js008"</span> )</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> </section> </div> </div> <div class="css-1nuklj8 e1ckbxcu1"> <div class="css-18fui5z e1ckbxcu0"> <div class="css-19lsqsq e1ckbxcu2"> 2 </div> </div> <div class="css-1ed38mk"> <section> <h4 class="contains-headerlink leafygreen-ui-1vzlt5f"> Attempt to perform update <a class="headerlink leafygreen-ui-1kepx47" href="#attempt-to-perform-update" 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="attempt-to-perform-update"> </div> </a> </h4> <p class="leafygreen-ui-1kp3ins"> Run: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"// Attempt to update one document\ndb.medical.updateOne( {\n // User must have the Provider role to perform the update\n $expr: { $ne: [\n { $setIntersection: [ [ \"Provider\" ], \"$$USER_ROLES.role\" ] }, []\n ] } },\n // Update diagnosisCode\n { $set: { diagnosisCode: \"ACH 01\"} }\n)","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-comment">//</span><span class="lg-highlight-comment"> Attempt to update </span><span class="lg-highlight-comment">one document</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx">db.<span class="lg-highlight-property">medical</span>.<span class="lg-highlight-title lg-highlight-function">updateOne</span>( <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-comment">//</span><span class="lg-highlight-comment"> User must have </span><span class="lg-highlight-comment">the</span><span class="lg-highlight-comment"> Provider role to </span><span class="lg-highlight-comment">perform the update</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">$expr</span>: <!-- -->{ <span class="lg-highlight-attr">$ne</span>: <!-- -->[</td></tr><tr class="leafygreen-ui-1wr1lm6"><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">$setIntersection</span>: <!-- -->[ <!-- -->[ <span class="lg-highlight-string">"Provider"</span> ]<!-- -->, <span class="lg-highlight-string">"$$USER_ROLES.role"</span> ] }<!-- -->, <!-- -->[<!-- -->]</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> ] } }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-comment">// Update diagnosisCode</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">$set</span>: <!-- -->{ <span class="lg-highlight-attr">diagnosisCode</span>: <span class="lg-highlight-string">"ACH 01"</span>} }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">)</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> </section> </div> </div> </div> <p class="leafygreen-ui-1kp3ins"> The previous example does not update any documents. </p> <div class="leafygreen-ui-13vw3ie" role="note"> <h2 class="leafygreen-ui-1fn4p2b"> Tip </h2> <h3 class="leafygreen-ui-144d5kf"> <strong> See also: </strong> </h3> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> To update multiple documents, see <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/db.collection.updateMany/#mongodb-method-db.collection.updateMany"> <code class="leafygreen-ui-1l06pbn"> db.collection.updateMany() </code> . </a> </p> </div> </div> </section> </section> </section>
https://www.mongodb.com/docs/manual/reference/operator/query/and/
<section> <h1 class="contains-headerlink leafygreen-ui-41fr9s" weight="medium"> $and <a class="headerlink leafygreen-ui-1kepx47" href="#-and" 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="-and"> </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="#syntax" target="_self"> <span> Syntax </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#behavior" target="_self"> <span> Behavior </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#examples" target="_self"> <span> Examples </span> </a> </li> </ul> </div> <dl class="query"> <dt> <code class="leafygreen-ui-1l06pbn"> $and </code> <a class="headerlink leafygreen-ui-1kepx47" href="#mongodb-query-op.-and" title="Permalink to this definition"> <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="mongodb-query-op.-and"> </div> </a> </dt> <dd> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-query-op.-and" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $and </code> </span> </a> performs a logical <code class="leafygreen-ui-1l06pbn"> AND </code> operation on an array of <em> one or more </em> expressions ( <code class="leafygreen-ui-1l06pbn"> &lt;expression1&gt; </code> , <code class="leafygreen-ui-1l06pbn"> &lt;expression2&gt; </code> , and so on) and selects the documents that satisfy <em> all </em> the expressions. </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"> MongoDB provides an implicit <code class="leafygreen-ui-1l06pbn"> AND </code> operation when specifying a comma separated list of expressions. </p> </div> </div> </dd> </dl> <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 <code class="leafygreen-ui-1l06pbn"> $and </code> 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"> Syntax <a class="headerlink leafygreen-ui-1kepx47" href="#syntax" 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="syntax"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> The <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-query-op.-and" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $and </code> </span> </a> has the following syntax: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ $and: [ { &lt;expression1&gt; }, { &lt;expression2&gt; } , ... , { &lt;expressionn&gt; } ] }","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-1q4bxgx" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-attr">$and</span>: <!-- -->[ <!-- -->{ &lt;<!-- -->expression1<!-- -->&gt; <!-- -->}<!-- -->, <!-- -->{ &lt;<!-- -->expression2<!-- -->&gt; <!-- -->} <!-- -->, <!-- -->...<!-- --> <!-- -->, <!-- -->{ &lt;<!-- -->expressionN<!-- -->&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> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Behavior <a class="headerlink leafygreen-ui-1kepx47" href="#behavior" 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="behavior"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> When evaluating the clauses in the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-query-op.-and" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $and </code> </span> </a> expression, MongoDB's query optimizer considers which indexes are available that could help satisfy clauses of the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-query-op.-and" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $and </code> </span> </a> expression when <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/query-plans/#std-label-read-operations-query-optimization"> selecting the best plan to execute <!-- --> . </a> </p> <p class="leafygreen-ui-1kp3ins"> To allow the query engine to optimize queries, <code class="leafygreen-ui-1l06pbn"> $and </code> handles errors as follows: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> If any expression supplied to <code class="leafygreen-ui-1l06pbn"> $and </code> would cause an error when evaluated alone, the <code class="leafygreen-ui-1l06pbn"> $and </code> containing the expression may cause an error but an error is not guaranteed. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> An expression supplied after the first expression supplied to <code class="leafygreen-ui-1l06pbn"> $and </code> may cause an error even if the first expression evaluates to <code class="leafygreen-ui-1l06pbn"> false </code> . </p> </li> </ul> <p class="leafygreen-ui-1kp3ins"> For example, the following query <em> always </em> produces an error if <code class="leafygreen-ui-1l06pbn"> $x </code> is <code class="leafygreen-ui-1l06pbn"> 0 </code> : </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.example.find( {\n $expr: { $eq: [ { $divide: [ 1, \"$x\" ] }, 3 ] }\n} )","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">example</span>.<span class="lg-highlight-title lg-highlight-function">find</span>( <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">$expr</span>: <!-- -->{ <span class="lg-highlight-attr">$eq</span>: <!-- -->[ <!-- -->{ <span class="lg-highlight-attr">$divide</span>: <!-- -->[ <span class="lg-highlight-number">1</span>, <span class="lg-highlight-string">"$x"</span> ] }<!-- -->, <span class="lg-highlight-number">3</span> ] }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">} )</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 query, which contains multiple expressions supplied to <code class="leafygreen-ui-1l06pbn"> $and </code> , <em> may </em> produce an error if there is any document where <code class="leafygreen-ui-1l06pbn"> $x </code> is <code class="leafygreen-ui-1l06pbn"> 0 </code> : </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.example.find( {\n $and: [\n { x: { $ne: 0 } },\n { $expr: { $eq: [ { $divide: [ 1, \"$x\" ] }, 3 ] } }\n ]\n} )","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">example</span>.<span class="lg-highlight-title lg-highlight-function">find</span>( <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">$and</span>: <!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">x</span>: <!-- -->{ <span class="lg-highlight-attr">$ne</span>: <span class="lg-highlight-number">0</span> } }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">$expr</span>: <!-- -->{ <span class="lg-highlight-attr">$eq</span>: <!-- -->[ <!-- -->{ <span class="lg-highlight-attr">$divide</span>: <!-- -->[ <span class="lg-highlight-number">1</span>, <span class="lg-highlight-string">"$x"</span> ] }<!-- -->, <span class="lg-highlight-number">3</span> ] } }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> ]</td></tr><tr class=""><td class="leafygreen-ui-7razhx">} )</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> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Examples <a class="headerlink leafygreen-ui-1kepx47" href="#examples" 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="examples"> </div> </a> </h2> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> <code class="leafygreen-ui-1l06pbn"> AND </code> Queries With Multiple Expressions Specifying the Same Field <a class="headerlink leafygreen-ui-1kepx47" href="#and-queries-with-multiple-expressions-specifying-the-same-field" 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="and-queries-with-multiple-expressions-specifying-the-same-field"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> Consider this query: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.inventory.find( { $and: [ { price: { $ne: 1.99 } }, { price: { $exists: true } } ] } )","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-1q4bxgx" tabindex="0"><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">inventory</span>.<span class="lg-highlight-title lg-highlight-function">find</span>( <!-- -->{ <span class="lg-highlight-attr">$and</span>: <!-- -->[ <!-- -->{ <span class="lg-highlight-attr">price</span>: <!-- -->{ <span class="lg-highlight-attr">$ne</span>: <span class="lg-highlight-number">1.99</span> } }<!-- -->, <!-- -->{ <span class="lg-highlight-attr">price</span>: <!-- -->{ <span class="lg-highlight-attr">$exists</span>: <span class="lg-highlight-literal">true</span> } } ] } )</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 query selects all documents in the <code class="leafygreen-ui-1l06pbn"> inventory </code> collection where: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> the <code class="leafygreen-ui-1l06pbn"> price </code> field value is not equal to <code class="leafygreen-ui-1l06pbn"> 1.99 </code> <strong> and </strong> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> the <code class="leafygreen-ui-1l06pbn"> price </code> field exists. </p> </li> </ul> <p class="leafygreen-ui-1kp3ins"> The query can be rewritten with an implicit <code class="leafygreen-ui-1l06pbn"> AND </code> operation that combines the operator expressions for the <code class="leafygreen-ui-1l06pbn"> price </code> field: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.inventory.find( { price: { $ne: 1.99, $exists: true } } )","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-1q4bxgx" tabindex="0"><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">inventory</span>.<span class="lg-highlight-title lg-highlight-function">find</span>( <!-- -->{ <span class="lg-highlight-attr">price</span>: <!-- -->{ <span class="lg-highlight-attr">$ne</span>: <span class="lg-highlight-number">1.99</span>, <span class="lg-highlight-attr">$exists</span>: <span class="lg-highlight-literal">true</span> } } )</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> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> <code class="leafygreen-ui-1l06pbn"> AND </code> Queries With Multiple Expressions Specifying the Same Operator <a class="headerlink leafygreen-ui-1kepx47" href="#and-queries-with-multiple-expressions-specifying-the-same-operator" 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="and-queries-with-multiple-expressions-specifying-the-same-operator"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> Consider this query: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.inventory.find( {\n $and: [\n { $or: [ { qty: { $lt : 10 } }, { qty : { $gt: 50 } } ] },\n { $or: [ { sale: true }, { price : { $lt : 5 } } ] }\n ]\n} )","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><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">inventory</span>.<span class="lg-highlight-title lg-highlight-function">find</span>( <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">$and</span>: <!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">$or</span>: <!-- -->[ <!-- -->{ <span class="lg-highlight-attr">qty</span>: <!-- -->{ <!-- -->$lt<!-- --> <!-- -->: <span class="lg-highlight-number">10</span> } }<!-- -->, <!-- -->{ <!-- -->qty <!-- -->: <!-- -->{ <span class="lg-highlight-attr">$gt</span>: <span class="lg-highlight-number">50</span> } } ] }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">$or</span>: <!-- -->[ <!-- -->{ <span class="lg-highlight-attr">sale</span>: <span class="lg-highlight-literal">true</span> }<!-- -->, <!-- -->{ <!-- -->price <!-- -->: <!-- -->{ <!-- -->$lt<!-- --> <!-- -->: <span class="lg-highlight-number">5</span> } } ] }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> ]</td></tr><tr class=""><td class="leafygreen-ui-7razhx">} )</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 query selects all documents where: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> the <code class="leafygreen-ui-1l06pbn"> qty </code> field value is less than <code class="leafygreen-ui-1l06pbn"> 10 </code> or greater than <code class="leafygreen-ui-1l06pbn"> 50 </code> , <strong> and </strong> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> the <code class="leafygreen-ui-1l06pbn"> sale </code> field value is equal to <code class="leafygreen-ui-1l06pbn"> true </code> <strong> or </strong> the <code class="leafygreen-ui-1l06pbn"> price </code> field value is less than <code class="leafygreen-ui-1l06pbn"> 5 </code> . </p> </li> </ul> <p class="leafygreen-ui-1kp3ins"> The query cannot use an implicit <code class="leafygreen-ui-1l06pbn"> AND </code> operation because it uses the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/query/or/#mongodb-query-op.-or"> <code class="leafygreen-ui-1l06pbn"> $or </code> </a> operator more than once. </p> <div class="leafygreen-ui-13vw3ie" role="note"> <h2 class="leafygreen-ui-1fn4p2b"> Tip </h2> <h3 class="leafygreen-ui-144d5kf"> <strong> See also: </strong> </h3> <div class="leafygreen-ui-9mycqc"> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/db.collection.find/#mongodb-method-db.collection.find"> <code class="leafygreen-ui-1l06pbn"> find() </code> </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/db.collection.updateMany/#mongodb-method-db.collection.updateMany"> <code class="leafygreen-ui-1l06pbn"> updateMany() </code> </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/query/ne/#mongodb-query-op.-ne"> <code class="leafygreen-ui-1l06pbn"> $ne </code> </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/query/exists/#mongodb-query-op.-exists"> <code class="leafygreen-ui-1l06pbn"> $exists </code> </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/update/set/#mongodb-update-up.-set"> <code class="leafygreen-ui-1l06pbn"> $set </code> </a> </p> </li> </ul> </div> </div> </section> </section> </section>
https://www.mongodb.com/docs/manual/reference/operator/aggregation/getField/
<section> <h1 class="contains-headerlink leafygreen-ui-41fr9s" weight="medium"> $getField (aggregation) <a class="headerlink leafygreen-ui-1kepx47" href="#-getfield--aggregation-" 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="-getfield--aggregation-"> </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="#definition" target="_self"> <span> Definition </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#syntax" target="_self"> <span> Syntax </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#behavior" target="_self"> <span> Behavior </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#examples" target="_self"> <span> Examples </span> </a> </li> </ul> </div> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Definition <a class="headerlink leafygreen-ui-1kepx47" href="#definition" 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="definition"> </div> </a> </h2> <dl class="expression"> <dt> <code class="leafygreen-ui-1l06pbn"> $getField </code> <a class="headerlink leafygreen-ui-1kepx47" href="#mongodb-expression-exp.-getField" title="Permalink to this definition"> <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="mongodb-expression-exp.-getField"> </div> </a> </dt> <dd> <div> <p> <em> New <!-- --> in version <!-- --> 5.0 </em> . </p> </div> <p class="leafygreen-ui-1kp3ins"> Returns the value of a specified field from a document. If you don't specify an object, <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-expression-exp.-getField" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $getField </code> </span> </a> returns the value of the field from <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/aggregation-variables/#mongodb-variable-variable.CURRENT"> <code class="leafygreen-ui-1l06pbn"> $$CURRENT </code> . </a> </p> <p class="leafygreen-ui-1kp3ins"> You can use <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-expression-exp.-getField" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $getField </code> </span> </a> to retrieve the value of fields with names that contain periods ( <code class="leafygreen-ui-1l06pbn"> . </code> ) or start with dollar signs ( <code class="leafygreen-ui-1l06pbn"> $ </code> ). </p> <div class="leafygreen-ui-13vw3ie" role="note"> <h2 class="leafygreen-ui-1fn4p2b"> Tip </h2> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> Use <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/setField/#mongodb-expression-exp.-setField"> <code class="leafygreen-ui-1l06pbn"> $setField </code> </a> to add or update fields with names that contain dollar signs ( <code class="leafygreen-ui-1l06pbn"> $ </code> ) or periods ( <code class="leafygreen-ui-1l06pbn"> . </code> ). </p> </div> </div> </dd> </dl> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Syntax <a class="headerlink leafygreen-ui-1kepx47" href="#syntax" 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="syntax"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-expression-exp.-getField" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $getField </code> </span> </a> has the following syntax: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{\n $getField: {\n field: &lt;string&gt;,\n input: &lt;object&gt;\n }\n}","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">$getField</span>: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">field</span>: &lt;<span class="lg-highlight-title lg-highlight-class">String</span>&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">input</span>: &lt;<span class="lg-highlight-title lg-highlight-class">Object</span>&gt;</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->}</td></tr><tr class=""><td class="leafygreen-ui-7razhx">}</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: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> Field </div> </div> </th> <th class="leafygreen-ui-13uteka" role="columnheader" scope="col"> <div class="leafygreen-ui-ui0te9"> <div> Type </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> <code class="leafygreen-ui-1l06pbn"> field </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> String </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <p class="leafygreen-ui-1kp3ins"> Field in the <code class="leafygreen-ui-1l06pbn"> input </code> object for which you want to return a value. <code class="leafygreen-ui-1l06pbn"> field </code> can be any valid <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/#std-label-aggregation-expressions"> expression </a> that resolves to a string. </p> <p class="leafygreen-ui-1kp3ins"> If <code class="leafygreen-ui-1l06pbn"> field </code> begins with a dollar sign ( <code class="leafygreen-ui-1l06pbn"> $ </code> ), place the field name inside of a <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/literal/#mongodb-expression-exp.-literal"> <code class="leafygreen-ui-1l06pbn"> $literal </code> </a> or <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/toString/#mongodb-expression-exp.-toString"> <code class="leafygreen-ui-1l06pbn"> $toString </code> </a> expression to return its value. </p> </div> </div> </td> </tr> <tr class=""> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> input </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Object </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <p class="leafygreen-ui-1kp3ins"> <em> Default </em> : <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/aggregation-variables/#mongodb-variable-variable.CURRENT"> <code class="leafygreen-ui-1l06pbn"> $$CURRENT </code> </a> </p> <p class="leafygreen-ui-1kp3ins"> A valid <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/#std-label-aggregation-expressions"> expression </a> that contains the <code class="leafygreen-ui-1l06pbn"> field </code> for which you want to return a value. <code class="leafygreen-ui-1l06pbn"> input </code> must resolve to an object, <code class="leafygreen-ui-1l06pbn"> missing </code> , <code class="leafygreen-ui-1l06pbn"> null </code> , or <code class="leafygreen-ui-1l06pbn"> undefined </code> . If omitted, defaults to the document currently being processed in the pipeline ( <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/aggregation-variables/#mongodb-variable-variable.CURRENT"> <code class="leafygreen-ui-1l06pbn"> $$CURRENT </code> </a> ). </p> </div> </div> </td> </tr> </tbody> </table> </div> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-expression-exp.-getField" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $getField </code> </span> </a> has the following shorthand syntax for retrieving field values from <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/aggregation-variables/#mongodb-variable-variable.CURRENT"> <code class="leafygreen-ui-1l06pbn"> $$CURRENT </code> : </a> </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{\n $getField: &lt;string&gt;\n}","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">$getField</span>: &lt;<span class="lg-highlight-title lg-highlight-class">String</span>&gt;</td></tr><tr class=""><td class="leafygreen-ui-7razhx">}</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"> For this syntax, the argument is equivalent to the value of <code class="leafygreen-ui-1l06pbn"> field </code> described above. </p> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Behavior <a class="headerlink leafygreen-ui-1kepx47" href="#behavior" 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="behavior"> </div> </a> </h2> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> If the <code class="leafygreen-ui-1l06pbn"> field </code> that you specify is not present in the <code class="leafygreen-ui-1l06pbn"> input </code> object, or in <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/aggregation-variables/#mongodb-variable-variable.CURRENT"> <code class="leafygreen-ui-1l06pbn"> $$CURRENT </code> </a> if you don't specify an <code class="leafygreen-ui-1l06pbn"> input </code> object, <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-expression-exp.-getField" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $getField </code> </span> </a> returns <code class="leafygreen-ui-1l06pbn"> missing </code> . </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> If <code class="leafygreen-ui-1l06pbn"> input </code> evaluates to <code class="leafygreen-ui-1l06pbn"> missing </code> , <code class="leafygreen-ui-1l06pbn"> undefined </code> , or <code class="leafygreen-ui-1l06pbn"> null </code> , <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-expression-exp.-getField" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $getField </code> </span> </a> returns <code class="leafygreen-ui-1l06pbn"> null </code> . </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> If <code class="leafygreen-ui-1l06pbn"> input </code> evaluates to anything other than an object, <code class="leafygreen-ui-1l06pbn"> missing </code> , <code class="leafygreen-ui-1l06pbn"> undefined </code> , or <code class="leafygreen-ui-1l06pbn"> null </code> , <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-expression-exp.-getField" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $getField </code> </span> </a> returns an error. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-expression-exp.-getField" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $getField </code> </span> </a> doesn't implicitly traverse objects or arrays. For example, <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-expression-exp.-getField" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $getField </code> </span> </a> evaluates a <code class="leafygreen-ui-1l06pbn"> field </code> value of <code class="leafygreen-ui-1l06pbn"> a.b.c </code> as a top-level field <code class="leafygreen-ui-1l06pbn"> a.b.c </code> instead of a nested field <code class="leafygreen-ui-1l06pbn"> { a: { b: { c: } } } </code> . </p> </li> </ul> <div class="leafygreen-ui-13vw3ie" role="note"> <h2 class="leafygreen-ui-1fn4p2b"> Tip </h2> <h3 class="leafygreen-ui-144d5kf"> <strong> See also: </strong> </h3> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/dot-dollar-considerations/#std-label-crud-concepts-dot-dollar-considerations"> Considerations for field names </a> </p> </div> </div> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Examples <a class="headerlink leafygreen-ui-1kepx47" href="#examples" 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="examples"> </div> </a> </h2> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Query Fields that Contain Periods ( <code class="leafygreen-ui-1l06pbn"> . </code> ) <a class="headerlink leafygreen-ui-1kepx47" href="#query-fields-that-contain-periods--.-" 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="query-fields-that-contain-periods--.-"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> Consider an <code class="leafygreen-ui-1l06pbn"> inventory </code> collection with the following documents: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ \"_id\" : 1, \"item\" : \"sweatshirt\", \"price.usd\": 45.99, qty: 300 }\n{ \"_id\" : 2, \"item\" : \"winter coat\", \"price.usd\": 499.99, qty: 200 }\n{ \"_id\" : 3, \"item\" : \"sun dress\", \"price.usd\": 199.99, qty: 250 }\n{ \"_id\" : 4, \"item\" : \"leather boots\", \"price.usd\": 249.99, qty: 300 }\n{ \"_id\" : 5, \"item\" : \"bow tie\", \"price.usd\": 9.99, qty: 180 }","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">1</span>, <span class="lg-highlight-string">"item"</span> <!-- -->: <span class="lg-highlight-string">"sweatshirt"</span>, <span class="lg-highlight-string">"price.usd"</span>: <span class="lg-highlight-number">45.99</span>, <span class="lg-highlight-attr">qty</span>: <span class="lg-highlight-number">300</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">2</span>, <span class="lg-highlight-string">"item"</span> <!-- -->: <span class="lg-highlight-string">"winter coat"</span>, <span class="lg-highlight-string">"price.usd"</span>: <span class="lg-highlight-number">499.99</span>, <span class="lg-highlight-attr">qty</span>: <span class="lg-highlight-number">200</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">3</span>, <span class="lg-highlight-string">"item"</span> <!-- -->: <span class="lg-highlight-string">"sun dress"</span>, <span class="lg-highlight-string">"price.usd"</span>: <span class="lg-highlight-number">199.99</span>, <span class="lg-highlight-attr">qty</span>: <span class="lg-highlight-number">250</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">4</span>, <span class="lg-highlight-string">"item"</span> <!-- -->: <span class="lg-highlight-string">"leather boots"</span>, <span class="lg-highlight-string">"price.usd"</span>: <span class="lg-highlight-number">249.99</span>, <span class="lg-highlight-attr">qty</span>: <span class="lg-highlight-number">300</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">5</span>, <span class="lg-highlight-string">"item"</span> <!-- -->: <span class="lg-highlight-string">"bow tie"</span>, <span class="lg-highlight-string">"price.usd"</span>: <span class="lg-highlight-number">9.99</span>, <span class="lg-highlight-attr">qty</span>: <span class="lg-highlight-number">180</span> }</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 operation uses the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-expression-exp.-getField" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $getField </code> </span> </a> and <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/gt/#mongodb-expression-exp.-gt"> <code class="leafygreen-ui-1l06pbn"> $gt </code> </a> operators to find which products have a <code class="leafygreen-ui-1l06pbn"> price.usd </code> greater than <code class="leafygreen-ui-1l06pbn"> 200 </code> : </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.inventory.aggregate( [\n {\n $match:\n { $expr:\n { $gt: [ { $getField: \"price.usd\" }, 200 ] }\n }\n }\n] )","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">inventory</span>.<span class="lg-highlight-title lg-highlight-function">aggregate</span>( <!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">$match</span>:</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">$expr</span>:</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">$gt</span>: <!-- -->[ <!-- -->{ <span class="lg-highlight-attr">$getField</span>: <span class="lg-highlight-string">"price.usd"</span> }<!-- -->, <span class="lg-highlight-number">200</span> ] }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">] )</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 operation returns the following results: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"[\n { _id: 2, item: 'winter coat', qty: 200, 'price.usd': 499.99 },\n { _id: 4, item: 'leather boots', qty: 300, 'price.usd': 249.99 }\n]","programmingLanguage":"JavaScript"} </script> <div class="css-1lju8ps"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-tyg50d"> <pre class="leafygreen-ui-1453az5" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">2</span>, <span class="lg-highlight-attr">item</span>: <span class="lg-highlight-string">'winter coat'</span>, <span class="lg-highlight-attr">qty</span>: <span class="lg-highlight-number">200</span>, <span class="lg-highlight-string">'price.usd'</span>: <span class="lg-highlight-number">499.99</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">4</span>, <span class="lg-highlight-attr">item</span>: <span class="lg-highlight-string">'leather boots'</span>, <span class="lg-highlight-attr">qty</span>: <span class="lg-highlight-number">300</span>, <span class="lg-highlight-string">'price.usd'</span>: <span class="lg-highlight-number">249.99</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">]</td></tr></tbody></table></code></pre> </div> </div> </div> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Query Fields that Start with a Dollar Sign ( <code class="leafygreen-ui-1l06pbn"> $ </code> ) <a class="headerlink leafygreen-ui-1kepx47" href="#query-fields-that-start-with-a-dollar-sign----" 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="query-fields-that-start-with-a-dollar-sign----"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> Consider an <code class="leafygreen-ui-1l06pbn"> inventory </code> collection with the following documents: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ \"_id\" : 1, \"item\" : \"sweatshirt\", \"$price\": 45.99, qty: 300 }\n{ \"_id\" : 2, \"item\" : \"winter coat\", \"$price\": 499.99, qty: 200 }\n{ \"_id\" : 3, \"item\" : \"sun dress\", \"$price\": 199.99, qty: 250 }\n{ \"_id\" : 4, \"item\" : \"leather boots\", \"$price\": 249.99, qty: 300 }\n{ \"_id\" : 5, \"item\" : \"bow tie\", \"$price\": 9.99, qty: 180 }","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">1</span>, <span class="lg-highlight-string">"item"</span> <!-- -->: <span class="lg-highlight-string">"sweatshirt"</span>, <span class="lg-highlight-string">"$price"</span>: <span class="lg-highlight-number">45.99</span>, <span class="lg-highlight-attr">qty</span>: <span class="lg-highlight-number">300</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">2</span>, <span class="lg-highlight-string">"item"</span> <!-- -->: <span class="lg-highlight-string">"winter coat"</span>, <span class="lg-highlight-string">"$price"</span>: <span class="lg-highlight-number">499.99</span>, <span class="lg-highlight-attr">qty</span>: <span class="lg-highlight-number">200</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">3</span>, <span class="lg-highlight-string">"item"</span> <!-- -->: <span class="lg-highlight-string">"sun dress"</span>, <span class="lg-highlight-string">"$price"</span>: <span class="lg-highlight-number">199.99</span>, <span class="lg-highlight-attr">qty</span>: <span class="lg-highlight-number">250</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">4</span>, <span class="lg-highlight-string">"item"</span> <!-- -->: <span class="lg-highlight-string">"leather boots"</span>, <span class="lg-highlight-string">"$price"</span>: <span class="lg-highlight-number">249.99</span>, <span class="lg-highlight-attr">qty</span>: <span class="lg-highlight-number">300</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">5</span>, <span class="lg-highlight-string">"item"</span> <!-- -->: <span class="lg-highlight-string">"bow tie"</span>, <span class="lg-highlight-string">"$price"</span>: <span class="lg-highlight-number">9.99</span>, <span class="lg-highlight-attr">qty</span>: <span class="lg-highlight-number">180</span> }</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 operation uses the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-expression-exp.-getField" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $getField </code> </span> </a> , <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/gt/#mongodb-expression-exp.-gt"> <code class="leafygreen-ui-1l06pbn"> $gt </code> </a> , and <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/literal/#mongodb-expression-exp.-literal"> <code class="leafygreen-ui-1l06pbn"> $literal </code> </a> operators to find which products have a <code class="leafygreen-ui-1l06pbn"> $price </code> greater than <code class="leafygreen-ui-1l06pbn"> 200 </code> : </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.inventory.aggregate( [\n {\n $match:\n { $expr:\n { $gt: [ { $getField: {$literal: \"$price\" } }, 200 ] }\n }\n }\n] )","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><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">inventory</span>.<span class="lg-highlight-title lg-highlight-function">aggregate</span>( <!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">$match</span>:</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">$expr</span>:</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">$gt</span>: <!-- -->[ <!-- -->{ <span class="lg-highlight-attr">$getField</span>: <!-- -->{<span class="lg-highlight-attr">$literal</span>: <span class="lg-highlight-string">"$price"</span> } }<!-- -->, <span class="lg-highlight-number">200</span> ] }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">] )</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 operation returns the following results: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"[\n { _id: 2, item: 'winter coat', qty: 200, '$price': 499.99 },\n { _id: 4, item: 'leather boots', qty: 300, '$price': 249.99 }\n]","programmingLanguage":"JavaScript"} </script> <div class="css-1lju8ps"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-tyg50d"> <pre class="leafygreen-ui-1453az5" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">2</span>, <span class="lg-highlight-attr">item</span>: <span class="lg-highlight-string">'winter coat'</span>, <span class="lg-highlight-attr">qty</span>: <span class="lg-highlight-number">200</span>, <span class="lg-highlight-string">'$price'</span>: <span class="lg-highlight-number">499.99</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">4</span>, <span class="lg-highlight-attr">item</span>: <span class="lg-highlight-string">'leather boots'</span>, <span class="lg-highlight-attr">qty</span>: <span class="lg-highlight-number">300</span>, <span class="lg-highlight-string">'$price'</span>: <span class="lg-highlight-number">249.99</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">]</td></tr></tbody></table></code></pre> </div> </div> </div> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Query a Field in a Sub-document <a class="headerlink leafygreen-ui-1kepx47" href="#query-a-field-in-a-sub-document" 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="query-a-field-in-a-sub-document"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> Create an <code class="leafygreen-ui-1l06pbn"> inventory </code> collection with the following documents: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.inventory.insertMany( [\n { \"_id\" : 1, \"item\" : \"sweatshirt\", \"price.usd\": 45.99,\n \"quantity\": { \"$large\": 50, \"$medium\": 50, \"$small\": 25 }\n },\n { \"_id\" : 2, \"item\" : \"winter coat\", \"price.usd\": 499.99,\n \"quantity\": { \"$large\": 35, \"$medium\": 35, \"$small\": 35 }\n },\n { \"_id\" : 3, \"item\" : \"sun dress\", \"price.usd\": 199.99,\n \"quantity\": { \"$large\": 45, \"$medium\": 40, \"$small\": 5 }\n },\n { \"_id\" : 4, \"item\" : \"leather boots\", \"price.usd\": 249.99,\n \"quantity\": { \"$large\": 20, \"$medium\": 30, \"$small\": 40 }\n },\n { \"_id\" : 5, \"item\" : \"bow tie\", \"price.usd\": 9.99,\n \"quantity\": { \"$large\": 0, \"$medium\": 10, \"$small\": 75 }\n }\n] )","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><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">inventory</span>.<span class="lg-highlight-title lg-highlight-function">insertMany</span>( <!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">1</span>, <span class="lg-highlight-string">"item"</span> <!-- -->: <span class="lg-highlight-string">"sweatshirt"</span>, <span class="lg-highlight-string">"price.usd"</span>: <span class="lg-highlight-number">45.99</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"quantity"</span>: <!-- -->{ <span class="lg-highlight-string">"$large"</span>: <span class="lg-highlight-number">50</span>, <span class="lg-highlight-string">"$medium"</span>: <span class="lg-highlight-number">50</span>, <span class="lg-highlight-string">"$small"</span>: <span class="lg-highlight-number">25</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">2</span>, <span class="lg-highlight-string">"item"</span> <!-- -->: <span class="lg-highlight-string">"winter coat"</span>, <span class="lg-highlight-string">"price.usd"</span>: <span class="lg-highlight-number">499.99</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"quantity"</span>: <!-- -->{ <span class="lg-highlight-string">"$large"</span>: <span class="lg-highlight-number">35</span>, <span class="lg-highlight-string">"$medium"</span>: <span class="lg-highlight-number">35</span>, <span class="lg-highlight-string">"$small"</span>: <span class="lg-highlight-number">35</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">3</span>, <span class="lg-highlight-string">"item"</span> <!-- -->: <span class="lg-highlight-string">"sun dress"</span>, <span class="lg-highlight-string">"price.usd"</span>: <span class="lg-highlight-number">199.99</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"quantity"</span>: <!-- -->{ <span class="lg-highlight-string">"$large"</span>: <span class="lg-highlight-number">45</span>, <span class="lg-highlight-string">"$medium"</span>: <span class="lg-highlight-number">40</span>, <span class="lg-highlight-string">"$small"</span>: <span class="lg-highlight-number">5</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">4</span>, <span class="lg-highlight-string">"item"</span> <!-- -->: <span class="lg-highlight-string">"leather boots"</span>, <span class="lg-highlight-string">"price.usd"</span>: <span class="lg-highlight-number">249.99</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"quantity"</span>: <!-- -->{ <span class="lg-highlight-string">"$large"</span>: <span class="lg-highlight-number">20</span>, <span class="lg-highlight-string">"$medium"</span>: <span class="lg-highlight-number">30</span>, <span class="lg-highlight-string">"$small"</span>: <span class="lg-highlight-number">40</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">5</span>, <span class="lg-highlight-string">"item"</span> <!-- -->: <span class="lg-highlight-string">"bow tie"</span>, <span class="lg-highlight-string">"price.usd"</span>: <span class="lg-highlight-number">9.99</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"quantity"</span>: <!-- -->{ <span class="lg-highlight-string">"$large"</span>: <span class="lg-highlight-number">0</span>, <span class="lg-highlight-string">"$medium"</span>: <span class="lg-highlight-number">10</span>, <span class="lg-highlight-string">"$small"</span>: <span class="lg-highlight-number">75</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">] )</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 operation returns documents where the number of <code class="leafygreen-ui-1l06pbn"> $small </code> items is less than or equal to <code class="leafygreen-ui-1l06pbn"> 20 </code> . </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.inventory.aggregate( [\n { $match:\n { $expr:\n { $lte:\n [\n { $getField:\n { field: { $literal: \"$small\" },\n input: \"$quantity\"\n }\n },\n 20\n ]\n }\n }\n }\n] )","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">inventory</span>.<span class="lg-highlight-title lg-highlight-function">aggregate</span>( <!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">$match</span>:</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">$expr</span>:</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">$lte</span>:</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->[</td></tr><tr class="leafygreen-ui-1wr1lm6"><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">$getField</span>:</td></tr><tr class="leafygreen-ui-1wr1lm6"><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">field</span>: <!-- -->{ <span class="lg-highlight-attr">$literal</span>: <span class="lg-highlight-string">"$small"</span> }<!-- -->,</td></tr><tr class="leafygreen-ui-1wr1lm6"><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">input</span>: <span class="lg-highlight-string">"$quantity"</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-number">20</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> ]</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">] )</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"> Use these operators to query the collection: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> The <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/lte/#mongodb-expression-exp.-lte"> <code class="leafygreen-ui-1l06pbn"> $lte </code> </a> operator finds values less than or equal to 20. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-expression-exp.-getField" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $getField </code> </span> </a> requires explicit <code class="leafygreen-ui-1l06pbn"> field </code> and <code class="leafygreen-ui-1l06pbn"> input </code> parameters because the <code class="leafygreen-ui-1l06pbn"> $small </code> field is part of a sub-document. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-expression-exp.-getField" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $getField </code> </span> </a> uses <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/literal/#mongodb-expression-exp.-literal"> <code class="leafygreen-ui-1l06pbn"> $literal </code> </a> to evaluate " <code class="leafygreen-ui-1l06pbn"> $small </code> ", because the field name has a dollar sign ( <code class="leafygreen-ui-1l06pbn"> $ </code> ) in it. </p> </li> </ul> <p class="leafygreen-ui-1kp3ins"> Example output: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"[\n {\n _id: 3,\n item: 'sun dress',\n 'price.usd': 199.99,\n quantity: { '$large': 45, '$medium': 40, '$small': 5 }\n }\n]","programmingLanguage":"JavaScript"} </script> <div class="css-1lju8ps"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1jheeh3"> <pre class="leafygreen-ui-1453az5" 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">[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">3</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">item</span>: <span class="lg-highlight-string">'sun dress'</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">'price.usd'</span>: <span class="lg-highlight-number">199.99</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">quantity</span>: <!-- -->{ <span class="lg-highlight-string">'$large'</span>: <span class="lg-highlight-number">45</span>, <span class="lg-highlight-string">'$medium'</span>: <span class="lg-highlight-number">40</span>, <span class="lg-highlight-string">'$small'</span>: <span class="lg-highlight-number">5</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">]</td></tr></tbody></table></code></pre> </div> </div> </div> </section> </section> </section>
https://www.mongodb.com/docs/manual/reference/operator/aggregation/derivative/
<section> <h1 class="contains-headerlink leafygreen-ui-41fr9s" weight="medium"> $derivative (aggregation) <a class="headerlink leafygreen-ui-1kepx47" href="#-derivative--aggregation-" 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="-derivative--aggregation-"> </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="#definition" target="_self"> <span> Definition </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#behavior" target="_self"> <span> Behavior </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#example" target="_self"> <span> Example </span> </a> </li> </ul> </div> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Definition <a class="headerlink leafygreen-ui-1kepx47" href="#definition" 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="definition"> </div> </a> </h2> <div> <p> <em> New <!-- --> in version <!-- --> 5.0 </em> . </p> </div> <dl class="group"> <dt> <code class="leafygreen-ui-1l06pbn"> $derivative </code> <a class="headerlink leafygreen-ui-1kepx47" href="#mongodb-group-grp.-derivative" title="Permalink to this definition"> <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="mongodb-group-grp.-derivative"> </div> </a> </dt> <dd> </dd> </dl> <p class="leafygreen-ui-1kp3ins"> Returns the average rate of change within the specified <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/setWindowFields/#std-label-setWindowFields-window"> window </a> , which is calculated using the: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> First and last documents in the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/setWindowFields/#mongodb-pipeline-pipe.-setWindowFields"> <code class="leafygreen-ui-1l06pbn"> $setWindowFields </code> </a> stage <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/setWindowFields/#std-label-setWindowFields-window"> window <!-- --> . </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Numerator, which is set to the result of subtracting the numeric <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/#std-label-aggregation-expressions"> expression </a> value for the first document from the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/#std-label-aggregation-expressions"> expression </a> value for the last document. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Denominator, which is set to the result of subtracting the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/setWindowFields/#std-label-setWindowFields-sortBy"> sortBy </a> field value for the first document from the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/setWindowFields/#std-label-setWindowFields-sortBy"> sortBy </a> field value for the last document. </p> </li> </ul> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-group-grp.-derivative" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $derivative </code> </span> </a> is only available in the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/setWindowFields/#mongodb-pipeline-pipe.-setWindowFields"> <code class="leafygreen-ui-1l06pbn"> $setWindowFields </code> </a> stage. You must specify a <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/setWindowFields/#std-label-setWindowFields-window"> window </a> in the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/setWindowFields/#mongodb-pipeline-pipe.-setWindowFields"> <code class="leafygreen-ui-1l06pbn"> $setWindowFields </code> </a> stage when using <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-group-grp.-derivative" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $derivative </code> . </span> </a> </p> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-group-grp.-derivative" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $derivative </code> </span> </a> syntax: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{\n $derivative: {\n input: &lt;expression&gt;,\n unit: <time>\n }\n}</time>"} </script> <div class="css-1lju8ps"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1jheeh3"> <pre class="leafygreen-ui-1453az5" tabindex="-1"><code class="lg-highlight-hljs-light none leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> $derivative: {</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> input: &lt;expression&gt;,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> unit: &lt;time unit&gt;</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">}</td></tr></tbody></table></code></pre> </div> </div> </div> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-group-grp.-derivative" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $derivative </code> </span> </a> takes a document with these fields: </p> <div class="leafygreen-ui-skkc39" tabindex="0"> <table class="leafygreen-ui-hr8lsv"> <colgroup> <col style="width:15%"/> <col style="width:85%"/> </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> Field </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="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-derivative-input" target="_self"> <span> input </span> </a> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <span class="leafygreen-ui-1qnjd6d" id="std-label-derivative-input"> </span> <p class="leafygreen-ui-1kp3ins"> Specifies the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/#std-label-aggregation-expressions"> expression </a> to evaluate. The expression must evaluate to a number. </p> </div> </div> </td> </tr> <tr class=""> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-derivative-unit" target="_self"> <span> unit </span> </a> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <span class="leafygreen-ui-1qnjd6d" id="std-label-derivative-unit"> </span> <p class="leafygreen-ui-1kp3ins"> A <code class="leafygreen-ui-1l06pbn"> string </code> that specifies the time unit. Use one of these strings: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <code class="leafygreen-ui-1l06pbn"> "week" </code> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <code class="leafygreen-ui-1l06pbn"> "day" </code> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <code class="leafygreen-ui-1l06pbn"> "hour" </code> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <code class="leafygreen-ui-1l06pbn"> "minute" </code> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <code class="leafygreen-ui-1l06pbn"> "second" </code> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <code class="leafygreen-ui-1l06pbn"> "millisecond" </code> </p> </li> </ul> <p class="leafygreen-ui-1kp3ins"> If the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/setWindowFields/#std-label-setWindowFields-sortBy"> sortBy </a> field is not a date, you must omit a <code class="leafygreen-ui-1l06pbn"> unit </code> . If you specify a <code class="leafygreen-ui-1l06pbn"> unit </code> , you must specify a date in the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/setWindowFields/#std-label-setWindowFields-sortBy"> sortBy </a> field. </p> </div> </div> </td> </tr> </tbody> </table> </div> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Behavior <a class="headerlink leafygreen-ui-1kepx47" href="#behavior" 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="behavior"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> You must specify a <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/setWindowFields/#std-label-setWindowFields-window"> window </a> in the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/setWindowFields/#mongodb-pipeline-pipe.-setWindowFields"> <code class="leafygreen-ui-1l06pbn"> $setWindowFields </code> </a> stage when using <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-group-grp.-derivative" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $derivative </code> . </span> </a> </p> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Example <a class="headerlink leafygreen-ui-1kepx47" href="#example" 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="example"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> Create a <code class="leafygreen-ui-1l06pbn"> deliveryFleet </code> collection that contains odometer readings for delivery trucks recorded at 30 second intervals: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.deliveryFleet.insertMany( [\n { truckID: \"1\", timeStamp: new Date( \"2020-05-18T14:10:30Z\" ), miles: 1295.1 },\n { truckID: \"1\", timeStamp: new Date( \"2020-05-18T14:11:00Z\" ), miles: 1295.63 },\n { truckID: \"1\", timeStamp: new Date( \"2020-05-18T14:11:30Z\" ), miles: 1296.25 },\n { truckID: \"1\", timeStamp: new Date( \"2020-05-18T14:12:00Z\" ), miles: 1296.76 },\n { truckID: \"2\", timeStamp: new Date( \"2020-05-18T14:10:30Z\" ), miles: 10234.1 },\n { truckID: \"2\", timeStamp: new Date( \"2020-05-18T14:11:00Z\" ), miles: 10234.33 },\n { truckID: \"2\", timeStamp: new Date( \"2020-05-18T14:11:30Z\" ), miles: 10234.73 },\n { truckID: \"2\", timeStamp: new Date( \"2020-05-18T14:12:00Z\" ), miles: 10235.13 }\n] )","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><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">deliveryFleet</span>.<span class="lg-highlight-title lg-highlight-function">insertMany</span>( <!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">truckID</span>: <span class="lg-highlight-string">"1"</span>, <span class="lg-highlight-attr">timeStamp</span>: <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">Date</span>( <span class="lg-highlight-string">"2020-05-18T14:10:30Z"</span> )<!-- -->, <span class="lg-highlight-attr">miles</span>: <span class="lg-highlight-number">1295.1</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">truckID</span>: <span class="lg-highlight-string">"1"</span>, <span class="lg-highlight-attr">timeStamp</span>: <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">Date</span>( <span class="lg-highlight-string">"2020-05-18T14:11:00Z"</span> )<!-- -->, <span class="lg-highlight-attr">miles</span>: <span class="lg-highlight-number">1295.63</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">truckID</span>: <span class="lg-highlight-string">"1"</span>, <span class="lg-highlight-attr">timeStamp</span>: <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">Date</span>( <span class="lg-highlight-string">"2020-05-18T14:11:30Z"</span> )<!-- -->, <span class="lg-highlight-attr">miles</span>: <span class="lg-highlight-number">1296.25</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">truckID</span>: <span class="lg-highlight-string">"1"</span>, <span class="lg-highlight-attr">timeStamp</span>: <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">Date</span>( <span class="lg-highlight-string">"2020-05-18T14:12:00Z"</span> )<!-- -->, <span class="lg-highlight-attr">miles</span>: <span class="lg-highlight-number">1296.76</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">truckID</span>: <span class="lg-highlight-string">"2"</span>, <span class="lg-highlight-attr">timeStamp</span>: <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">Date</span>( <span class="lg-highlight-string">"2020-05-18T14:10:30Z"</span> )<!-- -->, <span class="lg-highlight-attr">miles</span>: <span class="lg-highlight-number">10234.1</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">truckID</span>: <span class="lg-highlight-string">"2"</span>, <span class="lg-highlight-attr">timeStamp</span>: <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">Date</span>( <span class="lg-highlight-string">"2020-05-18T14:11:00Z"</span> )<!-- -->, <span class="lg-highlight-attr">miles</span>: <span class="lg-highlight-number">10234.33</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">truckID</span>: <span class="lg-highlight-string">"2"</span>, <span class="lg-highlight-attr">timeStamp</span>: <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">Date</span>( <span class="lg-highlight-string">"2020-05-18T14:11:30Z"</span> )<!-- -->, <span class="lg-highlight-attr">miles</span>: <span class="lg-highlight-number">10234.73</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">truckID</span>: <span class="lg-highlight-string">"2"</span>, <span class="lg-highlight-attr">timeStamp</span>: <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">Date</span>( <span class="lg-highlight-string">"2020-05-18T14:12:00Z"</span> )<!-- -->, <span class="lg-highlight-attr">miles</span>: <span class="lg-highlight-number">10235.13</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">] )</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"> This example uses <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-group-grp.-derivative" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $derivative </code> </span> </a> in the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/setWindowFields/#mongodb-pipeline-pipe.-setWindowFields"> <code class="leafygreen-ui-1l06pbn"> $setWindowFields </code> </a> stage to obtain the average speed in miles per hour for each truck, and the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/match/#mongodb-pipeline-pipe.-match"> <code class="leafygreen-ui-1l06pbn"> $match </code> </a> stage to filter the results to trucks whose speed exceeded 50 miles per hour: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.deliveryFleet.aggregate( [\n {\n $setWindowFields: {\n partitionBy: \"$truckID\",\n sortBy: { timeStamp: 1 },\n output: {\n truckAverageSpeed: {\n $derivative: {\n input: \"$miles\",\n unit: \"hour\"\n },\n window: {\n range: [ -30, 0 ],\n unit: \"second\"\n }\n }\n }\n }\n },\n {\n $match: {\n truckAverageSpeed: {\n $gt: 50\n }\n }\n }\n] )","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">deliveryFleet</span>.<span class="lg-highlight-title lg-highlight-function">aggregate</span>( <!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">$setWindowFields</span>: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">partitionBy</span>: <span class="lg-highlight-string">"$truckID"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">sortBy</span>: <!-- -->{ <span class="lg-highlight-attr">timeStamp</span>: <span class="lg-highlight-number">1</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">output</span>: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">truckAverageSpeed</span>: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">$derivative</span>: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">input</span>: <span class="lg-highlight-string">"$miles"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">unit</span>: <span class="lg-highlight-string">"hour"</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">window</span>: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">range</span>: <!-- -->[ <!-- -->-<span class="lg-highlight-number">30</span>, <span class="lg-highlight-number">0</span> ]<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">unit</span>: <span class="lg-highlight-string">"second"</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">$match</span>: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">truckAverageSpeed</span>: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">$gt</span>: <span class="lg-highlight-number">50</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">] )</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"> In the example: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> The <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/setWindowFields/#mongodb-pipeline-pipe.-setWindowFields"> <code class="leafygreen-ui-1l06pbn"> $setWindowFields </code> </a> stage obtains the average speed in miles per hour for each truck: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <code class="leafygreen-ui-1l06pbn"> partitionBy: "$truckID" </code> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/setWindowFields/#std-label-setWindowFields-partitionBy"> partitions </a> the documents in the collection by <code class="leafygreen-ui-1l06pbn"> truckID </code> . </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <code class="leafygreen-ui-1l06pbn"> sortBy: { timeStamp: 1 } </code> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/setWindowFields/#std-label-setWindowFields-sortBy"> sorts </a> the documents in each partition by <code class="leafygreen-ui-1l06pbn"> timeStamp </code> in ascending order ( <code class="leafygreen-ui-1l06pbn"> 1 </code> ), so the earliest odometer reading is first. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <code class="leafygreen-ui-1l06pbn"> output </code> sets the <code class="leafygreen-ui-1l06pbn"> miles </code> derivative value in a new field called <code class="leafygreen-ui-1l06pbn"> truckAverageSpeed </code> using <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-group-grp.-derivative" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $derivative </code> </span> </a> that is run in a <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/setWindowFields/#std-label-setWindowFields-range"> range </a> window. </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> The <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-derivative-input" target="_self"> <span> input </span> </a> expression is set to <code class="leafygreen-ui-1l06pbn"> "$miles" </code> , which is used in the numerator for the derivative calculation. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> The <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-group-grp.-derivative" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $derivative </code> </span> </a> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-derivative-unit" target="_self"> <span> unit </span> </a> is set to <code class="leafygreen-ui-1l06pbn"> "hour" </code> for the <code class="leafygreen-ui-1l06pbn"> timeStamp </code> field, which is used in the denominator for the derivative calculation. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> The <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/setWindowFields/#std-label-setWindowFields-window"> window </a> contains the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/setWindowFields/#std-label-setWindowFields-range"> range </a> between a lower limit of <code class="leafygreen-ui-1l06pbn"> -30 </code> seconds (the previous 30 seconds from the current document in the output) and <code class="leafygreen-ui-1l06pbn"> 0 </code> seconds (matches the current document's <code class="leafygreen-ui-1l06pbn"> timeStamp </code> value in the output). This means <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-group-grp.-derivative" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $derivative </code> </span> </a> returns the average speed for each truck in miles per hour in the 30 second window. </p> </li> </ul> </li> </ul> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> The <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/match/#mongodb-pipeline-pipe.-match"> <code class="leafygreen-ui-1l06pbn"> $match </code> </a> stage uses the greater than operator <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/gt/#mongodb-expression-exp.-gt"> <code class="leafygreen-ui-1l06pbn"> $gt </code> </a> to filter the results to trucks whose speed exceeded 50 miles per hour. </p> </li> </ul> <p class="leafygreen-ui-1kp3ins"> In the following example output, the speed for truck 1 is shown in the <code class="leafygreen-ui-1l06pbn"> truckAverageSpeed </code> field. The speed for truck 2 is not shown because truck 2 did not exceed 50 miles per hour. </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ \"_id\" : ObjectId(\"60cb8a7e833dfeadc8e6285c\"), \"truckID\" : \"1\",\n \"timeStamp\" : ISODate(\"2020-05-18T14:11:00Z\"), \"miles\" : 1295.63,\n \"truckAverageSpeed\" : 63.60000000002401 }\n{ \"_id\" : ObjectId(\"60cb8a7e833dfeadc8e6285d\"), \"truckID\" : \"1\",\n \"timeStamp\" : ISODate(\"2020-05-18T14:11:30Z\"), \"miles\" : 1296.25,\n \"truckAverageSpeed\" : 74.3999999999869 }\n{ \"_id\" : ObjectId(\"60cb8a7e833dfeadc8e6285e\"), \"truckID\" : \"1\",\n \"timeStamp\" : ISODate(\"2020-05-18T14:12:00Z\"), \"miles\" : 1296.76,\n \"truckAverageSpeed\" : 61.199999999998916 }","programmingLanguage":"JavaScript"} </script> <div class="css-1lju8ps"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-tyg50d"> <pre class="leafygreen-ui-1453az5" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">ObjectId</span>(<span class="lg-highlight-string">"60cb8a7e833dfeadc8e6285c"</span>)<!-- -->, <span class="lg-highlight-string">"truckID"</span> <!-- -->: <span class="lg-highlight-string">"1"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"timeStamp"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">ISODate</span>(<span class="lg-highlight-string">"2020-05-18T14:11:00Z"</span>)<!-- -->, <span class="lg-highlight-string">"miles"</span> <!-- -->: <span class="lg-highlight-number">1295.63</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"truckAverageSpeed"</span> <!-- -->: <span class="lg-highlight-number">63.60000000002401</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">ObjectId</span>(<span class="lg-highlight-string">"60cb8a7e833dfeadc8e6285d"</span>)<!-- -->, <span class="lg-highlight-string">"truckID"</span> <!-- -->: <span class="lg-highlight-string">"1"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"timeStamp"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">ISODate</span>(<span class="lg-highlight-string">"2020-05-18T14:11:30Z"</span>)<!-- -->, <span class="lg-highlight-string">"miles"</span> <!-- -->: <span class="lg-highlight-number">1296.25</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"truckAverageSpeed"</span> <!-- -->: <span class="lg-highlight-number">74.3999999999869</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">ObjectId</span>(<span class="lg-highlight-string">"60cb8a7e833dfeadc8e6285e"</span>)<!-- -->, <span class="lg-highlight-string">"truckID"</span> <!-- -->: <span class="lg-highlight-string">"1"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"timeStamp"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">ISODate</span>(<span class="lg-highlight-string">"2020-05-18T14:12:00Z"</span>)<!-- -->, <span class="lg-highlight-string">"miles"</span> <!-- -->: <span class="lg-highlight-number">1296.76</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"truckAverageSpeed"</span> <!-- -->: <span class="lg-highlight-number">61.199999999998916</span> }</td></tr></tbody></table></code></pre> </div> </div> </div> </section> </section>
https://www.mongodb.com/docs/manual/reference/method/js-cursor/
<section> <h1 class="contains-headerlink leafygreen-ui-41fr9s" weight="medium"> Cursor Methods <a class="headerlink leafygreen-ui-1kepx47" href="#cursor-methods" 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="cursor-methods"> </div> </a> </h1> <div class="leafygreen-ui-15mdk4" role="note"> <h2 class="leafygreen-ui-6n7b7d"> Note </h2> <h3 class="leafygreen-ui-144d5kf"> <strong> mongosh Methods </strong> </h3> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> The methods listed on this table of contents page are <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/mongodb-shell/#mongodb-binary-bin.mongosh" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongosh </code> </span> </a> methods. This is <em> not </em> the documentation for <code class="leafygreen-ui-1l06pbn"> Node.js </code> or other programming language specific driver methods. </p> <p class="leafygreen-ui-1kp3ins"> In most cases, <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/mongodb-shell/#mongodb-binary-bin.mongosh" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongosh </code> </span> </a> methods work the same way as the legacy <code class="leafygreen-ui-1l06pbn"> mongo </code> shell methods. However, some legacy methods are unavailable in <code class="leafygreen-ui-1l06pbn"> mongosh </code> . </p> <p class="leafygreen-ui-1kp3ins"> For MongoDB API drivers, refer to the language specific <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/drivers/" target="_self"> <span> MongoDB driver </span> </a> documentation. </p> </div> </div> <p class="leafygreen-ui-1kp3ins"> These methods modify the way that the underlying query is executed. </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 method, including syntax and examples, click on the link to the method's reference page. </p> </div> </div> <div class="leafygreen-ui-skkc39" tabindex="0"> <table class="leafygreen-ui-hr8lsv"> <colgroup> <col style="width:30%"/> <col style="width:70%"/> </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> Name </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/method/cursor.addOption/#mongodb-method-cursor.addOption"> <code class="leafygreen-ui-1l06pbn"> cursor.addOption() </code> </a> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Adds special wire protocol flags that modify the behavior of the query. </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/method/cursor.allowDiskUse/#mongodb-method-cursor.allowDiskUse"> <code class="leafygreen-ui-1l06pbn"> cursor.allowDiskUse() </code> </a> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Allows MongoDB to use temporary files on disk to store data exceeding the 100 megabyte system memory limit while processing a blocking sort operation. </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/method/cursor.allowPartialResults/#mongodb-method-cursor.allowPartialResults"> <code class="leafygreen-ui-1l06pbn"> cursor.allowPartialResults() </code> </a> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Allows <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/db.collection.find/#mongodb-method-db.collection.find"> <code class="leafygreen-ui-1l06pbn"> db.collection.find() </code> </a> operations against a sharded collection to return partial results, rather than an error, if one or more queried shards are unavailable. </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/method/cursor.batchSize/#mongodb-method-cursor.batchSize"> <code class="leafygreen-ui-1l06pbn"> cursor.batchSize() </code> </a> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Controls the number of documents MongoDB will return to the client in a single network message. </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/method/cursor.close/#mongodb-method-cursor.close"> <code class="leafygreen-ui-1l06pbn"> cursor.close() </code> </a> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Close a cursor and free associated server resources. </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/method/cursor.isClosed/#mongodb-method-cursor.isClosed"> <code class="leafygreen-ui-1l06pbn"> cursor.isClosed() </code> </a> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Returns <code class="leafygreen-ui-1l06pbn"> true </code> if the cursor is closed. </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/method/cursor.collation/#mongodb-method-cursor.collation"> <code class="leafygreen-ui-1l06pbn"> cursor.collation() </code> </a> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Specifies the collation for the cursor returned by the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/db.collection.find/#mongodb-method-db.collection.find"> <code class="leafygreen-ui-1l06pbn"> db.collection.find() </code> . </a> </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/method/cursor.comment/#mongodb-method-cursor.comment"> <code class="leafygreen-ui-1l06pbn"> cursor.comment() </code> </a> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Attaches a comment to the query to allow for traceability in the logs and the system.profile 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/method/cursor.count/#mongodb-method-cursor.count"> <code class="leafygreen-ui-1l06pbn"> cursor.count() </code> </a> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Modifies the cursor to return the number of documents in the result set rather than the documents themselves. </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/method/cursor.explain/#mongodb-method-cursor.explain"> <code class="leafygreen-ui-1l06pbn"> cursor.explain() </code> </a> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Reports on the query execution plan for a cursor. </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/method/cursor.forEach/#mongodb-method-cursor.forEach"> <code class="leafygreen-ui-1l06pbn"> cursor.forEach() </code> </a> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Applies a JavaScript function for every document in a cursor. </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/method/cursor.hasNext/#mongodb-method-cursor.hasNext"> <code class="leafygreen-ui-1l06pbn"> cursor.hasNext() </code> </a> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Returns true if the cursor has documents and can be iterated. </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/method/cursor.hint/#mongodb-method-cursor.hint"> <code class="leafygreen-ui-1l06pbn"> cursor.hint() </code> </a> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Forces MongoDB to use a specific index for a query. </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/method/cursor.isExhausted/#mongodb-method-cursor.isExhausted"> <code class="leafygreen-ui-1l06pbn"> cursor.isExhausted() </code> </a> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Returns <code class="leafygreen-ui-1l06pbn"> true </code> if the cursor is closed <em> and </em> there are no objects remaining in the batch. </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/method/cursor.itcount/#mongodb-method-cursor.itcount"> <code class="leafygreen-ui-1l06pbn"> cursor.itcount() </code> </a> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Computes the total number of documents in the cursor client-side by fetching and iterating the 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/method/cursor.limit/#mongodb-method-cursor.limit"> <code class="leafygreen-ui-1l06pbn"> cursor.limit() </code> </a> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Constrains the size of a cursor's 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/method/cursor.map/#mongodb-method-cursor.map"> <code class="leafygreen-ui-1l06pbn"> cursor.map() </code> </a> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Applies a function to each document in a cursor and collects the return values in an array. </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/method/cursor.max/#mongodb-method-cursor.max"> <code class="leafygreen-ui-1l06pbn"> cursor.max() </code> </a> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Specifies an exclusive upper index bound for a cursor. For use with <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/cursor.hint/#mongodb-method-cursor.hint"> <code class="leafygreen-ui-1l06pbn"> cursor.hint() </code> </a> </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/method/cursor.maxAwaitTimeMS/#mongodb-method-cursor.maxAwaitTimeMS"> <code class="leafygreen-ui-1l06pbn"> cursor.maxAwaitTimeMS() </code> </a> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Specifies a limit in milliseconds to wait for the next query result update. </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/method/cursor.maxTimeMS/#mongodb-method-cursor.maxTimeMS"> <code class="leafygreen-ui-1l06pbn"> cursor.maxTimeMS() </code> </a> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Specifies a cumulative time limit in milliseconds for processing operations on a cursor. </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/method/cursor.min/#mongodb-method-cursor.min"> <code class="leafygreen-ui-1l06pbn"> cursor.min() </code> </a> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Specifies an inclusive lower index bound for a cursor. For use with <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/cursor.hint/#mongodb-method-cursor.hint"> <code class="leafygreen-ui-1l06pbn"> cursor.hint() </code> </a> </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/method/cursor.next/#mongodb-method-cursor.next"> <code class="leafygreen-ui-1l06pbn"> cursor.next() </code> </a> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Returns the next document in a cursor. </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/method/cursor.noCursorTimeout/#mongodb-method-cursor.noCursorTimeout"> <code class="leafygreen-ui-1l06pbn"> cursor.noCursorTimeout() </code> </a> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Instructs the server to avoid closing a cursor automatically after a period of inactivity. </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/method/cursor.objsLeftInBatch/#mongodb-method-cursor.objsLeftInBatch"> <code class="leafygreen-ui-1l06pbn"> cursor.objsLeftInBatch() </code> </a> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Returns the number of documents left in the current cursor batch. </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/method/cursor.pretty/#mongodb-method-cursor.pretty"> <code class="leafygreen-ui-1l06pbn"> cursor.pretty() </code> </a> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Configures the cursor to display results in an easy-to-read format. </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/method/cursor.readConcern/#mongodb-method-cursor.readConcern"> <code class="leafygreen-ui-1l06pbn"> cursor.readConcern() </code> </a> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Specifies a <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-read-concern"> read concern </a> for a <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/db.collection.find/#mongodb-method-db.collection.find"> <code class="leafygreen-ui-1l06pbn"> find() </code> </a> operation. </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/method/cursor.readPref/#mongodb-method-cursor.readPref"> <code class="leafygreen-ui-1l06pbn"> cursor.readPref() </code> </a> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Specifies a <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-read-preference"> read preference </a> to a cursor to control how the client directs queries to a <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-replica-set"> replica set <!-- --> . </a> </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/method/cursor.returnKey/#mongodb-method-cursor.returnKey"> <code class="leafygreen-ui-1l06pbn"> cursor.returnKey() </code> </a> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Modifies the cursor to return index keys rather than the 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/method/cursor.showRecordId/#mongodb-method-cursor.showRecordId"> <code class="leafygreen-ui-1l06pbn"> cursor.showRecordId() </code> </a> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Adds an internal storage engine ID field to each document returned by the cursor. </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/method/cursor.size/#mongodb-method-cursor.size"> <code class="leafygreen-ui-1l06pbn"> cursor.size() </code> </a> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Returns a count of the documents in the cursor after applying <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/cursor.skip/#mongodb-method-cursor.skip"> <code class="leafygreen-ui-1l06pbn"> skip() </code> </a> and <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/cursor.limit/#mongodb-method-cursor.limit"> <code class="leafygreen-ui-1l06pbn"> limit() </code> </a> methods. </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/method/cursor.skip/#mongodb-method-cursor.skip"> <code class="leafygreen-ui-1l06pbn"> cursor.skip() </code> </a> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Returns a cursor that begins returning results only after passing or skipping a number of 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/method/cursor.sort/#mongodb-method-cursor.sort"> <code class="leafygreen-ui-1l06pbn"> cursor.sort() </code> </a> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Returns results ordered according to a sort specification. </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/method/cursor.tailable/#mongodb-method-cursor.tailable"> <code class="leafygreen-ui-1l06pbn"> cursor.tailable() </code> </a> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Marks the cursor as tailable. Only valid for cursors over capped collections. </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/method/cursor.toArray/#mongodb-method-cursor.toArray"> <code class="leafygreen-ui-1l06pbn"> cursor.toArray() </code> </a> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Returns an array that contains all documents returned by the cursor. </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/method/cursor.tryNext/#mongodb-method-cursor.tryNext"> <code class="leafygreen-ui-1l06pbn"> cursor.tryNext() </code> </a> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Returns the next element in the iteration if available or else null. </div> </div> </td> </tr> </tbody> </table> </div> </section>
https://www.mongodb.com/docs/manual/reference/operator/aggregation/tsIncrement/
<section> <h1 class="contains-headerlink leafygreen-ui-41fr9s" weight="medium"> $tsIncrement (aggregation) <a class="headerlink leafygreen-ui-1kepx47" href="#-tsincrement--aggregation-" 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="-tsincrement--aggregation-"> </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="#definition" target="_self"> <span> Definition </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#behavior" target="_self"> <span> Behavior </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#examples" target="_self"> <span> Examples </span> </a> </li> </ul> </div> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Definition <a class="headerlink leafygreen-ui-1kepx47" href="#definition" 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="definition"> </div> </a> </h2> <dl class="expression"> <dt> <code class="leafygreen-ui-1l06pbn"> $tsIncrement </code> <a class="headerlink leafygreen-ui-1kepx47" href="#mongodb-expression-exp.-tsIncrement" title="Permalink to this definition"> <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="mongodb-expression-exp.-tsIncrement"> </div> </a> </dt> <dd> </dd> </dl> <div> <p> <em> New <!-- --> in version <!-- --> 5.1 </em> . </p> </div> <p class="leafygreen-ui-1kp3ins"> Returns the incrementing ordinal from a <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/bson-types/#std-label-document-bson-type-timestamp"> timestamp </a> as a <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/mongodb-extended-json-v1/#mongodb-bsontype-data_numberlong"> <code class="leafygreen-ui-1l06pbn"> long </code> . </a> </p> <p class="leafygreen-ui-1kp3ins"> When multiple events happen within the same second, the incrementing ordinal uniquely identifies each event. </p> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-expression-exp.-tsIncrement" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $tsIncrement </code> </span> </a> syntax: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ $tsIncrement: &lt;expression&gt; }"} </script> <div class="css-1lju8ps"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1jheeh3"> <pre class="leafygreen-ui-1agdxuk" tabindex="-1"><code class="lg-highlight-hljs-light none leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">{ $tsIncrement: &lt;expression&gt; }</td></tr></tbody></table></code></pre> </div> </div> </div> <p class="leafygreen-ui-1kp3ins"> The <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/#std-label-aggregation-expressions"> expression </a> must resolve to a <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/bson-types/#std-label-document-bson-type-timestamp"> timestamp <!-- --> . </a> </p> <div class="leafygreen-ui-13vw3ie" role="note"> <h2 class="leafygreen-ui-1fn4p2b"> Tip </h2> <h3 class="leafygreen-ui-144d5kf"> <strong> See also: </strong> </h3> <div class="leafygreen-ui-9mycqc"> <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/#std-label-aggregation-expressions"> Expression Operators </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/bson-types/#std-label-bson-types"> BSON Types </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/tsSecond/#mongodb-expression-exp.-tsSecond"> <code class="leafygreen-ui-1l06pbn"> $tsSecond </code> </a> </p> </li> </ul> </div> </div> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Behavior <a class="headerlink leafygreen-ui-1kepx47" href="#behavior" 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="behavior"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-expression-exp.-tsIncrement" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $tsIncrement </code> </span> </a> returns: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <code class="leafygreen-ui-1l06pbn"> Null </code> if the input <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/#std-label-aggregation-expressions"> expression </a> evaluates to <code class="leafygreen-ui-1l06pbn"> null </code> or refers to a field that is missing. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> An error if the input <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/#std-label-aggregation-expressions"> expression </a> does not evaluate to a <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/bson-types/#std-label-document-bson-type-timestamp"> timestamp <!-- --> . </a> </p> </li> </ul> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Examples <a class="headerlink leafygreen-ui-1kepx47" href="#examples" 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="examples"> </div> </a> </h2> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Obtain the Incrementing Ordinal from a Timestamp Field <a class="headerlink leafygreen-ui-1kepx47" href="#obtain-the-incrementing-ordinal-from-a-timestamp-field" 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="obtain-the-incrementing-ordinal-from-a-timestamp-field"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> Create a <code class="leafygreen-ui-1l06pbn"> stockSales </code> collection that contains company stock financial market sales: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.stockSales.insertMany( [\n { _id: 0, symbol: \"MDB\", saleTimestamp: Timestamp(1622731060, 1) },\n { _id: 1, symbol: \"MDB\", saleTimestamp: Timestamp(1622731060, 2) },\n { _id: 2, symbol: \"MSFT\", saleTimestamp: Timestamp(1714124193, 1) },\n { _id: 3, symbol: \"MSFT\", saleTimestamp: Timestamp(1714124193, 2) },\n { _id: 4, symbol: \"MSFT\", saleTimestamp: Timestamp(1714124193, 3) }\n] )","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><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">stockSales</span>.<span class="lg-highlight-title lg-highlight-function">insertMany</span>( <!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">0</span>, <span class="lg-highlight-attr">symbol</span>: <span class="lg-highlight-string">"MDB"</span>, <span class="lg-highlight-attr">saleTimestamp</span>: <span class="lg-highlight-title lg-highlight-class">Timestamp</span>(<span class="lg-highlight-number">1622731060</span>, <span class="lg-highlight-number">1</span>) }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">1</span>, <span class="lg-highlight-attr">symbol</span>: <span class="lg-highlight-string">"MDB"</span>, <span class="lg-highlight-attr">saleTimestamp</span>: <span class="lg-highlight-title lg-highlight-class">Timestamp</span>(<span class="lg-highlight-number">1622731060</span>, <span class="lg-highlight-number">2</span>) }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">2</span>, <span class="lg-highlight-attr">symbol</span>: <span class="lg-highlight-string">"MSFT"</span>, <span class="lg-highlight-attr">saleTimestamp</span>: <span class="lg-highlight-title lg-highlight-class">Timestamp</span>(<span class="lg-highlight-number">1714124193</span>, <span class="lg-highlight-number">1</span>) }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">3</span>, <span class="lg-highlight-attr">symbol</span>: <span class="lg-highlight-string">"MSFT"</span>, <span class="lg-highlight-attr">saleTimestamp</span>: <span class="lg-highlight-title lg-highlight-class">Timestamp</span>(<span class="lg-highlight-number">1714124193</span>, <span class="lg-highlight-number">2</span>) }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">4</span>, <span class="lg-highlight-attr">symbol</span>: <span class="lg-highlight-string">"MSFT"</span>, <span class="lg-highlight-attr">saleTimestamp</span>: <span class="lg-highlight-title lg-highlight-class">Timestamp</span>(<span class="lg-highlight-number">1714124193</span>, <span class="lg-highlight-number">3</span>) }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">] )</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"> In the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/bson-types/#std-label-document-bson-type-timestamp"> timestamp </a> constructor, the: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> First value is the number of seconds after the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://en.wikipedia.org/wiki/Unix_time" rel="noopener noreferrer"> <span> Unix epoch <!-- --> . </span> <svg alt="" aria-hidden="true" class="leafygreen-ui-1ie5kuq" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M13.823 2.4491C13.8201 2.30008 13.6999 2.17994 13.5509 2.17704L9.5062 2.09836C9.25654 2.09351 9.12821 2.39519 9.30482 2.5718L10.3856 3.65257L7.93433 6.10383C7.87964 6.15852 7.83047 6.21665 7.78683 6.27752L5.99909 8.06525C5.46457 8.59977 5.46457 9.4664 5.99909 10.0009C6.53361 10.5354 7.40023 10.5354 7.93475 10.0009L9.72249 8.21317C9.78336 8.16953 9.84148 8.12037 9.89618 8.06567L12.3474 5.61441L13.4282 6.69518C13.6048 6.87179 13.9065 6.74347 13.9016 6.4938L13.823 2.4491Z" fill="currentColor"> </path> <path d="M7.25 3.12893C7.66421 3.12893 8 3.46472 8 3.87893C8 4.29315 7.66421 4.62893 7.25 4.62893H4C3.72386 4.62893 3.5 4.85279 3.5 5.12893V11.9929C3.5 12.2691 3.72386 12.4929 4 12.4929H10.864C11.1401 12.4929 11.364 12.2691 11.364 11.9929V8.75C11.364 8.33579 11.6998 8 12.114 8C12.5282 8 12.864 8.33579 12.864 8.75V11.9929C12.864 13.0975 11.9686 13.9929 10.864 13.9929H4C2.89543 13.9929 2 13.0975 2 11.9929V5.12893C2 4.02436 2.89543 3.12893 4 3.12893H7.25Z" fill="currentColor"> </path> </svg> </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Second value is the incrementing ordinal. When multiple events happen within the same second, the incrementing ordinal uniquely identifies each event. </p> </li> </ul> <p class="leafygreen-ui-1kp3ins"> The following example uses <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-expression-exp.-tsIncrement" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $tsIncrement </code> </span> </a> in a <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 to return the incrementing ordinal from the stock sales <code class="leafygreen-ui-1l06pbn"> saleTimestamp </code> field: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.stockSales.aggregate( [\n {\n $project:\n {\n _id: 0, saleTimestamp: 1, saleIncrement: { $tsIncrement: \"$saleTimestamp\" }\n }\n }\n] )","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><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">stockSales</span>.<span class="lg-highlight-title lg-highlight-function">aggregate</span>( <!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">$project</span>:</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">0</span>, <span class="lg-highlight-attr">saleTimestamp</span>: <span class="lg-highlight-number">1</span>, <span class="lg-highlight-attr">saleIncrement</span>: <!-- -->{ <span class="lg-highlight-attr">$tsIncrement</span>: <span class="lg-highlight-string">"$saleTimestamp"</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">] )</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"> In the example, <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/project/#mongodb-pipeline-pipe.-project"> <code class="leafygreen-ui-1l06pbn"> $project </code> </a> only includes the <code class="leafygreen-ui-1l06pbn"> saleTimestamp </code> and <code class="leafygreen-ui-1l06pbn"> saleIncrement </code> fields as shown in the following output: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{\n saleTimestamp: Timestamp({ t: 1622731060, i: 1 }),\n saleIncrement: Long(\"1\")\n},\n{\n saleTimestamp: Timestamp({ t: 1622731060, i: 2 }),\n saleIncrement: Long(\"2\")\n},\n{\n saleTimestamp: Timestamp({ t: 1714124193, i: 1 }),\n saleIncrement: Long(\"1\")\n},\n{\n saleTimestamp: Timestamp({ t: 1714124193, i: 2 }),\n saleIncrement: Long(\"2\")\n},\n{\n saleTimestamp: Timestamp({ t: 1714124193, i: 3 }),\n saleIncrement: Long(\"3\")\n}","programmingLanguage":"JavaScript"} </script> <div class="css-1lju8ps"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1jheeh3"> <pre class="leafygreen-ui-1453az5" 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">{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">saleTimestamp</span>: <span class="lg-highlight-title lg-highlight-class">Timestamp</span>(<!-- -->{ <span class="lg-highlight-attr">t</span>: <span class="lg-highlight-number">1622731060</span>, <span class="lg-highlight-attr">i</span>: <span class="lg-highlight-number">1</span> })<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">saleIncrement</span>: <span class="lg-highlight-title lg-highlight-class">Long</span>(<span class="lg-highlight-string">"1"</span>)</td></tr><tr class=""><td class="leafygreen-ui-7razhx">}<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">saleTimestamp</span>: <span class="lg-highlight-title lg-highlight-class">Timestamp</span>(<!-- -->{ <span class="lg-highlight-attr">t</span>: <span class="lg-highlight-number">1622731060</span>, <span class="lg-highlight-attr">i</span>: <span class="lg-highlight-number">2</span> })<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">saleIncrement</span>: <span class="lg-highlight-title lg-highlight-class">Long</span>(<span class="lg-highlight-string">"2"</span>)</td></tr><tr class=""><td class="leafygreen-ui-7razhx">}<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">saleTimestamp</span>: <span class="lg-highlight-title lg-highlight-class">Timestamp</span>(<!-- -->{ <span class="lg-highlight-attr">t</span>: <span class="lg-highlight-number">1714124193</span>, <span class="lg-highlight-attr">i</span>: <span class="lg-highlight-number">1</span> })<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">saleIncrement</span>: <span class="lg-highlight-title lg-highlight-class">Long</span>(<span class="lg-highlight-string">"1"</span>)</td></tr><tr class=""><td class="leafygreen-ui-7razhx">}<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">saleTimestamp</span>: <span class="lg-highlight-title lg-highlight-class">Timestamp</span>(<!-- -->{ <span class="lg-highlight-attr">t</span>: <span class="lg-highlight-number">1714124193</span>, <span class="lg-highlight-attr">i</span>: <span class="lg-highlight-number">2</span> })<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">saleIncrement</span>: <span class="lg-highlight-title lg-highlight-class">Long</span>(<span class="lg-highlight-string">"2"</span>)</td></tr><tr class=""><td class="leafygreen-ui-7razhx">}<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">saleTimestamp</span>: <span class="lg-highlight-title lg-highlight-class">Timestamp</span>(<!-- -->{ <span class="lg-highlight-attr">t</span>: <span class="lg-highlight-number">1714124193</span>, <span class="lg-highlight-attr">i</span>: <span class="lg-highlight-number">3</span> })<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">saleIncrement</span>: <span class="lg-highlight-title lg-highlight-class">Long</span>(<span class="lg-highlight-string">"3"</span>)</td></tr><tr class=""><td class="leafygreen-ui-7razhx">}</td></tr></tbody></table></code></pre> </div> </div> </div> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Use <code class="leafygreen-ui-1l06pbn"> $tsIncrement </code> in a Change Stream Cursor to Monitor Collection Changes <a class="headerlink leafygreen-ui-1kepx47" href="#use--tsincrement-in-a-change-stream-cursor-to-monitor-collection-changes" 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="use--tsincrement-in-a-change-stream-cursor-to-monitor-collection-changes"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> The example in this section uses <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-expression-exp.-tsIncrement" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $tsIncrement </code> </span> </a> in a <a class="leafygreen-ui-tqgtui" href="/docs/manual/changeStreams/#std-label-changeStreams"> change stream cursor </a> to return every other change made to a collection in the same second of time. </p> <p class="leafygreen-ui-1kp3ins"> Create a <a class="leafygreen-ui-tqgtui" href="/docs/manual/changeStreams/#std-label-changeStreams"> change stream cursor </a> on a collection named <code class="leafygreen-ui-1l06pbn"> cakeSales </code> that you will see later in this section: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"cakeSalesCursor = db.cakeSales.watch( [\n {\n $match: {\n $expr: {\n $eq: [\n { $mod: [ { $tsIncrement: \"$clusterTime\" } , 2 ] },\n 0\n ]\n }\n }\n }\n] )","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">cakeSalesCursor <!-- -->= <!-- -->db.<span class="lg-highlight-property">cakeSales</span>.<span class="lg-highlight-title lg-highlight-function">watch</span>( <!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">$match</span>: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">$expr</span>: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">$eq</span>: <!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">$mod</span>: <!-- -->[ <!-- -->{ <span class="lg-highlight-attr">$tsIncrement</span>: <span class="lg-highlight-string">"$clusterTime"</span> } <!-- -->, <span class="lg-highlight-number">2</span> ] }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-number">0</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> ]</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">] )</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"> In the example, the: </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/method/db.collection.watch/#mongodb-method-db.collection.watch"> <code class="leafygreen-ui-1l06pbn"> db.collection.watch() </code> </a> method creates a <a class="leafygreen-ui-tqgtui" href="/docs/manual/changeStreams/#std-label-changeStreams"> change stream cursor </a> for the <code class="leafygreen-ui-1l06pbn"> cakeSales </code> collection and stores the cursor in <code class="leafygreen-ui-1l06pbn"> cakeSalesCursor </code> . </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/match/#mongodb-pipeline-pipe.-match"> <code class="leafygreen-ui-1l06pbn"> $match </code> </a> stage filters the documents to those returned by the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/query/expr/#mongodb-query-op.-expr"> <code class="leafygreen-ui-1l06pbn"> $expr </code> </a> operator. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/query/expr/#mongodb-query-op.-expr"> <code class="leafygreen-ui-1l06pbn"> $expr </code> </a> operator: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Applies <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/mod/#mongodb-expression-exp.-mod"> <code class="leafygreen-ui-1l06pbn"> $mod </code> </a> <code class="leafygreen-ui-1l06pbn"> 2 </code> to the <code class="leafygreen-ui-1l06pbn"> $clusterTime </code> variable's incrementing ordinal returned by <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-expression-exp.-tsIncrement" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $tsIncrement </code> . </span> </a> </p> <p class="leafygreen-ui-1kp3ins"> <code class="leafygreen-ui-1l06pbn"> $clusterTime </code> is the timestamp from the <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/replica-set-oplog/#std-label-replica-set-oplog"> oplog </a> entry when the <code class="leafygreen-ui-1l06pbn"> cakeSales </code> collection is modified. See <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/db.runCommand/#std-label-command-response"> Command Response <!-- --> . </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Compares the returned value from <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/mod/#mongodb-expression-exp.-mod"> <code class="leafygreen-ui-1l06pbn"> $mod </code> </a> to <code class="leafygreen-ui-1l06pbn"> 0 </code> using <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/eq/#mongodb-expression-exp.-eq"> <code class="leafygreen-ui-1l06pbn"> $eq </code> . </a> </p> </li> </ul> </li> </ul> <p class="leafygreen-ui-1kp3ins"> Create a <code class="leafygreen-ui-1l06pbn"> cakeSales </code> collection that contains cake sales in the states of California ( <code class="leafygreen-ui-1l06pbn"> CA </code> ) and Washington ( <code class="leafygreen-ui-1l06pbn"> WA </code> ): </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.cakeSales.insertMany( [\n { _id: 0, type: \"chocolate\", orderDate: new Date(\"2020-05-18T14:10:30Z\"),\n state: \"CA\", price: 13, quantity: 120 },\n { _id: 1, type: \"chocolate\", orderDate: new Date(\"2021-03-20T11:30:05Z\"),\n state: \"WA\", price: 14, quantity: 140 },\n { _id: 2, type: \"vanilla\", orderDate: new Date(\"2021-01-11T06:31:15Z\"),\n state: \"CA\", price: 12, quantity: 145 },\n { _id: 3, type: \"vanilla\", orderDate: new Date(\"2020-02-08T13:13:23Z\"),\n state: \"WA\", price: 13, quantity: 104 },\n { _id: 4, type: \"strawberry\", orderDate: new Date(\"2019-05-18T16:09:01Z\"),\n state: \"CA\", price: 41, quantity: 162 },\n { _id: 5, type: \"strawberry\", orderDate: new Date(\"2019-01-08T06:12:03Z\"),\n state: \"WA\", price: 43, quantity: 134 }\n] )","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><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">cakeSales</span>.<span class="lg-highlight-title lg-highlight-function">insertMany</span>( <!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">0</span>, <span class="lg-highlight-attr">type</span>: <span class="lg-highlight-string">"chocolate"</span>, <span class="lg-highlight-attr">orderDate</span>: <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">Date</span>(<span class="lg-highlight-string">"2020-05-18T14:10:30Z"</span>)<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">state</span>: <span class="lg-highlight-string">"CA"</span>, <span class="lg-highlight-attr">price</span>: <span class="lg-highlight-number">13</span>, <span class="lg-highlight-attr">quantity</span>: <span class="lg-highlight-number">120</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">1</span>, <span class="lg-highlight-attr">type</span>: <span class="lg-highlight-string">"chocolate"</span>, <span class="lg-highlight-attr">orderDate</span>: <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">Date</span>(<span class="lg-highlight-string">"2021-03-20T11:30:05Z"</span>)<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">state</span>: <span class="lg-highlight-string">"WA"</span>, <span class="lg-highlight-attr">price</span>: <span class="lg-highlight-number">14</span>, <span class="lg-highlight-attr">quantity</span>: <span class="lg-highlight-number">140</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">2</span>, <span class="lg-highlight-attr">type</span>: <span class="lg-highlight-string">"vanilla"</span>, <span class="lg-highlight-attr">orderDate</span>: <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">Date</span>(<span class="lg-highlight-string">"2021-01-11T06:31:15Z"</span>)<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">state</span>: <span class="lg-highlight-string">"CA"</span>, <span class="lg-highlight-attr">price</span>: <span class="lg-highlight-number">12</span>, <span class="lg-highlight-attr">quantity</span>: <span class="lg-highlight-number">145</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">3</span>, <span class="lg-highlight-attr">type</span>: <span class="lg-highlight-string">"vanilla"</span>, <span class="lg-highlight-attr">orderDate</span>: <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">Date</span>(<span class="lg-highlight-string">"2020-02-08T13:13:23Z"</span>)<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">state</span>: <span class="lg-highlight-string">"WA"</span>, <span class="lg-highlight-attr">price</span>: <span class="lg-highlight-number">13</span>, <span class="lg-highlight-attr">quantity</span>: <span class="lg-highlight-number">104</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">4</span>, <span class="lg-highlight-attr">type</span>: <span class="lg-highlight-string">"strawberry"</span>, <span class="lg-highlight-attr">orderDate</span>: <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">Date</span>(<span class="lg-highlight-string">"2019-05-18T16:09:01Z"</span>)<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">state</span>: <span class="lg-highlight-string">"CA"</span>, <span class="lg-highlight-attr">price</span>: <span class="lg-highlight-number">41</span>, <span class="lg-highlight-attr">quantity</span>: <span class="lg-highlight-number">162</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">5</span>, <span class="lg-highlight-attr">type</span>: <span class="lg-highlight-string">"strawberry"</span>, <span class="lg-highlight-attr">orderDate</span>: <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">Date</span>(<span class="lg-highlight-string">"2019-01-08T06:12:03Z"</span>)<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">state</span>: <span class="lg-highlight-string">"WA"</span>, <span class="lg-highlight-attr">price</span>: <span class="lg-highlight-number">43</span>, <span class="lg-highlight-attr">quantity</span>: <span class="lg-highlight-number">134</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">] )</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"> To monitor the <code class="leafygreen-ui-1l06pbn"> cakeSales </code> collection changes, use <code class="leafygreen-ui-1l06pbn"> cakeSalesCursor </code> . For example, to obtain the next document from <code class="leafygreen-ui-1l06pbn"> cakeSalesCursor </code> , use the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/cursor.next/#mongodb-method-cursor.next"> <code class="leafygreen-ui-1l06pbn"> next() </code> </a> method: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"cakeSalesCursor.next()","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">cakeSalesCursor.<span class="lg-highlight-title lg-highlight-function">next</span>(<!-- -->)</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"> Depending on the second when the documents were added to <code class="leafygreen-ui-1l06pbn"> cakeSales </code> , the output from <code class="leafygreen-ui-1l06pbn"> cakeSalesCursor.next() </code> varies. For example, the document additions might span more than one second. </p> <p class="leafygreen-ui-1kp3ins"> The following <code class="leafygreen-ui-1l06pbn"> cakeSalesCursor.next() </code> example output shows the <code class="leafygreen-ui-1l06pbn"> insert </code> details for the first document added to the <code class="leafygreen-ui-1l06pbn"> cakeSales </code> collection. Notice the incrementing ordinal <code class="leafygreen-ui-1l06pbn"> i </code> is <code class="leafygreen-ui-1l06pbn"> 2 </code> in the <code class="leafygreen-ui-1l06pbn"> clusterTime </code> field. </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"_id: {\n _data: '82613A4F25000000022B022C0100296E5A100454C5BFAF538C47AB950614F43889BE00461E5F696400290004'\n},\noperationType: 'insert',\nclusterTime: Timestamp({ t: 1631211301, i: 2 }),\nfullDocument: {\n _id: 0,\n type: 'chocolate',\n orderDate: ISODate(\"2020-05-18T14:10:30.000Z\"),\n state: 'CA',\n price: 13,\n quantity: 120\n},\nns: { db: 'test', coll: 'cakeSales' },\ndocumentKey: { _id: 0 }","programmingLanguage":"JavaScript"} </script> <div class="css-1lju8ps"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-tyg50d"> <pre class="leafygreen-ui-1453az5" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-attr">_id</span>: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">_data</span>: <span class="lg-highlight-string">'82613A4F25000000022B022C0100296E5A100454C5BFAF538C47AB950614F43889BE00461E5F696400290004'</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx">}<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-attr">operationType</span>: <span class="lg-highlight-string">'insert'</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-attr">clusterTime</span>: <span class="lg-highlight-title lg-highlight-class">Timestamp</span>(<!-- -->{ <span class="lg-highlight-attr">t</span>: <span class="lg-highlight-number">1631211301</span>, <span class="lg-highlight-attr">i</span>: <span class="lg-highlight-number">2</span> })<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-attr">fullDocument</span>: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">0</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">type</span>: <span class="lg-highlight-string">'chocolate'</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">orderDate</span>: <span class="lg-highlight-title lg-highlight-class">ISODate</span>(<span class="lg-highlight-string">"2020-05-18T14:10:30.000Z"</span>)<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">state</span>: <span class="lg-highlight-string">'CA'</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">price</span>: <span class="lg-highlight-number">13</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">quantity</span>: <span class="lg-highlight-number">120</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx">}<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-attr">ns</span>: <!-- -->{ <span class="lg-highlight-attr">db</span>: <span class="lg-highlight-string">'test'</span>, <span class="lg-highlight-attr">coll</span>: <span class="lg-highlight-string">'cakeSales'</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-attr">documentKey</span>: <!-- -->{ <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">0</span> }</td></tr></tbody></table></code></pre> </div> </div> </div> <p class="leafygreen-ui-1kp3ins"> Running <code class="leafygreen-ui-1l06pbn"> cakeSalesCursor.next() </code> again returns the <code class="leafygreen-ui-1l06pbn"> cakeSales </code> document for which the <code class="leafygreen-ui-1l06pbn"> clusterTime </code> incrementing ordinal <code class="leafygreen-ui-1l06pbn"> i </code> is <code class="leafygreen-ui-1l06pbn"> 4 </code> , omitting the document where <code class="leafygreen-ui-1l06pbn"> i </code> is <code class="leafygreen-ui-1l06pbn"> 3 </code> . </p> </section> </section> </section>
https://www.mongodb.com/docs/manual/administration/configuration/
<section> <h1 class="contains-headerlink leafygreen-ui-41fr9s" weight="medium"> Run-time Database Configuration for Self-Managed Deployments <a class="headerlink leafygreen-ui-1kepx47" href="#run-time-database-configuration-for-self-managed-deployments" 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="run-time-database-configuration-for-self-managed-deployments"> </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="#configure-the-database" target="_self"> <span> Configure the Database </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#security-considerations" target="_self"> <span> Security Considerations </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#replication-and-sharding-configuration" target="_self"> <span> Replication and Sharding Configuration </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#run-multiple-database-instances-on-the-same-system" target="_self"> <span> Run Multiple Database Instances on the Same System </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#diagnostic-configurations" target="_self"> <span> Diagnostic Configurations </span> </a> </li> </ul> </div> <p class="leafygreen-ui-1kp3ins"> The <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#std-label-mongod"> command line </a> and <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-configuration-file" target="_self"> <span> configuration file </span> </a> interfaces provide MongoDB administrators with a large number of options and settings for controlling the operation of the database system. This document provides an overview of common configurations and examples of best-practice configurations for common use cases. </p> <p class="leafygreen-ui-1kp3ins"> While both interfaces provide access to the same collection of options and settings, this document primarily uses the configuration file interface. </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> If you <a class="leafygreen-ui-tqgtui" href="/docs/manual/installation/#std-label-tutorial-installation"> installed MongoDB </a> with a package manager such as <code class="leafygreen-ui-1l06pbn"> yum </code> or <code class="leafygreen-ui-1l06pbn"> apt </code> on Linux or <code class="leafygreen-ui-1l06pbn"> brew </code> on macOS, or with the MSI installer on Windows, a default <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/configuration-options/"> configuration file </a> has been provided as part of your installation: </p> <div class="leafygreen-ui-skkc39" tabindex="0"> <table class="leafygreen-ui-hr8lsv"> <colgroup> <col style="width:10%"/> <col style="width:25%"/> <col style="width:65%"/> </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> Platform </div> </div> </th> <th class="leafygreen-ui-13uteka" role="columnheader" scope="col"> <div class="leafygreen-ui-ui0te9"> <div> Method </div> </div> </th> <th class="leafygreen-ui-13uteka" role="columnheader" scope="col"> <div class="leafygreen-ui-ui0te9"> <div> Configuration File </div> </div> </th> </tr> </thead> <tbody> <tr class=""> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Linux </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> apt </code> , <code class="leafygreen-ui-1l06pbn"> yum </code> , or <code class="leafygreen-ui-1l06pbn"> zypper </code> Package Manager </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> /etc/mongod.conf </code> </div> </div> </td> </tr> <tr class=""> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> macOS </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> brew </code> Package Manager </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <p class="leafygreen-ui-1kp3ins"> <code class="leafygreen-ui-1l06pbn"> /usr/local/etc/mongod.conf </code> (on Intel processors), or </p> <p class="leafygreen-ui-1kp3ins"> <code class="leafygreen-ui-1l06pbn"> /opt/homebrew/etc/mongod.conf </code> (on <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://support.apple.com/en-us/HT211814" rel="noopener noreferrer"> <span> Apple M1 processors <!-- --> ) </span> <svg alt="" aria-hidden="true" class="leafygreen-ui-1ie5kuq" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M13.823 2.4491C13.8201 2.30008 13.6999 2.17994 13.5509 2.17704L9.5062 2.09836C9.25654 2.09351 9.12821 2.39519 9.30482 2.5718L10.3856 3.65257L7.93433 6.10383C7.87964 6.15852 7.83047 6.21665 7.78683 6.27752L5.99909 8.06525C5.46457 8.59977 5.46457 9.4664 5.99909 10.0009C6.53361 10.5354 7.40023 10.5354 7.93475 10.0009L9.72249 8.21317C9.78336 8.16953 9.84148 8.12037 9.89618 8.06567L12.3474 5.61441L13.4282 6.69518C13.6048 6.87179 13.9065 6.74347 13.9016 6.4938L13.823 2.4491Z" fill="currentColor"> </path> <path d="M7.25 3.12893C7.66421 3.12893 8 3.46472 8 3.87893C8 4.29315 7.66421 4.62893 7.25 4.62893H4C3.72386 4.62893 3.5 4.85279 3.5 5.12893V11.9929C3.5 12.2691 3.72386 12.4929 4 12.4929H10.864C11.1401 12.4929 11.364 12.2691 11.364 11.9929V8.75C11.364 8.33579 11.6998 8 12.114 8C12.5282 8 12.864 8.33579 12.864 8.75V11.9929C12.864 13.0975 11.9686 13.9929 10.864 13.9929H4C2.89543 13.9929 2 13.0975 2 11.9929V5.12893C2 4.02436 2.89543 3.12893 4 3.12893H7.25Z" fill="currentColor"> </path> </svg> </a> </p> </div> </div> </td> </tr> <tr class=""> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Windows </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> MSI Installer </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> &lt;install directory&gt;\bin\mongod.cfg </code> </div> </div> </td> </tr> </tbody> </table> </div> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> If you <a class="leafygreen-ui-tqgtui" href="/docs/manual/installation/#std-label-tutorial-installation"> installed MongoDB </a> through a downloaded <code class="leafygreen-ui-1l06pbn"> TGZ </code> or <code class="leafygreen-ui-1l06pbn"> ZIP </code> file, you must create your own configuration file. The <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-base-config" target="_self"> <span> basic example configuration </span> </a> is a good place to start. </p> </li> </ul> <p class="leafygreen-ui-1kp3ins"> For package installations of MongoDB on Linux or macOS, an initialization script which uses this default configuration file is also provided. This initialization script can be used to start the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> on these platforms in the following manner: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> On Linux systems that use the <strong> systemd </strong> init system (the <code class="leafygreen-ui-1l06pbn"> systemctl </code> command): </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"sudo systemctl start mongod","programmingLanguage":"Bash"} </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 bash leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">sudo systemctl start mongod</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> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> On Linux systems that use the <strong> SystemV init </strong> init system (the <code class="leafygreen-ui-1l06pbn"> service </code> command): </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"sudo service mongod start","programmingLanguage":"Bash"} </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 bash leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">sudo service mongod start</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> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> On macOS, using the <code class="leafygreen-ui-1l06pbn"> brew </code> package manger: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"brew services start [email protected]","programmingLanguage":"Bash"} </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 bash leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">brew services start [email protected]</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> </li> </ul> <p class="leafygreen-ui-1kp3ins"> If you installed MongoDB using a <code class="leafygreen-ui-1l06pbn"> TGZ </code> or <code class="leafygreen-ui-1l06pbn"> ZIP </code> file, you will need to create your own configuration file. A <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-base-config" target="_self"> <span> basic example configuration </span> </a> can be found later in this document. Once you have created a configuration file, you can start a MongoDB instance with this configuration file by using either the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#std-option-mongod.--config"> <code class="leafygreen-ui-1l06pbn"> --config </code> </a> or <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#std-option-mongod.--config"> <code class="leafygreen-ui-1l06pbn"> -f </code> </a> options to <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> . For example, on Linux: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"mongod --config /etc/mongod.conf\nmongod -f /etc/mongod.conf","programmingLanguage":"Bash"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" tabindex="-1"><code class="lg-highlight-hljs-light bash leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">mongod --config <!-- -->/etc/mongod.conf</td></tr><tr class=""><td class="leafygreen-ui-7razhx">mongod -f <!-- -->/etc/mongod.conf</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"> Modify the values in the <code class="leafygreen-ui-1l06pbn"> mongod.conf </code> file on your system to control the configuration of your database instance. </p> <span class="leafygreen-ui-1qnjd6d" id="std-label-base-config"> </span> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Configure the Database <a class="headerlink leafygreen-ui-1kepx47" href="#configure-the-database" 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="configure-the-database"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> Consider the following basic configuration: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"processManagement:\n fork: true\nnet:\n bindIp: localhost\n port: 27017\nstorage:\n dbPath: /var/lib/mongo\nsystemLog:\n destination: file\n path: \"/var/log/mongodb/mongod.log\"\n logAppend: true","programmingLanguage":"YAML"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" tabindex="-1"><code class="lg-highlight-hljs-light yaml leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-attr">processManagement:</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">fork:</span> <span class="lg-highlight-literal">true</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-attr">net:</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">bindIp:</span> <span class="lg-highlight-string">localhost</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">port:</span> <span class="lg-highlight-number">27017</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-attr">storage:</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">dbPath:</span> <span class="lg-highlight-string">/var/lib/mongo</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-attr">systemLog:</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">destination:</span> <span class="lg-highlight-string">file</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">path:</span> <span class="lg-highlight-string">"/var/log/mongodb/mongod.log"</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">logAppend:</span> <span class="lg-highlight-literal">true</span></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"> For most standalone servers, this is a sufficient base configuration. It makes several assumptions, but consider the following explanation: </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/configuration-options/#mongodb-setting-processManagement.fork"> <code class="leafygreen-ui-1l06pbn"> fork </code> </a> is <code class="leafygreen-ui-1l06pbn"> true </code> , which enables a <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-daemon"> daemon </a> mode for <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> , which detaches (i.e. "forks") the MongoDB from the current session and allows you to run the database as a conventional server. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/configuration-options/#mongodb-setting-net.bindIp"> <code class="leafygreen-ui-1l06pbn"> bindIp </code> </a> is <code class="leafygreen-ui-1l06pbn"> localhost </code> , which forces the server to only listen for requests on the localhost IP. Only bind to secure interfaces that the application-level systems can access with access control provided by system network filtering (i.e. " <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-firewall"> firewall </a> "). </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/configuration-options/#mongodb-setting-net.port"> <code class="leafygreen-ui-1l06pbn"> port </code> </a> is <code class="leafygreen-ui-1l06pbn"> 27017 </code> , which is the default MongoDB port for database instances. MongoDB can bind to any port. You can also filter access based on port using network filtering tools. </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"> UNIX-like systems require superuser privileges to attach processes to ports lower than 1024. </p> </div> </div> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/configuration-options/#mongodb-setting-systemLog.quiet"> <code class="leafygreen-ui-1l06pbn"> quiet </code> </a> is <code class="leafygreen-ui-1l06pbn"> true </code> . This disables all but the most critical entries in output/log file, and is <em> not </em> recommended for production systems. If you do set this option, you can use <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/command/setParameter/#mongodb-dbcommand-dbcmd.setParameter"> <code class="leafygreen-ui-1l06pbn"> setParameter </code> </a> to modify this setting during run time. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/configuration-options/#mongodb-setting-storage.dbPath"> <code class="leafygreen-ui-1l06pbn"> dbPath </code> </a> is <code class="leafygreen-ui-1l06pbn"> /var/lib/mongo </code> , which specifies where MongoDB will store its data files. </p> <p class="leafygreen-ui-1kp3ins"> If you installed MongoDB on Linux using a package manager, such as <code class="leafygreen-ui-1l06pbn"> yum </code> or <code class="leafygreen-ui-1l06pbn"> apt </code> , the <code class="leafygreen-ui-1l06pbn"> /etc/mongod.conf </code> file provided with your MongoDB installation sets the following default <code class="leafygreen-ui-1l06pbn"> dbPath </code> , depending on your Linux distro: </p> <div class="leafygreen-ui-skkc39" tabindex="0"> <table class="leafygreen-ui-hr8lsv"> <colgroup> <col style="width:35%"/> <col style="width:30%"/> <col style="width:35%"/> </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> Platform </div> </div> </th> <th class="leafygreen-ui-13uteka" role="columnheader" scope="col"> <div class="leafygreen-ui-ui0te9"> <div> Package Manager </div> </div> </th> <th class="leafygreen-ui-13uteka" role="columnheader" scope="col"> <div class="leafygreen-ui-ui0te9"> <div> Default <code class="leafygreen-ui-1l06pbn"> dbPath </code> </div> </div> </th> </tr> </thead> <tbody> <tr class=""> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <span class="leafygreen-ui-vm4wms" tabindex="0"> RHEL </span> / CentOS and Amazon </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> yum </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> /var/lib/mongo </code> </div> </div> </td> </tr> <tr class=""> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> SUSE </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> zypper </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> /var/lib/mongo </code> </div> </div> </td> </tr> <tr class=""> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Ubuntu and Debian </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> apt </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> /var/lib/mongodb </code> </div> </div> </td> </tr> <tr class=""> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> macOS </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> brew </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> /usr/local/var/mongodb </code> </div> </div> </td> </tr> </tbody> </table> </div> <p class="leafygreen-ui-1kp3ins"> The user account that <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> runs under will need read and write access to this directory. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/configuration-options/#mongodb-setting-systemLog.path"> <code class="leafygreen-ui-1l06pbn"> systemLog.path </code> </a> is <code class="leafygreen-ui-1l06pbn"> /var/log/mongodb/mongod.log </code> which is where <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> will write its output. If you do not set this value, <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> writes all output to standard output (e.g. <code class="leafygreen-ui-1l06pbn"> stdout </code> .) </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/configuration-options/#mongodb-setting-systemLog.logAppend"> <code class="leafygreen-ui-1l06pbn"> logAppend </code> </a> is <code class="leafygreen-ui-1l06pbn"> true </code> , which ensures that <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> does not overwrite an existing log file following the server start operation. </p> </li> </ul> <p class="leafygreen-ui-1kp3ins"> Given the default configuration, some of these values may be redundant. However, in many situations explicitly stating the configuration increases overall system intelligibility. </p> <span class="leafygreen-ui-1qnjd6d" id="std-label-configuration-security"> </span> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Security Considerations <a class="headerlink leafygreen-ui-1kepx47" href="#security-considerations" 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="security-considerations"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> The following configuration options are useful for limiting access to a <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> instance: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"net:\n bindIp: localhost,10.8.0.10,192.168.4.24,/tmp/mongod.sock\nsecurity:\n authorization: enabled","programmingLanguage":"YAML"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><code class="lg-highlight-hljs-light yaml leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-attr">net:</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">bindIp:</span> <span class="lg-highlight-string">localhost,10.8.0.10,192.168.4.24,/tmp/mongod.sock</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-attr">security:</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">authorization:</span> <span class="lg-highlight-string">enabled</span></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> <dl> <dt> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/configuration-options/#mongodb-setting-net.bindIp"> <code class="leafygreen-ui-1l06pbn"> net.bindIp </code> </a> </dt> <dd class="css-1ufxuu7"> <p class="leafygreen-ui-1kp3ins"> This example provides four values to the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/configuration-options/#mongodb-setting-net.bindIp"> <code class="leafygreen-ui-1l06pbn"> bindIp </code> </a> option: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <code class="leafygreen-ui-1l06pbn"> localhost </code> , the localhost interface; </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <code class="leafygreen-ui-1l06pbn"> 10.8.0.10 </code> , a private IP address typically used for local networks and VPN interfaces; </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <code class="leafygreen-ui-1l06pbn"> 192.168.4.24 </code> , a private network interface typically used for local networks; and </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <code class="leafygreen-ui-1l06pbn"> /tmp/mongod.sock </code> , a Unix domain socket path. </p> </li> </ul> <p class="leafygreen-ui-1kp3ins"> Because production MongoDB instances need to be accessible from multiple database servers, it is important to bind MongoDB to multiple interfaces that are accessible from your application servers. At the same time it's important to limit these interfaces to interfaces controlled and protected at the network layer. </p> </dd> <dt> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/configuration-options/#mongodb-setting-security.authorization"> <code class="leafygreen-ui-1l06pbn"> security.authorization </code> </a> </dt> <dd class="css-1ufxuu7"> Setting this option to <code class="leafygreen-ui-1l06pbn"> true </code> enables the authorization system within MongoDB. If enabled you will need to log in by connecting over the <code class="leafygreen-ui-1l06pbn"> localhost </code> interface for the first time to create user credentials. </dd> </dl> <div class="leafygreen-ui-13vw3ie" role="note"> <h2 class="leafygreen-ui-1fn4p2b"> Tip </h2> <h3 class="leafygreen-ui-144d5kf"> <strong> See also: </strong> </h3> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/security/"> Security </a> </p> </div> </div> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Replication and Sharding Configuration <a class="headerlink leafygreen-ui-1kepx47" href="#replication-and-sharding-configuration" 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="replication-and-sharding-configuration"> </div> </a> </h2> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Replication Configuration <a class="headerlink leafygreen-ui-1kepx47" href="#replication-configuration" 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="replication-configuration"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/atlas/reference/glossary/#std-term-replica-set" target="_self"> <span> replica set </span> </a> configuration is straightforward, and only requires that the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/configuration-options/#mongodb-setting-replication.replSetName"> <code class="leafygreen-ui-1l06pbn"> replSetName </code> </a> have a value that is consistent among all members of the set. Consider the following: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"replication:\n replSetName: set0","programmingLanguage":"YAML"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" tabindex="-1"><code class="lg-highlight-hljs-light yaml leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-attr">replication:</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">replSetName:</span> <span class="lg-highlight-string">set0</span></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"> Use descriptive names for sets. Once configured, use <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/mongodb-shell/#mongodb-binary-bin.mongosh" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongosh </code> </span> </a> to add hosts to the replica set. </p> <div class="leafygreen-ui-13vw3ie" role="note"> <h2 class="leafygreen-ui-1fn4p2b"> Tip </h2> <h3 class="leafygreen-ui-144d5kf"> <strong> See also: </strong> </h3> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/rs.reconfig/#std-label-replica-set-reconfiguration-usage"> Replica set reconfiguration </a> </p> </div> </div> <p class="leafygreen-ui-1kp3ins"> To enable authentication for the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-replica-set"> replica set </a> using <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/security-internal-authentication/#std-label-internal-auth-keyfile"> keyfiles </a> , add the following <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/configuration-options/#mongodb-setting-security.keyFile"> <code class="leafygreen-ui-1l06pbn"> keyFile </code> </a> option <a class="footnote-reference header-buffer" href="#footnote-x509" id="ref-x509-id1"> [ <!-- --> 1 <!-- --> ] </a> : </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"security:\n keyFile: /srv/mongodb/keyfile","programmingLanguage":"YAML"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" tabindex="-1"><code class="lg-highlight-hljs-light yaml leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-attr">security:</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">keyFile:</span> <span class="lg-highlight-string">/srv/mongodb/keyfile</span></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"> Setting <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/configuration-options/#mongodb-setting-security.keyFile"> <code class="leafygreen-ui-1l06pbn"> keyFile </code> </a> enables authentication and specifies a keyfile for the replica set member to use when authenticating to each other. </p> <div class="leafygreen-ui-13vw3ie" role="note"> <h2 class="leafygreen-ui-1fn4p2b"> Tip </h2> <h3 class="leafygreen-ui-144d5kf"> <strong> See also: </strong> </h3> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> The <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/security-internal-authentication/#std-label-replica-set-security"> Replica Set Security </a> section for information on configuring authentication with replica sets. </p> <p class="leafygreen-ui-1kp3ins"> The <a class="leafygreen-ui-tqgtui" href="/docs/manual/replication/"> Replication </a> document for more information on replication in MongoDB and replica set configuration in general. </p> </div> </div> <table class="header-buffer leafygreen-ui-rbqgrl" frame="void" id="footnote-x509" rules="none"> <colgroup> <col/> </colgroup> <tbody valign="top"> <tr> <td class="leafygreen-ui-17r2xs0"> [ <a href="#ref-x509-id1"> 1 </a> ] </td> <td class="leafygreen-ui-17r2xs0"> <!-- --> Sharded clusters and replica sets can use <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/security-internal-authentication/#std-label-internal-auth-x509"> x.509 </a> for membership verification instead of keyfiles. For details, see <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/security-internal-authentication/#std-label-internal-auth-x509"> x.509 <!-- --> . </a> </td> </tr> </tbody> </table> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Sharding Configuration <a class="headerlink leafygreen-ui-1kepx47" href="#sharding-configuration" 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="sharding-configuration"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> Sharding requires <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> instances with different <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> configurations for the <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/sharded-cluster-config-servers/#std-label-sharded-cluster-config-server"> config servers </a> and the <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/sharded-cluster-shards/#std-label-shards-concepts"> shards </a> . The config servers store the cluster's metadata, while the shards store the data. </p> <p class="leafygreen-ui-1kp3ins"> To configure the config server <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> instances, in the configuration file, specify <code class="leafygreen-ui-1l06pbn"> configsvr </code> for the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/configuration-options/#mongodb-setting-sharding.clusterRole"> <code class="leafygreen-ui-1l06pbn"> sharding.clusterRole </code> </a> setting. </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"> Config servers must be deployed as a replica set. </p> </div> </div> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":" sharding:\n clusterRole: configsvr\n net:\n bindIp: 10.8.0.12\n port: 27001\nreplication:\n replSetName: csRS","programmingLanguage":"YAML"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" tabindex="-1"><code class="lg-highlight-hljs-light yaml leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">sharding:</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">clusterRole:</span> <span class="lg-highlight-string">configsvr</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">net:</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">bindIp:</span> <span class="lg-highlight-number">10.8</span><span class="lg-highlight-number">.0</span><span class="lg-highlight-number">.12</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">port:</span> <span class="lg-highlight-number">27001</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-attr">replication:</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">replSetName:</span> <span class="lg-highlight-string">csRS</span></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"> To deploy config servers as a replica set, the config servers must run the <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/wiredtiger/#std-label-storage-wiredtiger"> WiredTiger Storage Engine </a> . <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/rs.initiate/#mongodb-method-rs.initiate"> <code class="leafygreen-ui-1l06pbn"> Initiate </code> </a> the replica set and add members. </p> <p class="leafygreen-ui-1kp3ins"> To configure the shard <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> instances, specify <code class="leafygreen-ui-1l06pbn"> shardsvr </code> for the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/configuration-options/#mongodb-setting-sharding.clusterRole"> <code class="leafygreen-ui-1l06pbn"> sharding.clusterRole </code> </a> setting, and if running as a replica set, the replica set name: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"sharding:\n clusterRole: shardsvr\nreplication:\n replSetName: shardA","programmingLanguage":"YAML"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" tabindex="-1"><code class="lg-highlight-hljs-light yaml leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-attr">sharding:</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">clusterRole:</span> <span class="lg-highlight-string">shardsvr</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-attr">replication:</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">replSetName:</span> <span class="lg-highlight-string">shardA</span></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"> If running as a replica set, <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/rs.initiate/#mongodb-method-rs.initiate"> <code class="leafygreen-ui-1l06pbn"> initiate </code> </a> the shard replica set and add members. </p> <p class="leafygreen-ui-1kp3ins"> For the router (i.e. <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongos/#mongodb-binary-bin.mongos"> <code class="leafygreen-ui-1l06pbn"> mongos </code> </a> ), configure at least one <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongos/#mongodb-binary-bin.mongos"> <code class="leafygreen-ui-1l06pbn"> mongos </code> </a> process with the following <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/configuration-options/#std-label-configuration-options"> setting <!-- --> : </a> </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"sharding:\n configDB: csRS/10.8.0.12:27001","programmingLanguage":"YAML"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" tabindex="-1"><code class="lg-highlight-hljs-light yaml leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-attr">sharding:</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">configDB:</span> <span class="lg-highlight-string">csRS/10.8.0.12:27001</span></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"> You can specify additional members of the config server replica set by specifying hostnames and ports in the form of a comma separated list after the replica set name. </p> <div class="leafygreen-ui-13vw3ie" role="note"> <h2 class="leafygreen-ui-1fn4p2b"> Tip </h2> <h3 class="leafygreen-ui-144d5kf"> <strong> See also: </strong> </h3> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> The <a class="leafygreen-ui-tqgtui" href="/docs/manual/sharding/"> Sharding </a> section of the manual for more information on sharding and cluster configuration. </p> </div> </div> </section> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Run Multiple Database Instances on the Same System <a class="headerlink leafygreen-ui-1kepx47" href="#run-multiple-database-instances-on-the-same-system" 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="run-multiple-database-instances-on-the-same-system"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> In many cases running multiple instances of <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> on a single system is not recommended. On some types of deployments <a class="footnote-reference header-buffer" href="#footnote-multimongod" id="ref-multimongod-id2"> [ <!-- --> 2 <!-- --> ] </a> and for testing purposes you may need to run more than one <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> on a single system. </p> <p class="leafygreen-ui-1kp3ins"> In these cases, use a <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-base-config" target="_self"> <span> base configuration </span> </a> for each instance, but consider the following configuration values: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"storage:\n dbPath: /var/lib/mongo/db0/\nprocessManagement:\n pidFilePath: /var/lib/mongo/db0.pid","programmingLanguage":"YAML"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" tabindex="-1"><code class="lg-highlight-hljs-light yaml leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-attr">storage:</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">dbPath:</span> <span class="lg-highlight-string">/var/lib/mongo/db0/</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-attr">processManagement:</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">pidFilePath:</span> <span class="lg-highlight-string">/var/lib/mongo/db0.pid</span></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 <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/configuration-options/#mongodb-setting-storage.dbPath"> <code class="leafygreen-ui-1l06pbn"> dbPath </code> </a> value controls the location of the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> instance's data directory. Ensure that each database has a distinct and well labeled data directory. The <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/configuration-options/#mongodb-setting-processManagement.pidFilePath"> <code class="leafygreen-ui-1l06pbn"> pidFilePath </code> </a> controls where <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> process places it's <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-PID"> process ID (PID) </a> file. As this tracks the specific <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> file, it is crucial that file be unique and well labeled to make it easy to start and stop these processes. </p> <p class="leafygreen-ui-1kp3ins"> Create additional <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-init-script"> init scripts </a> and/or adjust your existing MongoDB configuration and init script as needed to control these processes. </p> <table class="header-buffer leafygreen-ui-rbqgrl" frame="void" id="footnote-multimongod" rules="none"> <colgroup> <col/> </colgroup> <tbody valign="top"> <tr> <td class="leafygreen-ui-17r2xs0"> [ <a href="#ref-multimongod-id2"> 2 </a> ] </td> <td class="leafygreen-ui-17r2xs0"> <!-- --> Single-tenant systems with <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-SSD"> SSD </a> or other high performance disks may provide acceptable performance levels for multiple <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> instances. Additionally, you may find that multiple databases with small working sets may function acceptably on a single system. </td> </tr> </tbody> </table> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Diagnostic Configurations <a class="headerlink leafygreen-ui-1kepx47" href="#diagnostic-configurations" 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="diagnostic-configurations"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> The following configuration options control various <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> behaviors for diagnostic purposes: </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/configuration-options/#mongodb-setting-operationProfiling.mode"> <code class="leafygreen-ui-1l06pbn"> operationProfiling.mode </code> </a> sets the <a class="leafygreen-ui-tqgtui" href="/docs/manual/tutorial/manage-the-database-profiler/#std-label-database-profiling"> database profiler </a> level. The profiler is not active by default because of the possible impact on the profiler itself on performance. Unless this setting is on, queries are not profiled. </p> </li> <li class="leafygreen-ui-d7p7b6"> <div class="line-block"> <div class="line"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/configuration-options/#mongodb-setting-operationProfiling.slowOpThresholdMs"> <code class="leafygreen-ui-1l06pbn"> operationProfiling.slowOpThresholdMs </code> </a> configures the threshold which determines whether a query is "slow" for the purpose of the logging system and the <a class="leafygreen-ui-tqgtui" href="/docs/manual/tutorial/manage-the-database-profiler/#std-label-database-profiling"> profiler </a> . The default value is 100 milliseconds. Set to a lower value if the logging system and the database profiler do not return useful results or set to a higher value to only log the longest running queries. </div> </div> <div class="line-block"> <div class="line"> <br/> </div> </div> <p class="leafygreen-ui-1kp3ins"> Secondary members of a replica set now <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/replica-set-oplog/#std-label-slow-oplog-application"> log oplog entries </a> that take longer than the slow operation threshold to apply. These slow oplog messages: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Are logged for the secondaries in the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#std-option-mongod.--logpath"> <code class="leafygreen-ui-1l06pbn"> diagnostic log </code> . </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Are logged under the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/log-messages/#mongodb-data-REPL"> <code class="leafygreen-ui-1l06pbn"> REPL </code> </a> component with the text <code class="leafygreen-ui-1l06pbn"> applied op: &lt;oplog entry&gt; took &lt;num&gt;ms </code> . </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Do not depend on the log levels (either at the system or component level) </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Do not depend on the profiling level. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Are affected by <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/configuration-options/#mongodb-setting-operationProfiling.slowOpSampleRate"> <code class="leafygreen-ui-1l06pbn"> slowOpSampleRate </code> . </a> </p> </li> </ul> <p class="leafygreen-ui-1kp3ins"> The profiler does not capture slow oplog entries. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/configuration-options/#mongodb-setting-systemLog.verbosity"> <code class="leafygreen-ui-1l06pbn"> systemLog.verbosity </code> </a> controls the amount of logging output that <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> write to the log. Only use this option if you are experiencing an issue that is not reflected in the normal logging level. </p> <p class="leafygreen-ui-1kp3ins"> You can also specify verbosity level for specific components using the <code class="leafygreen-ui-1l06pbn"> systemLog.component.&lt;name&gt;.verbosity </code> setting. For the available components, see <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/configuration-options/#mongodb-setting-systemLog.component.accessControl.verbosity"> <code class="leafygreen-ui-1l06pbn"> component verbosity settings </code> . </a> </p> </li> </ul> <p class="leafygreen-ui-1kp3ins"> For more information, see also <a class="leafygreen-ui-tqgtui" href="/docs/manual/tutorial/manage-the-database-profiler/#std-label-database-profiling"> Database Profiler </a> and <a class="leafygreen-ui-tqgtui" href="/docs/manual/administration/analyzing-mongodb-performance/"> MongoDB Performance <!-- --> . </a> </p> </section> </section>
https://www.mongodb.com/docs/manual/reference/command/getMore/
<section> <h1 class="contains-headerlink leafygreen-ui-41fr9s" weight="medium"> getMore <a class="headerlink leafygreen-ui-1kepx47" href="#getmore" 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="getmore"> </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="#definition" target="_self"> <span> Definition </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#compatibility" target="_self"> <span> Compatibility </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#syntax" target="_self"> <span> Syntax </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#command-fields" target="_self"> <span> Command Fields </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#output" target="_self"> <span> Output </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#behavior" target="_self"> <span> Behavior </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#learn-more" target="_self"> <span> Learn More </span> </a> </li> </ul> </div> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Definition <a class="headerlink leafygreen-ui-1kepx47" href="#definition" 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="definition"> </div> </a> </h2> <dl class="dbcommand"> <dt> <code class="leafygreen-ui-1l06pbn"> getMore </code> <a class="headerlink leafygreen-ui-1kepx47" href="#mongodb-dbcommand-dbcmd.getMore" title="Permalink to this definition"> <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="mongodb-dbcommand-dbcmd.getMore"> </div> </a> </dt> <dd> <p class="leafygreen-ui-1kp3ins"> Use in conjunction with commands that return a cursor. For example, <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/command/find/#mongodb-dbcommand-dbcmd.find"> <code class="leafygreen-ui-1l06pbn"> find </code> </a> and <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/command/aggregate/#mongodb-dbcommand-dbcmd.aggregate"> <code class="leafygreen-ui-1l06pbn"> aggregate </code> </a> , to return subsequent batches of documents currently pointed to by the cursor. </p> </dd> </dl> </section> <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"> This command is available in 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> <div class="leafygreen-ui-15mdk4" role="note"> <h2 class="leafygreen-ui-6n7b7d"> Note </h2> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> This command is supported in all MongoDB Atlas clusters. For information on Atlas support for all commands, see <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/atlas/unsupported-commands/" target="_self"> <span> Unsupported Commands <!-- --> . </span> </a> </p> </div> </div> <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"> Syntax <a class="headerlink leafygreen-ui-1kepx47" href="#syntax" 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="syntax"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> The command has the following syntax: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.runCommand(\n {\n getMore: &lt;long&gt;,\n collection: &lt;string&gt;,\n batchSize: &lt;int&gt;,\n maxTimeMS: &lt;int&gt;,\n comment: &lt;any&gt;\n }\n)","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">runCommand</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">getMore</span>: &lt;<!-- -->long<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">collection</span>: &lt;<!-- -->string<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">batchSize</span>: &lt;<!-- -->int<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">maxTimeMS</span>: &lt;<!-- -->int<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">comment</span>: &lt;<!-- -->any<!-- -->&gt;</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->}</td></tr><tr class=""><td class="leafygreen-ui-7razhx">)</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> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Command Fields <a class="headerlink leafygreen-ui-1kepx47" href="#command-fields" 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="command-fields"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> The command accepts the following fields: </p> <div class="leafygreen-ui-skkc39" tabindex="0"> <table class="leafygreen-ui-hr8lsv"> <colgroup> <col style="width:20%"/> <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> Field </div> </div> </th> <th class="leafygreen-ui-13uteka" role="columnheader" scope="col"> <div class="leafygreen-ui-ui0te9"> <div> Type </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> <code class="leafygreen-ui-1l06pbn"> getMore </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> long </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> The cursor identifier. </div> </div> </td> </tr> <tr class="leafygreen-ui-15dvrnp"> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> collection </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> string </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> The name of the collection over which the cursor is operating. </div> </div> </td> </tr> <tr class="leafygreen-ui-15dvrnp"> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> batchSize </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> positive integer </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <p class="leafygreen-ui-1kp3ins"> Optional. The number of documents to return in the batch. </p> <p class="leafygreen-ui-1kp3ins"> If <code class="leafygreen-ui-1l06pbn"> batchSize </code> is not set, <code class="leafygreen-ui-1l06pbn"> getMore </code> returns up to 16 megabytes of data. If <code class="leafygreen-ui-1l06pbn"> batchSize </code> is set, <code class="leafygreen-ui-1l06pbn"> getMore </code> returns the smaller of 16 megabytes of data or <code class="leafygreen-ui-1l06pbn"> batchSize </code> documents. </p> </div> </div> </td> </tr> <tr class="leafygreen-ui-15dvrnp"> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> maxTimeMS </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> non-negative integer </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <p class="leafygreen-ui-1kp3ins"> Optional. </p> <p class="leafygreen-ui-1kp3ins"> Specifies the maximum time for the server to wait for new documents that match a <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/tailable-cursors/#std-label-tailable-cursors-landing-page"> tailable cursor </a> query on a <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/capped-collections/#std-label-manual-capped-collection"> capped collection </a> . <code class="leafygreen-ui-1l06pbn"> maxTimeMS </code> on a <code class="leafygreen-ui-1l06pbn"> getMore </code> for a tailable <code class="leafygreen-ui-1l06pbn"> awaitData </code> cursor is considered the same as <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/cursor.maxAwaitTimeMS/#mongodb-method-cursor.maxAwaitTimeMS"> <code class="leafygreen-ui-1l06pbn"> maxAwaitTimeMS() </code> </a> . Drivers will only set this value on <code class="leafygreen-ui-1l06pbn"> getMore </code> for a tailable cursor on a capped collection with <code class="leafygreen-ui-1l06pbn"> awaitData </code> set to <code class="leafygreen-ui-1l06pbn"> true </code> . Otherwise, the command that creates the cursor sets <code class="leafygreen-ui-1l06pbn"> maxTimeMS </code> , which is the maximum amount of time that the initial operation, and any subsequent <code class="leafygreen-ui-1l06pbn"> getMore </code> operations, can spend cumulatively executing the query. For tailable cursors with <code class="leafygreen-ui-1l06pbn"> awaitData </code> set to <code class="leafygreen-ui-1l06pbn"> true </code> , the following is true: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> If no value is provided, the wait time defaults to <code class="leafygreen-ui-1l06pbn"> 1 </code> (1000 milliseconds). </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <code class="leafygreen-ui-1l06pbn"> maxTimeMS </code> on <code class="leafygreen-ui-1l06pbn"> getMore </code> specifies the maximum amount of time MongoDB waits for new documents to be inserted into the capped collection for that specific <code class="leafygreen-ui-1l06pbn"> getMore </code> command. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <code class="leafygreen-ui-1l06pbn"> maxTimeMS </code> is set individually by the driver for each call to <code class="leafygreen-ui-1l06pbn"> getMore </code> . </p> </li> </ul> <p class="leafygreen-ui-1kp3ins"> MongoDB terminates operations that exceed their allotted time limit using the same mechanism as <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/db.killOp/#mongodb-method-db.killOp"> <code class="leafygreen-ui-1l06pbn"> db.killOp() </code> </a> . MongoDB only terminates an operation at one of its designated <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-interrupt-point"> interrupt points <!-- --> . </a> </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> You cannot set <code class="leafygreen-ui-1l06pbn"> maxTimeMS </code> when calling <code class="leafygreen-ui-1l06pbn"> getMore </code> on a non-tailable cursor. Instead, set it using <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/cursor.maxTimeMS/#mongodb-method-cursor.maxTimeMS"> <code class="leafygreen-ui-1l06pbn"> maxTimeMS() </code> </a> when you create the cursor. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> To use <code class="leafygreen-ui-1l06pbn"> getMore </code> with <code class="leafygreen-ui-1l06pbn"> maxTimeMS </code> on a tailable cursor, enable <code class="leafygreen-ui-1l06pbn"> awaitData </code> when you create the cursor using <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/cursor.tailable/#mongodb-method-cursor.tailable"> <code class="leafygreen-ui-1l06pbn"> cursor.tailable() </code> . </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Setting <code class="leafygreen-ui-1l06pbn"> maxTimeMS </code> on the command that creates a cursor only sets the time limit for that operation. Use <code class="leafygreen-ui-1l06pbn"> getMore </code> to set a limit on further operations. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> You can set or omit <code class="leafygreen-ui-1l06pbn"> maxTimeMS </code> for each call to <code class="leafygreen-ui-1l06pbn"> getMore </code> , and you don't have to use the same value. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> For a tailable cursor, a timeout on <code class="leafygreen-ui-1l06pbn"> getMore </code> retains the documents accumulated before the timeout occurred in the cursor. For a non-tailable cursor, a timeout raises an error. </p> </li> </ul> </div> </div> </td> </tr> <tr class="leafygreen-ui-15dvrnp"> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> comment </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> any </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <p class="leafygreen-ui-1kp3ins"> Optional. A user-provided comment to attach to this command. Once set, this comment appears alongside records of this command in the following locations: </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/log-messages/#std-label-log-messages-ref"> mongod log messages </a> , in the <code class="leafygreen-ui-1l06pbn"> attr.command.cursor.comment </code> field. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/database-profiler/#std-label-profiler"> Database profiler </a> output, in the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/database-profiler/#mongodb-data-system.profile.command"> <code class="leafygreen-ui-1l06pbn"> command.comment </code> </a> field. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/command/currentOp/#mongodb-dbcommand-dbcmd.currentOp"> <code class="leafygreen-ui-1l06pbn"> currentOp </code> </a> output, in the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/command/currentOp/#mongodb-data-currentOp.command"> <code class="leafygreen-ui-1l06pbn"> command.comment </code> </a> field. </p> </li> </ul> <p class="leafygreen-ui-1kp3ins"> A comment can be any valid <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/bson-types/#std-label-bson-types"> BSON type </a> (string, integer, object, array, etc). </p> <p class="leafygreen-ui-1kp3ins"> If omitted, <code class="leafygreen-ui-1l06pbn"> getMore </code> inherits any <code class="leafygreen-ui-1l06pbn"> comment </code> set on the originating <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/command/find/#mongodb-dbcommand-dbcmd.find"> <code class="leafygreen-ui-1l06pbn"> find </code> </a> or <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/command/aggregate/#mongodb-dbcommand-dbcmd.aggregate"> <code class="leafygreen-ui-1l06pbn"> aggregate </code> </a> command. </p> </div> </div> </td> </tr> </tbody> </table> </div> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Output <a class="headerlink leafygreen-ui-1kepx47" href="#output" 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="output"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> The command returns a document that contains the cursor information as well as the next batch. </p> <p class="leafygreen-ui-1kp3ins"> For example, running <code class="leafygreen-ui-1l06pbn"> getMore </code> on a cursor created by a <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/command/find/#mongodb-dbcommand-dbcmd.find"> <code class="leafygreen-ui-1l06pbn"> find </code> </a> operation on a sharded cluster returns a document similar to this output: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{\n \"cursor\" : {\n \"id\" : NumberLong(\"678960441858272731\"),\n \"ns\" : \"test.contacts\",\n \"nextBatch\" : [\n {\n \"_id\" : ObjectId(\"5e8e501e1a32d227f9085857\"),\n \"zipcode\" : \"220000\"\n }\n ],\n \"partialResultsReturned\" : true,\n \"postBatchResumeToken\": \"&lt; Resume Token &gt;\"\n },\n \"ok\" : 1,\n \"operationTime\" : Timestamp(1586385239, 2),\n \"$clusterTime\" : {\n \"clusterTime\" : Timestamp(1586385239, 2),\n \"signature\" : {\n \"hash\" : BinData(0,\"lLjejeW6AQGReR9x1PD8xU+tP+A=\"),\n \"keyId\" : NumberLong(\"6813467763969884181\")\n }\n }\n}","programmingLanguage":"JavaScript"} </script> <div class="css-1lju8ps"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1jheeh3"> <pre class="leafygreen-ui-1453az5" 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">{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"cursor"</span> <!-- -->: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"id"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">NumberLong</span>(<span class="lg-highlight-string">"678960441858272731"</span>)<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"ns"</span> <!-- -->: <span class="lg-highlight-string">"test.contacts"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"nextBatch"</span> <!-- -->: <!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">ObjectId</span>(<span class="lg-highlight-string">"5e8e501e1a32d227f9085857"</span>)<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"zipcode"</span> <!-- -->: <span class="lg-highlight-string">"220000"</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> ]<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"partialResultsReturned"</span> <!-- -->: <span class="lg-highlight-literal">true</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"postBatchResumeToken"</span>: <span class="lg-highlight-string">"&lt; Resume Token &gt;"</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"ok"</span> <!-- -->: <span class="lg-highlight-number">1</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"operationTime"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">Timestamp</span>(<span class="lg-highlight-number">1586385239</span>, <span class="lg-highlight-number">2</span>)<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"$clusterTime"</span> <!-- -->: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"clusterTime"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">Timestamp</span>(<span class="lg-highlight-number">1586385239</span>, <span class="lg-highlight-number">2</span>)<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"signature"</span> <!-- -->: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"hash"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">BinData</span>(<span class="lg-highlight-number">0</span>,<span class="lg-highlight-string">"lLjejeW6AQGReR9x1PD8xU+tP+A="</span>)<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"keyId"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">NumberLong</span>(<span class="lg-highlight-string">"6813467763969884181"</span>)</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">}</td></tr></tbody></table></code></pre> </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> Field </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> <code class="leafygreen-ui-1l06pbn"> cursor </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <p class="leafygreen-ui-1kp3ins"> Contains the cursor information, including the cursor ID as well as the <code class="leafygreen-ui-1l06pbn"> nextBatch </code> of documents. </p> <p class="leafygreen-ui-1kp3ins"> If <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/command/find/#mongodb-dbcommand-dbcmd.find"> <code class="leafygreen-ui-1l06pbn"> find </code> </a> (or subsequent <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-dbcommand-dbcmd.getMore" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> getMore </code> </span> </a> commands) returns partial results because the queried shard(s) aren't available, the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/command/find/#std-label-cmd-find-output"> find output </a> includes a <code class="leafygreen-ui-1l06pbn"> partialResultsReturned </code> indicator field. If the queried shards are available for the initial <code class="leafygreen-ui-1l06pbn"> find </code> command, but one or more shards become unavailable for subsequent <code class="leafygreen-ui-1l06pbn"> getMore </code> commands, only the <code class="leafygreen-ui-1l06pbn"> getMore </code> commands that run while the shards aren't available include <code class="leafygreen-ui-1l06pbn"> partialResultsReturned </code> in their output. </p> <p class="leafygreen-ui-1kp3ins"> The <code class="leafygreen-ui-1l06pbn"> postBatchResumeToken </code> field can be used with the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/changeStream/#mongodb-pipeline-pipe.-changeStream"> <code class="leafygreen-ui-1l06pbn"> $changeStream </code> </a> pipeline to start or resume a change stream from this point. </p> </div> </div> </td> </tr> <tr class=""> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> "ok" </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Indicates whether the command has succeeded ( <code class="leafygreen-ui-1l06pbn"> 1 </code> ) or failed ( <code class="leafygreen-ui-1l06pbn"> 0 </code> ). </div> </div> </td> </tr> </tbody> </table> </div> <p class="leafygreen-ui-1kp3ins"> In addition to these fields, the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/db.runCommand/#mongodb-method-db.runCommand"> <code class="leafygreen-ui-1l06pbn"> db.runCommand() </code> </a> response includes the following information for replica sets and sharded clusters: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <code class="leafygreen-ui-1l06pbn"> $clusterTime </code> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <code class="leafygreen-ui-1l06pbn"> operationTime </code> </p> </li> </ul> <p class="leafygreen-ui-1kp3ins"> See <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/db.runCommand/#std-label-command-response"> db.runCommand() Response </a> for details. </p> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Behavior <a class="headerlink leafygreen-ui-1kepx47" href="#behavior" 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="behavior"> </div> </a> </h2> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Access Control <a class="headerlink leafygreen-ui-1kepx47" href="#access-control" 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="access-control"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> If <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/authentication/#std-label-authentication"> authentication </a> is enabled, you can only run <code class="leafygreen-ui-1l06pbn"> getMore </code> against cursors you created. </p> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Sessions <a class="headerlink leafygreen-ui-1kepx47" href="#sessions" 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="sessions"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> For cursors created inside a session, you cannot call <code class="leafygreen-ui-1l06pbn"> getMore </code> outside the session. </p> <p class="leafygreen-ui-1kp3ins"> Similarly, for cursors created outside of a session, you cannot call <code class="leafygreen-ui-1l06pbn"> getMore </code> inside a session. </p> <section> <h4 class="contains-headerlink leafygreen-ui-1vzlt5f"> Transactions <a class="headerlink leafygreen-ui-1kepx47" href="#transactions" 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="transactions"> </div> </a> </h4> <p class="leafygreen-ui-1kp3ins"> For <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/transactions/#std-label-transactions"> multi-document transactions <!-- --> : </a> </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> For cursors created outside of a transaction, you cannot call <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-dbcommand-dbcmd.getMore" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> getMore </code> </span> </a> inside the transaction. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> For cursors created in a transaction, you cannot call <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-dbcommand-dbcmd.getMore" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> getMore </code> </span> </a> outside the transaction. </p> </li> </ul> </section> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Slow Queries <a class="headerlink leafygreen-ui-1kepx47" href="#slow-queries" 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="slow-queries"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> Starting in MongoDB 5.1, when a <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-dbcommand-dbcmd.getMore" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> getMore </code> </span> </a> command is logged as a <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/log-messages/#std-label-log-message-slow-ops"> slow query </a> , the <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/query-plans/#std-label-query-hash"> queryHash </a> and <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/query-plans/#std-label-plan-cache-key"> planCacheKey </a> fields are added to the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/log-messages/#std-label-log-message-slow-ops"> slow query log message </a> and the <a class="leafygreen-ui-tqgtui" href="/docs/manual/tutorial/manage-the-database-profiler/#std-label-database-profiler"> profiler log message <!-- --> . </a> </p> <p class="leafygreen-ui-1kp3ins"> Starting in MongoDB 8.0, the pre-existing <code class="leafygreen-ui-1l06pbn"> queryHash </code> field is renamed to <code class="leafygreen-ui-1l06pbn"> planCacheShapeHash </code> . If you're using an earlier MongoDB version, you'll see <code class="leafygreen-ui-1l06pbn"> queryHash </code> instead of <code class="leafygreen-ui-1l06pbn"> planCacheShapeHash </code> . </p> </section> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Learn More <a class="headerlink leafygreen-ui-1kepx47" href="#learn-more" 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="learn-more"> </div> </a> </h2> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/cursor.batchSize/#std-label-cursor-batchSize"> cursor.batchSize() </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/tutorial/iterate-a-cursor/#std-label-read-operations-cursors"> Iterate a Cursor in <code class="leafygreen-ui-1l06pbn"> mongosh </code> </a> </p> </li> </ul> </section> </section>
https://www.mongodb.com/docs/manual/reference/operator/aggregation/bsonSize/
<section> <h1 class="contains-headerlink leafygreen-ui-41fr9s" weight="medium"> $bsonSize (aggregation) <a class="headerlink leafygreen-ui-1kepx47" href="#-bsonsize--aggregation-" 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="-bsonsize--aggregation-"> </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="#definition" target="_self"> <span> Definition </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#behavior" target="_self"> <span> Behavior </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#examples" target="_self"> <span> Examples </span> </a> </li> </ul> </div> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Definition <a class="headerlink leafygreen-ui-1kepx47" href="#definition" 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="definition"> </div> </a> </h2> <dl class="expression"> <dt> <code class="leafygreen-ui-1l06pbn"> $bsonSize </code> <a class="headerlink leafygreen-ui-1kepx47" href="#mongodb-expression-exp.-bsonSize" title="Permalink to this definition"> <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="mongodb-expression-exp.-bsonSize"> </div> </a> </dt> <dd> <p class="leafygreen-ui-1kp3ins"> Returns the size in bytes of a given document (i.e. bsontype <code class="leafygreen-ui-1l06pbn"> Object </code> ) when encoded as <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-BSON"> BSON </a> . You can use <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-expression-exp.-bsonSize" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $bsonSize </code> </span> </a> as an alternative to the <code class="leafygreen-ui-1l06pbn"> bsonSize() </code> method. </p> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-expression-exp.-bsonSize" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $bsonSize </code> </span> </a> has the following syntax: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ $bsonSize: &lt;object&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">{ <span class="lg-highlight-attr">$bsonSize</span>: &lt;<!-- -->object<!-- -->&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 argument can be any valid <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/#std-label-aggregation-expressions"> expression </a> as long as it resolves to either an object or <code class="leafygreen-ui-1l06pbn"> null </code> . For more information on expressions, see <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/#std-label-aggregation-expressions"> Expression Operators <!-- --> . </a> </p> </dd> </dl> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Behavior <a class="headerlink leafygreen-ui-1kepx47" href="#behavior" 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="behavior"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> If the argument is an object, the expression returns the size of the object in bytes when the object is encoded as <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-BSON"> BSON <!-- --> . </a> </p> <p class="leafygreen-ui-1kp3ins"> If the argument is <code class="leafygreen-ui-1l06pbn"> null </code> , the expression returns <code class="leafygreen-ui-1l06pbn"> null </code> . </p> <p class="leafygreen-ui-1kp3ins"> If the argument resolves to a data type other than an object or <code class="leafygreen-ui-1l06pbn"> null </code> , <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-expression-exp.-bsonSize" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $bsonSize </code> </span> </a> errors. </p> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Examples <a class="headerlink leafygreen-ui-1kepx47" href="#examples" 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="examples"> </div> </a> </h2> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Return Sizes of Documents <a class="headerlink leafygreen-ui-1kepx47" href="#return-sizes-of-documents" 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="return-sizes-of-documents"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> In <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/mongodb-shell/#mongodb-binary-bin.mongosh" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongosh </code> </span> </a> , create a sample collection named <code class="leafygreen-ui-1l06pbn"> employees </code> with the following documents: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":" db.employees.insertMany([\n {\n \"_id\": 1,\n \"name\": \"Alice\", \"email\": \"[email protected]\", \"position\": \"Software Developer\",\n \"current_task\": {\n \"project_id\": 1,\n \"project_name\": \"Aggregation Improvements\",\n \"project_duration\": 5,\n \"hours\": 20\n }\n },\n {\n \"_id\": 2,\n \"name\": \"Bob\", \"email\": \"[email protected]\", \"position\": \"Sales\",\n \"current_task\": {\n \"project_id\": 2,\n \"project_name\": \"Write Blog Posts\",\n \"project_duration\": 2,\n \"hours\": 10,\n \"notes\": \"Progress is slow. Waiting for feedback.\"\n }\n },\n {\n \"_id\": 3,\n \"name\": \"Charlie\", \"email\": \"[email protected]\", \"position\": \"HR (On Leave)\",\n \"current_task\": null\n },\n {\n \"_id\": 4,\n \"name\": \"Dianne\", \"email\": \"[email protected]\", \"position\": \"Web Designer\",\n \"current_task\": {\n \"project_id\": 3,\n \"project_name\": \"Update Home Page\",\n \"notes\": \"Need to scope this project.\"\n }\n }\n]);","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><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">employees</span>.<span class="lg-highlight-title lg-highlight-function">insertMany</span>(<!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"_id"</span>: <span class="lg-highlight-number">1</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"name"</span>: <span class="lg-highlight-string">"Alice"</span>, <span class="lg-highlight-string">"email"</span>: <span class="lg-highlight-string">"[email protected]"</span>, <span class="lg-highlight-string">"position"</span>: <span class="lg-highlight-string">"Software Developer"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"current_task"</span>: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"project_id"</span>: <span class="lg-highlight-number">1</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"project_name"</span>: <span class="lg-highlight-string">"Aggregation Improvements"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"project_duration"</span>: <span class="lg-highlight-number">5</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"hours"</span>: <span class="lg-highlight-number">20</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"_id"</span>: <span class="lg-highlight-number">2</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"name"</span>: <span class="lg-highlight-string">"Bob"</span>, <span class="lg-highlight-string">"email"</span>: <span class="lg-highlight-string">"[email protected]"</span>, <span class="lg-highlight-string">"position"</span>: <span class="lg-highlight-string">"Sales"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"current_task"</span>: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"project_id"</span>: <span class="lg-highlight-number">2</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"project_name"</span>: <span class="lg-highlight-string">"Write Blog Posts"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"project_duration"</span>: <span class="lg-highlight-number">2</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"hours"</span>: <span class="lg-highlight-number">10</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"notes"</span>: <span class="lg-highlight-string">"Progress is slow. Waiting for feedback."</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"_id"</span>: <span class="lg-highlight-number">3</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"name"</span>: <span class="lg-highlight-string">"Charlie"</span>, <span class="lg-highlight-string">"email"</span>: <span class="lg-highlight-string">"[email protected]"</span>, <span class="lg-highlight-string">"position"</span>: <span class="lg-highlight-string">"HR (On Leave)"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"current_task"</span>: <span class="lg-highlight-literal">null</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"_id"</span>: <span class="lg-highlight-number">4</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"name"</span>: <span class="lg-highlight-string">"Dianne"</span>, <span class="lg-highlight-string">"email"</span>: <span class="lg-highlight-string">"[email protected]"</span>, <span class="lg-highlight-string">"position"</span>: <span class="lg-highlight-string">"Web Designer"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"current_task"</span>: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"project_id"</span>: <span class="lg-highlight-number">3</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"project_name"</span>: <span class="lg-highlight-string">"Update Home Page"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"notes"</span>: <span class="lg-highlight-string">"Need to scope this project."</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">])<!-- -->;</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 aggregation <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/project/#mongodb-pipeline-pipe.-project"> <code class="leafygreen-ui-1l06pbn"> projects </code> : </a> </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> The <code class="leafygreen-ui-1l06pbn"> name </code> field </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> The <code class="leafygreen-ui-1l06pbn"> object_size </code> field, which uses <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-expression-exp.-bsonSize" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $bsonSize </code> </span> </a> to return the size of the document in bytes. The <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/aggregation-variables/#mongodb-variable-variable.ROOT"> <code class="leafygreen-ui-1l06pbn"> $$ROOT </code> </a> variable references the document currently being processed by the pipeline. To learn more about variables in the aggregation pipeline, see <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/aggregation-variables/"> Variables in Aggregation Expressions <!-- --> . </a> </p> </li> </ul> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.employees.aggregate([\n {\n \"$project\": {\n \"name\": 1,\n \"object_size\": { $bsonSize: \"$$ROOT\" }\n }\n }\n])","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">employees</span>.<span class="lg-highlight-title lg-highlight-function">aggregate</span>(<!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"$project"</span>: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"name"</span>: <span class="lg-highlight-number">1</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"object_size"</span>: <!-- -->{ <span class="lg-highlight-attr">$bsonSize</span>: <span class="lg-highlight-string">"$$ROOT"</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">])</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 operation returns the following result: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ \"_id\" : 1, \"name\" : \"Alice\", \"object_size\" : 222 }\n{ \"_id\" : 2, \"name\" : \"Bob\", \"object_size\" : 248 }\n{ \"_id\" : 3, \"name\" : \"Charlie\", \"object_size\" : 112 }\n{ \"_id\" : 4, \"name\" : \"Dianne\", \"object_size\" : 207 }","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">1</span>, <span class="lg-highlight-string">"name"</span> <!-- -->: <span class="lg-highlight-string">"Alice"</span>, <span class="lg-highlight-string">"object_size"</span> <!-- -->: <span class="lg-highlight-number">222</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">2</span>, <span class="lg-highlight-string">"name"</span> <!-- -->: <span class="lg-highlight-string">"Bob"</span>, <span class="lg-highlight-string">"object_size"</span> <!-- -->: <span class="lg-highlight-number">248</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">3</span>, <span class="lg-highlight-string">"name"</span> <!-- -->: <span class="lg-highlight-string">"Charlie"</span>, <span class="lg-highlight-string">"object_size"</span> <!-- -->: <span class="lg-highlight-number">112</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">4</span>, <span class="lg-highlight-string">"name"</span> <!-- -->: <span class="lg-highlight-string">"Dianne"</span>, <span class="lg-highlight-string">"object_size"</span> <!-- -->: <span class="lg-highlight-number">207</span> }</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> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Return Combined Size of All Documents in a Collection <a class="headerlink leafygreen-ui-1kepx47" href="#return-combined-size-of-all-documents-in-a-collection" 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="return-combined-size-of-all-documents-in-a-collection"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> The following pipeline returns the combined size of all of the documents in the <code class="leafygreen-ui-1l06pbn"> employees </code> collection: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.employees.aggregate([\n {\n \"$group\": {\n \"_id\": null,\n \"combined_object_size\": { $sum: { $bsonSize: \"$$ROOT\" } }\n }\n }\n])","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><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">employees</span>.<span class="lg-highlight-title lg-highlight-function">aggregate</span>(<!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"$group"</span>: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"_id"</span>: <span class="lg-highlight-literal">null</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"combined_object_size"</span>: <!-- -->{ <span class="lg-highlight-attr">$sum</span>: <!-- -->{ <span class="lg-highlight-attr">$bsonSize</span>: <span class="lg-highlight-string">"$$ROOT"</span> } }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">])</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"> When you specify an <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/group/#mongodb-pipeline-pipe.-group"> <code class="leafygreen-ui-1l06pbn"> $group </code> </a> _id value of <code class="leafygreen-ui-1l06pbn"> null </code> , or any other constant value, the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/group/#mongodb-pipeline-pipe.-group"> <code class="leafygreen-ui-1l06pbn"> $group </code> </a> stage calculates accumulated values for all the input documents as a whole. </p> <p class="leafygreen-ui-1kp3ins"> The operation uses the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/sum/#mongodb-group-grp.-sum"> <code class="leafygreen-ui-1l06pbn"> $sum </code> </a> operator to calculate the combined <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-expression-exp.-bsonSize" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $bsonSize </code> </span> </a> of each document in the collection. The <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/aggregation-variables/#mongodb-variable-variable.ROOT"> <code class="leafygreen-ui-1l06pbn"> $$ROOT </code> </a> variable references the document currently being processed by the pipeline. To learn more about variables in the aggregation pipeline, see <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/aggregation-variables/"> Variables in Aggregation Expressions <!-- --> . </a> </p> <p class="leafygreen-ui-1kp3ins"> The operation returns the following result: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ \"_id\" : null, \"combined_object_size\" : 789 }"} </script> <div class="css-1lju8ps"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1jheeh3"> <pre class="leafygreen-ui-1agdxuk" tabindex="-1"><code class="lg-highlight-hljs-light none leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">{ "_id" : null, "combined_object_size" : 789 }</td></tr></tbody></table></code></pre> </div> </div> </div> <div class="leafygreen-ui-13vw3ie" role="note"> <h2 class="leafygreen-ui-1fn4p2b"> Tip </h2> <h3 class="leafygreen-ui-144d5kf"> <strong> See also: </strong> </h3> <div class="leafygreen-ui-9mycqc"> <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/group/#mongodb-pipeline-pipe.-group"> <code class="leafygreen-ui-1l06pbn"> $group </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/sum/#mongodb-group-grp.-sum"> <code class="leafygreen-ui-1l06pbn"> $sum </code> </a> </p> </li> </ul> </div> </div> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Return Document with Largest Specified Field <a class="headerlink leafygreen-ui-1kepx47" href="#return-document-with-largest-specified-field" 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="return-document-with-largest-specified-field"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> The following pipeline returns the document with the largest <code class="leafygreen-ui-1l06pbn"> current_task </code> field in bytes: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.employees.aggregate([\n // First Stage\n { $project: { name: \"$name\", task_object_size: { $bsonSize: \"$current_task\" } } },\n // Second Stage\n { $sort: { \"task_object_size\" : -1 } },\n // Third Stage\n { $limit: 1 }\n])","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><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">employees</span>.<span class="lg-highlight-title lg-highlight-function">aggregate</span>(<!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-comment">// First Stage</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">$project</span>: <!-- -->{ <span class="lg-highlight-attr">name</span>: <span class="lg-highlight-string">"$name"</span>, <span class="lg-highlight-attr">task_object_size</span>: <!-- -->{ <span class="lg-highlight-attr">$bsonSize</span>: <span class="lg-highlight-string">"$current_task"</span> } } }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-comment">// Second Stage</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">$sort</span>: <!-- -->{ <span class="lg-highlight-string">"task_object_size"</span> <!-- -->: <!-- -->-<span class="lg-highlight-number">1</span> } }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-comment">// Third Stage</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">$limit</span>: <span class="lg-highlight-number">1</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">])</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> <dl> <dt> First Stage </dt> <dd class="css-1ufxuu7"> <p class="leafygreen-ui-1kp3ins"> The first stage of the pipeline <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/project/#mongodb-pipeline-pipe.-project"> <code class="leafygreen-ui-1l06pbn"> projects </code> : </a> </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> The <code class="leafygreen-ui-1l06pbn"> name </code> field </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> The <code class="leafygreen-ui-1l06pbn"> task_object_size </code> field, which uses <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-expression-exp.-bsonSize" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $bsonSize </code> </span> </a> to return the size of the document's <code class="leafygreen-ui-1l06pbn"> current_task </code> field in bytes. </p> </li> </ul> <p class="leafygreen-ui-1kp3ins"> This stage outputs the following documents to the next stage: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ \"_id\" : 1, \"name\" : \"Alice\", \"task_object_size\" : 109 }\n{ \"_id\" : 2, \"name\" : \"Bob\", \"task_object_size\" : 152 }\n{ \"_id\" : 3, \"name\" : \"Charlie\", \"task_object_size\" : null }\n{ \"_id\" : 4, \"name\" : \"Dianne\", \"task_object_size\" : 99 }","programmingLanguage":"JavaScript"} </script> <div class="css-1lju8ps"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-tyg50d"> <pre class="leafygreen-ui-1453az5" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">1</span>, <span class="lg-highlight-string">"name"</span> <!-- -->: <span class="lg-highlight-string">"Alice"</span>, <span class="lg-highlight-string">"task_object_size"</span> <!-- -->: <span class="lg-highlight-number">109</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">2</span>, <span class="lg-highlight-string">"name"</span> <!-- -->: <span class="lg-highlight-string">"Bob"</span>, <span class="lg-highlight-string">"task_object_size"</span> <!-- -->: <span class="lg-highlight-number">152</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">3</span>, <span class="lg-highlight-string">"name"</span> <!-- -->: <span class="lg-highlight-string">"Charlie"</span>, <span class="lg-highlight-string">"task_object_size"</span> <!-- -->: <span class="lg-highlight-literal">null</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">4</span>, <span class="lg-highlight-string">"name"</span> <!-- -->: <span class="lg-highlight-string">"Dianne"</span>, <span class="lg-highlight-string">"task_object_size"</span> <!-- -->: <span class="lg-highlight-number">99</span> }</td></tr></tbody></table></code></pre> </div> </div> </div> </dd> <dt> Second Stage </dt> <dd class="css-1ufxuu7"> <p class="leafygreen-ui-1kp3ins"> The second stage <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/sort/#mongodb-pipeline-pipe.-sort"> <code class="leafygreen-ui-1l06pbn"> sorts </code> </a> the documents by <code class="leafygreen-ui-1l06pbn"> task_object_size </code> in descending order. </p> <p class="leafygreen-ui-1kp3ins"> This stage outputs the following documents to the next stage: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ \"_id\" : 2, \"name\" : \"Bob\", \"task_object_size\" : 152 }\n{ \"_id\" : 1, \"name\" : \"Alice\", \"task_object_size\" : 109 }\n{ \"_id\" : 4, \"name\" : \"Dianne\", \"task_object_size\" : 99 }\n{ \"_id\" : 3, \"name\" : \"Charlie\", \"task_object_size\" : null }","programmingLanguage":"JavaScript"} </script> <div class="css-1lju8ps"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-tyg50d"> <pre class="leafygreen-ui-1453az5" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">2</span>, <span class="lg-highlight-string">"name"</span> <!-- -->: <span class="lg-highlight-string">"Bob"</span>, <span class="lg-highlight-string">"task_object_size"</span> <!-- -->: <span class="lg-highlight-number">152</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">1</span>, <span class="lg-highlight-string">"name"</span> <!-- -->: <span class="lg-highlight-string">"Alice"</span>, <span class="lg-highlight-string">"task_object_size"</span> <!-- -->: <span class="lg-highlight-number">109</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">4</span>, <span class="lg-highlight-string">"name"</span> <!-- -->: <span class="lg-highlight-string">"Dianne"</span>, <span class="lg-highlight-string">"task_object_size"</span> <!-- -->: <span class="lg-highlight-number">99</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">3</span>, <span class="lg-highlight-string">"name"</span> <!-- -->: <span class="lg-highlight-string">"Charlie"</span>, <span class="lg-highlight-string">"task_object_size"</span> <!-- -->: <span class="lg-highlight-literal">null</span> }</td></tr></tbody></table></code></pre> </div> </div> </div> </dd> <dt> Third Stage </dt> <dd class="css-1ufxuu7"> <p class="leafygreen-ui-1kp3ins"> The third stage <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/limit/#mongodb-pipeline-pipe.-limit"> <code class="leafygreen-ui-1l06pbn"> limits </code> </a> the output documents to only return the document appearing first in the sort order: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ \"_id\" : 2, \"name\" : \"Bob\", \"task_object_size\" : 152 }","programmingLanguage":"JavaScript"} </script> <div class="css-1lju8ps"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1jheeh3"> <pre class="leafygreen-ui-1agdxuk" 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">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">2</span>, <span class="lg-highlight-string">"name"</span> <!-- -->: <span class="lg-highlight-string">"Bob"</span>, <span class="lg-highlight-string">"task_object_size"</span> <!-- -->: <span class="lg-highlight-number">152</span> }</td></tr></tbody></table></code></pre> </div> </div> </div> </dd> </dl> <div class="leafygreen-ui-13vw3ie" role="note"> <h2 class="leafygreen-ui-1fn4p2b"> Tip </h2> <h3 class="leafygreen-ui-144d5kf"> <strong> See also: </strong> </h3> <div class="leafygreen-ui-9mycqc"> <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/project/#mongodb-pipeline-pipe.-project"> <code class="leafygreen-ui-1l06pbn"> $project </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/sort/#mongodb-pipeline-pipe.-sort"> <code class="leafygreen-ui-1l06pbn"> $sort </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/limit/#mongodb-pipeline-pipe.-limit"> <code class="leafygreen-ui-1l06pbn"> $limit </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/strLenBytes/#mongodb-expression-exp.-strLenBytes"> <code class="leafygreen-ui-1l06pbn"> $strLenBytes </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/binarySize/#mongodb-expression-exp.-binarySize"> <code class="leafygreen-ui-1l06pbn"> $binarySize </code> </a> </p> </li> </ul> </div> </div> </section> </section> </section>
https://www.mongodb.com/docs/manual/tutorial/configure-oidc/
<section> <h1 class="contains-headerlink leafygreen-ui-41fr9s" weight="medium"> Configure Self-Managed MongoDB with OpenID Connect <a class="headerlink leafygreen-ui-1kepx47" href="#configure-self-managed-mongodb-with-openid-connect" 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="configure-self-managed-mongodb-with-openid-connect"> </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="#before-you-begin" target="_self"> <span> Before you Begin </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#steps" target="_self"> <span> Steps </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#learn-more" target="_self"> <span> Learn More </span> </a> </li> </ul> </div> <p class="leafygreen-ui-1kp3ins"> MongoDB Enterprise provides support for OpenID Connect Authentication. You can use OpenID Connect to configure single sign-on between your MongoDB database and a third-party identity provider. </p> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Before you Begin <a class="headerlink leafygreen-ui-1kepx47" href="#before-you-begin" 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="before-you-begin"> </div> </a> </h2> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Set up an OpenID Connect client profile with your chosen provider: <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://learn.microsoft.com/en-us/azure/active-directory/manage-apps/add-application-portal-setup-oidc-sso" rel="noopener noreferrer"> <span> Microsoft Azure AD </span> <svg alt="" aria-hidden="true" class="leafygreen-ui-1ie5kuq" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M13.823 2.4491C13.8201 2.30008 13.6999 2.17994 13.5509 2.17704L9.5062 2.09836C9.25654 2.09351 9.12821 2.39519 9.30482 2.5718L10.3856 3.65257L7.93433 6.10383C7.87964 6.15852 7.83047 6.21665 7.78683 6.27752L5.99909 8.06525C5.46457 8.59977 5.46457 9.4664 5.99909 10.0009C6.53361 10.5354 7.40023 10.5354 7.93475 10.0009L9.72249 8.21317C9.78336 8.16953 9.84148 8.12037 9.89618 8.06567L12.3474 5.61441L13.4282 6.69518C13.6048 6.87179 13.9065 6.74347 13.9016 6.4938L13.823 2.4491Z" fill="currentColor"> </path> <path d="M7.25 3.12893C7.66421 3.12893 8 3.46472 8 3.87893C8 4.29315 7.66421 4.62893 7.25 4.62893H4C3.72386 4.62893 3.5 4.85279 3.5 5.12893V11.9929C3.5 12.2691 3.72386 12.4929 4 12.4929H10.864C11.1401 12.4929 11.364 12.2691 11.364 11.9929V8.75C11.364 8.33579 11.6998 8 12.114 8C12.5282 8 12.864 8.33579 12.864 8.75V11.9929C12.864 13.0975 11.9686 13.9929 10.864 13.9929H4C2.89543 13.9929 2 13.0975 2 11.9929V5.12893C2 4.02436 2.89543 3.12893 4 3.12893H7.25Z" fill="currentColor"> </path> </svg> </a> or <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://help.okta.com/oie/en-us/Content/Topics/Apps/apps-about-oidc.htm" rel="noopener noreferrer"> <span> Okta </span> <svg alt="" aria-hidden="true" class="leafygreen-ui-1ie5kuq" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M13.823 2.4491C13.8201 2.30008 13.6999 2.17994 13.5509 2.17704L9.5062 2.09836C9.25654 2.09351 9.12821 2.39519 9.30482 2.5718L10.3856 3.65257L7.93433 6.10383C7.87964 6.15852 7.83047 6.21665 7.78683 6.27752L5.99909 8.06525C5.46457 8.59977 5.46457 9.4664 5.99909 10.0009C6.53361 10.5354 7.40023 10.5354 7.93475 10.0009L9.72249 8.21317C9.78336 8.16953 9.84148 8.12037 9.89618 8.06567L12.3474 5.61441L13.4282 6.69518C13.6048 6.87179 13.9065 6.74347 13.9016 6.4938L13.823 2.4491Z" fill="currentColor"> </path> <path d="M7.25 3.12893C7.66421 3.12893 8 3.46472 8 3.87893C8 4.29315 7.66421 4.62893 7.25 4.62893H4C3.72386 4.62893 3.5 4.85279 3.5 5.12893V11.9929C3.5 12.2691 3.72386 12.4929 4 12.4929H10.864C11.1401 12.4929 11.364 12.2691 11.364 11.9929V8.75C11.364 8.33579 11.6998 8 12.114 8C12.5282 8 12.864 8.33579 12.864 8.75V11.9929C12.864 13.0975 11.9686 13.9929 10.864 13.9929H4C2.89543 13.9929 2 13.0975 2 11.9929V5.12893C2 4.02436 2.89543 3.12893 4 3.12893H7.25Z" fill="currentColor"> </path> </svg> </a> . </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> When using <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/mongodb-shell/#mongodb-binary-bin.mongosh" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongosh </code> </span> </a> to connect, if you use the <code class="leafygreen-ui-1l06pbn"> oidcRedirectUri </code> option, the URI must match the configuration of the identity provider. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Ensure that you are on MongoDB Enterprise. </p> <p class="leafygreen-ui-1kp3ins"> To verify that you are using MongoDB Enterprise, pass the <code class="leafygreen-ui-1l06pbn"> --version </code> command line option to the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> or <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongos/#mongodb-binary-bin.mongos"> <code class="leafygreen-ui-1l06pbn"> mongos </code> : </a> </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"mongod --version","programmingLanguage":"Bash"} </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 bash leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">mongod --version</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"> In the output from this command, look for the string <code class="leafygreen-ui-1l06pbn"> modules: subscription </code> or <code class="leafygreen-ui-1l06pbn"> modules: enterprise </code> to confirm you are using the MongoDB Enterprise binaries. </p> </li> </ul> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Steps <a class="headerlink leafygreen-ui-1kepx47" href="#steps" 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="steps"> </div> </a> </h2> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"HowTo","steps":[{"@type":"HowToStep","text":"To configure the MongoDB server, enable the MONGODB-OIDC\nauthentication mechanism and use the oidcIdentityProviders\nto specify identity provider (IDP) configurations.You can configure the MongoDB server using your configuration file or the command line.To configure using your configuration file, specify two parameters in\nthe file:To configure using the command line, specify the following:","name":"Configure the MongoDB server"},{"@type":"HowToStep","text":"In the admin database, use the db.createRole() method to create\nroles that map the identity provider group roles to MongoDB roles.Use the following format to create roles:The oidcIdentityProviders parameter provides the authNamePrefix\nfield and the authorizationClaim field. For example:","name":"Create MongoDB roles"}],"name":"Steps","image":"https://webimages.mongodb.com/_com_assets/cms/kuyj2focmkbxv7gh3-stacked_default_slate_blue.svg?auto=format%252Ccompress"} </script> <div class="css-4nyere eccljxs0"> <div class="css-1nuklj8 e1ckbxcu1"> <div class="css-18fui5z e1ckbxcu0"> <div class="css-19lsqsq e1ckbxcu2"> 1 </div> </div> <div class="css-1ed38mk"> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Configure the MongoDB server <a class="headerlink leafygreen-ui-1kepx47" href="#configure-the-mongodb-server" 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="configure-the-mongodb-server"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> To configure the MongoDB server, enable the <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/security-oidc/#std-label-authentication-oidc"> MONGODB-OIDC </a> authentication mechanism and use the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/parameters/#mongodb-parameter-param.oidcIdentityProviders"> <code class="leafygreen-ui-1l06pbn"> oidcIdentityProviders </code> </a> to specify identity provider (IDP) configurations. </p> <p class="leafygreen-ui-1kp3ins"> You can configure the MongoDB server using your configuration file or the command line. </p> <div aria-hidden="true"> </div> <div class="leafygreen-ui-1b75luy" data-lgid="lg-tabs"> <div class="leafygreen-ui-jp7pox" id="tabs-7"> <div aria-label="Tabs to describe usage of command line/config file" aria-orientation="horizontal" class="leafygreen-ui-m8p1vb lg-ui-tab-list-0000" data-lgid="lg-tabs-tab_list" role="tablist"> <button aria-controls="_mod7ux3di" aria-selected="true" class="leafygreen-ui-1l773z1" data-text="" id="_bwxwlj4jk" name="" role="tab" tabindex="0"> <div class="leafygreen-ui-1nxuzmg"> Configuration file </div> </button> <button aria-controls="_r209ru88p" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_zd4u9ukd3" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Command line </div> </button> </div> <div class="leafygreen-ui-ov1ktg"> <div class="leafygreen-ui-1sg2lsz"> </div> </div> </div> <div class="lg-ui-tab-panels-0000" data-lgid="lg-tabs-tab_panels"> <div> <div aria-labelledby="_794j1nwpj" class="" id="_k3teuldyd" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <p class="leafygreen-ui-1kp3ins"> To configure using your configuration file, specify two parameters in the file: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"setParameter:\n authenticationMechanisms: MONGODB-OIDC\n oidcIdentityProviders: [ {\"issuer\": \"https://...\", ...} ]","programmingLanguage":"YAML"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" tabindex="-1"><code class="lg-highlight-hljs-light yaml leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-attr">setParameter:</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">authenticationMechanisms:</span> <span class="lg-highlight-string">MONGODB-OIDC</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">oidcIdentityProviders:</span> <!-- -->[<!-- --> <!-- -->{<span class="lg-highlight-attr">"issuer":</span> <span class="lg-highlight-string">"https://..."</span>,<!-- --> <span class="lg-highlight-string">...</span>} <!-- -->]</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> </div> </div> <div> <div aria-labelledby="_bc3kfw1y6" class="leafygreen-ui-38lglc" id="_qr7fi6x6t" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <p class="leafygreen-ui-1kp3ins"> To configure using the command line, specify the following: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"mongod --auth --setParameter authenticationMechanisms=MONGODB-OIDC --setParameter \\\n'oidcIdentityProviders=[ {\"issuer\": \"https://...\", ...} ]'"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" tabindex="-1"><code class="lg-highlight-hljs-light none leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">mongod --auth --setParameter authenticationMechanisms=MONGODB-OIDC --setParameter \</td></tr><tr class=""><td class="leafygreen-ui-7razhx">'oidcIdentityProviders=[ {"issuer": "https://...", ...} ]'</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> </div> </div> </div> </div> </section> </div> </div> <div class="css-1nuklj8 e1ckbxcu1"> <div class="css-18fui5z e1ckbxcu0"> <div class="css-19lsqsq e1ckbxcu2"> 2 </div> </div> <div class="css-1ed38mk"> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Create MongoDB roles <a class="headerlink leafygreen-ui-1kepx47" href="#create-mongodb-roles" 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="create-mongodb-roles"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> In the <code class="leafygreen-ui-1l06pbn"> admin </code> database, use the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/db.createRole/#mongodb-method-db.createRole"> <code class="leafygreen-ui-1l06pbn"> db.createRole() </code> </a> method to create roles that map the identity provider group roles to MongoDB roles. </p> <p class="leafygreen-ui-1kp3ins"> Use the following format to create roles: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"&lt;authnameprefix&gt;/&lt;authorizationclaim&gt;"} </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 none leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">&lt;authNamePrefix&gt;/&lt;authorizationClaim&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 <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/parameters/#mongodb-parameter-param.oidcIdentityProviders"> <code class="leafygreen-ui-1l06pbn"> oidcIdentityProviders </code> </a> parameter provides the <code class="leafygreen-ui-1l06pbn"> authNamePrefix </code> field and the <code class="leafygreen-ui-1l06pbn"> authorizationClaim </code> field. For example: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.createRole( {\n role: \"okta/Everyone\",\n privileges: [ ],\n roles: [ \"readWriteAnyDatabase\" ]\n } )","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">createRole</span>( <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">role</span>: <span class="lg-highlight-string">"okta/Everyone"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">privileges</span>: <!-- -->[ <!-- -->]<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">roles</span>: <!-- -->[ <span class="lg-highlight-string">"readWriteAnyDatabase"</span> ]</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> } )</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> </section> </div> </div> </div> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Learn More <a class="headerlink leafygreen-ui-1kepx47" href="#learn-more" 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="learn-more"> </div> </a> </h2> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/security-oidc/#std-label-authentication-oidc"> OpenID Connect Authentication </a> </p> </li> </ul> </section> </section>
https://www.mongodb.com/docs/manual/reference/method/db.logout/
<section> <h1 class="contains-headerlink leafygreen-ui-41fr9s" weight="medium"> db.logout() <a class="headerlink leafygreen-ui-1kepx47" href="#db.logout--" 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.logout--"> </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> </ul> </div> <dl class="method"> <dt> <code class="leafygreen-ui-1l06pbn"> db.logout() </code> <a class="headerlink leafygreen-ui-1kepx47" href="#mongodb-method-db.logout" title="Permalink to this definition"> <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="mongodb-method-db.logout"> </div> </a> </dt> <dd> <div> <p> <em> Deprecated <!-- --> since version <!-- --> 5.0 </em> . </p> </div> <p class="leafygreen-ui-1kp3ins"> Attempting to use the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-method-db.logout" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> db.logout() </code> </span> </a> method will write an error message to the log once per logout attempt. </p> <p class="leafygreen-ui-1kp3ins"> This method will be removed in a future release. </p> <p class="leafygreen-ui-1kp3ins"> Ends the current authentication session. This function has no effect if the current session is not authenticated. </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"> If you're not logged in and using authentication, <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-method-db.logout" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> db.logout() </code> </span> </a> has no effect. </p> <p class="leafygreen-ui-1kp3ins"> Because MongoDB allows users defined in one database to have privileges on another database, you must call <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-method-db.logout" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> db.logout() </code> </span> </a> while using the same database context that you authenticated to. </p> <p class="leafygreen-ui-1kp3ins"> If you authenticated to a database such as <code class="leafygreen-ui-1l06pbn"> users </code> or <code class="leafygreen-ui-1l06pbn"> $external </code> , you must issue <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-method-db.logout" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> db.logout() </code> </span> </a> against this database in order to successfully log out. </p> </div> </div> <div class="leafygreen-ui-vg7qwp" role="note"> <h2 class="leafygreen-ui-2xicti"> Example </h2> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> Use the <code class="leafygreen-ui-1l06pbn"> use &lt;database-name&gt; </code> helper in <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/mongodb-shell/#mongodb-binary-bin.mongosh" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongosh </code> </span> </a> , or the following <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/db.getSiblingDB/#mongodb-method-db.getSiblingDB"> <code class="leafygreen-ui-1l06pbn"> db.getSiblingDB() </code> </a> method in an interactive <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/mongodb-shell/#mongodb-binary-bin.mongosh" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongosh </code> </span> </a> session or in <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/mongodb-shell/#mongodb-binary-bin.mongosh" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongosh </code> </span> </a> shell scripts to change the <code class="leafygreen-ui-1l06pbn"> db </code> object: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db = db.getSiblingDB('&lt;database-name&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 <!-- -->= <!-- -->db.<span class="lg-highlight-title lg-highlight-function">getSiblingDB</span>(<span class="lg-highlight-string">'&lt;database-name&gt;'</span>)</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"> When you have set the database context and <code class="leafygreen-ui-1l06pbn"> db </code> object, you can use the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-method-db.logout" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> db.logout() </code> </span> </a> to log out of database as in the following operation: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.logout()","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">logout</span>(<!-- -->)</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> </div> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-method-db.logout" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> db.logout() </code> </span> </a> function provides a wrapper around the database command <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/command/logout/#mongodb-dbcommand-dbcmd.logout"> <code class="leafygreen-ui-1l06pbn"> logout </code> . </a> </p> </dd> </dl> <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"> This method is available in 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> <div class="leafygreen-ui-15mdk4" role="note"> <h2 class="leafygreen-ui-6n7b7d"> Note </h2> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> This command is supported in all MongoDB Atlas clusters. For information on Atlas support for all commands, see <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/atlas/unsupported-commands/" target="_self"> <span> Unsupported Commands <!-- --> . </span> </a> </p> </div> </div> <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>
https://www.mongodb.com/docs/manual/reference/method/KeyVault.getKeyByAltName/
<section> <h1 class="contains-headerlink leafygreen-ui-41fr9s" weight="medium"> KeyVault.getKeyByAltName() <a class="headerlink leafygreen-ui-1kepx47" href="#keyvault.getkeybyaltname--" 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="keyvault.getkeybyaltname--"> </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="#behavior" target="_self"> <span> Behavior </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#example" target="_self"> <span> Example </span> </a> </li> </ul> </div> <dl class="method"> <dt> <code class="leafygreen-ui-1l06pbn"> KeyVault.getKeyByAltName(keyAltName) </code> <a class="headerlink leafygreen-ui-1kepx47" href="#mongodb-method-KeyVault.getKeyByAltName" title="Permalink to this definition"> <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="mongodb-method-KeyVault.getKeyByAltName"> </div> </a> </dt> <dd> <p class="leafygreen-ui-1kp3ins"> Gets all data encryption keys with the specified <code class="leafygreen-ui-1l06pbn"> keyAltName </code> . </p> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-method-KeyVault.getKeyByAltName" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> getKeyByAltName() </code> </span> </a> has the following syntax: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"keyVault = db.getMongo().getKeyVault()\n\nkeyVault.getKeyByAltName(\"keyAltName\")"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" tabindex="-1"><code class="lg-highlight-hljs-light none leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">keyVault = db.getMongo().getKeyVault()</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><div class="leafygreen-ui-ihxujy"></div></td></tr><tr class=""><td class="leafygreen-ui-7razhx">keyVault.getKeyByAltName("keyAltName")</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> <table class="css-11h39yh e1nex8bq0"> <colgroup> <col class="field-name"/> <col class="field-body"/> </colgroup> <tbody> <tr class="css-x8snli"> <th> Returns <!-- --> : </th> <td> Document representing a matching data encryption key. </td> </tr> </tbody> </table> </dd> </dl> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Behavior <a class="headerlink leafygreen-ui-1kepx47" href="#behavior" 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="behavior"> </div> </a> </h2> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Requires Configuring Client-Side Field Level Encryption on Database Connection <a class="headerlink leafygreen-ui-1kepx47" href="#requires-configuring-client-side-field-level-encryption-on-database-connection" 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="requires-configuring-client-side-field-level-encryption-on-database-connection"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> The <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/mongodb-shell/#mongodb-binary-bin.mongosh" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongosh </code> </span> </a> client-side field level encryption methods require a database connection with client-side field level encryption enabled. If the current database connection was not initiated with client-side field level encryption enabled, either: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Use the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/Mongo/#mongodb-method-Mongo"> <code class="leafygreen-ui-1l06pbn"> Mongo() </code> </a> constructor from the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/mongodb-shell/#mongodb-binary-bin.mongosh" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongosh </code> </span> </a> to establish a connection with the required client-side field level encryption options. The <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/Mongo/#mongodb-method-Mongo"> <code class="leafygreen-ui-1l06pbn"> Mongo() </code> </a> method supports the following Key Management Service (KMS) providers for Customer Master Key (CMK) management: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/queryable-encryption/fundamentals/kms-providers/#std-label-qe-fundamentals-kms-providers-aws"> Amazon Web Services KMS </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/queryable-encryption/fundamentals/kms-providers/#std-label-qe-fundamentals-kms-providers-azure"> Azure Key Vault </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/queryable-encryption/fundamentals/kms-providers/#std-label-qe-fundamentals-kms-providers-gcp"> Google Cloud Platform KMS </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/queryable-encryption/fundamentals/kms-providers/#std-label-qe-fundamentals-kms-providers-local"> Locally Managed Key </a> </p> </li> </ul> <p class="leafygreen-ui-1kp3ins"> <em> or </em> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Use the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/mongodb-shell/#mongodb-binary-bin.mongosh" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongosh </code> </span> </a> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/mongodb-shell/reference/options/#std-label-mongosh-client-side-field-level-encryption-options" target="_self"> <span> command line options </span> </a> to establish a connection with the required options. The command line options only support the <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/queryable-encryption/fundamentals/kms-providers/#std-label-qe-fundamentals-kms-providers-aws"> Amazon Web Services KMS </a> provider for CMK management. </p> </li> </ul> </section> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Example <a class="headerlink leafygreen-ui-1kepx47" href="#example" 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="example"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> The following example uses a locally managed KMS for the client-side field level encryption configuration. </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"HowTo","steps":[{"@type":"HowToStep","text":"Start the mongosh client.","name":"Start mongosh"},{"@type":"HowToStep","text":"To configure client-side field level encryption for a locally\nmanaged key, generate a base64-encoded 96-byte string with no line\nbreaks.","name":"Generate Your Key"},{"@type":"HowToStep","text":"Create the client-side field level encryption options using the\ngenerated local key string:","name":"Create the Client-Side Field Level Encryption Options"},{"@type":"HowToStep","text":"Use the Mongo() constructor with the client-side field level\nencryption options configured to create a database connection. Replace\nthe mongodb://myMongo.example.net URI with the connection\nstring URI of the target cluster.","name":"Create Your Encrypted Client"}],"name":"Example","image":"https://webimages.mongodb.com/_com_assets/cms/kuyj2focmkbxv7gh3-stacked_default_slate_blue.svg?auto=format%252Ccompress"} </script> <div class="css-4nyere eccljxs0"> <div class="css-1nuklj8 e1ckbxcu1"> <div class="css-18fui5z e1ckbxcu0"> <div class="css-19lsqsq e1ckbxcu2"> 1 </div> </div> <div class="css-1ed38mk"> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Start mongosh <a class="headerlink leafygreen-ui-1kepx47" href="#start-mongosh" 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="start-mongosh"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> Start the <code class="leafygreen-ui-1l06pbn"> mongosh </code> client. </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"mongosh --nodb","programmingLanguage":"Bash"} </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 bash leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">mongosh --nodb</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> </section> </div> </div> <div class="css-1nuklj8 e1ckbxcu1"> <div class="css-18fui5z e1ckbxcu0"> <div class="css-19lsqsq e1ckbxcu2"> 2 </div> </div> <div class="css-1ed38mk"> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Generate Your Key <a class="headerlink leafygreen-ui-1kepx47" href="#generate-your-key" 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="generate-your-key"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> To configure client-side field level encryption for a locally managed key, generate a base64-encoded 96-byte string with no line breaks. </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"const TEST_LOCAL_KEY = require(\"crypto\").randomBytes(96).toString(\"base64\")","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-1q4bxgx" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-keyword">const</span> <span class="lg-highlight-variable lg-highlight-constant">TEST_LOCAL_KEY</span> <!-- -->= <span class="lg-highlight-built_in">require</span>(<span class="lg-highlight-string">"crypto"</span>).<span class="lg-highlight-title lg-highlight-function">randomBytes</span>(<span class="lg-highlight-number">96</span>).<span class="lg-highlight-title lg-highlight-function">toString</span>(<span class="lg-highlight-string">"base64"</span>)</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> </section> </div> </div> <div class="css-1nuklj8 e1ckbxcu1"> <div class="css-18fui5z e1ckbxcu0"> <div class="css-19lsqsq e1ckbxcu2"> 3 </div> </div> <div class="css-1ed38mk"> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Create the Client-Side Field Level Encryption Options <a class="headerlink leafygreen-ui-1kepx47" href="#create-the-client-side-field-level-encryption-options" 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="create-the-client-side-field-level-encryption-options"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> Create the client-side field level encryption options using the generated local key string: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":" var autoEncryptionOpts = {\n \"keyVaultNamespace\" : \"encryption.__dataKeys\",\n \"kmsProviders\" : {\n \"local\" : {\n \"key\" : BinData(0, TEST_LOCAL_KEY)\n }\n }\n }","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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"> <span class="lg-highlight-keyword">var</span> autoEncryptionOpts <!-- -->= <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"keyVaultNamespace"</span> <!-- -->: <span class="lg-highlight-string">"encryption.__dataKeys"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"kmsProviders"</span> <!-- -->: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"local"</span> <!-- -->: <!-- -->{</td></tr><tr class="leafygreen-ui-1wr1lm6"><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"key"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">BinData</span>(<span class="lg-highlight-number">0</span>, <span class="lg-highlight-variable lg-highlight-constant">TEST_LOCAL_KEY</span>)</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</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> </section> </div> </div> <div class="css-1nuklj8 e1ckbxcu1"> <div class="css-18fui5z e1ckbxcu0"> <div class="css-19lsqsq e1ckbxcu2"> 4 </div> </div> <div class="css-1ed38mk"> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Create Your Encrypted Client <a class="headerlink leafygreen-ui-1kepx47" href="#create-your-encrypted-client" 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="create-your-encrypted-client"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> Use the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/Mongo/#mongodb-method-Mongo"> <code class="leafygreen-ui-1l06pbn"> Mongo() </code> </a> constructor with the client-side field level encryption options configured to create a database connection. Replace the <code class="leafygreen-ui-1l06pbn"> mongodb://myMongo.example.net </code> URI with the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/connection-string/#std-label-mongodb-uri"> connection string URI </a> of the target cluster. </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"encryptedClient = Mongo(\n \"mongodb://myMongo.example.net:27017/?replSetName=myMongo\",\n autoEncryptionOpts\n)","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">encryptedClient <!-- -->= <span class="lg-highlight-title lg-highlight-class">Mongo</span>(</td></tr><tr class="leafygreen-ui-1wr1lm6"><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"mongodb://myMongo.example.net:27017/?replSetName=myMongo"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->autoEncryptionOpts</td></tr><tr class=""><td class="leafygreen-ui-7razhx">)</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> </section> </div> </div> </div> <p class="leafygreen-ui-1kp3ins"> Retrieve the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/getKeyVault/#mongodb-method-getKeyVault"> <code class="leafygreen-ui-1l06pbn"> KeyVault </code> </a> object and use the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-method-KeyVault.getKeyByAltName" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> KeyVault.getKeyByAltName() </code> </span> </a> method to retrieve the data encryption key whose <code class="leafygreen-ui-1l06pbn"> keyAltNames </code> array includes the specified key alternate name: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"keyVault.getKeyByAltName(\"data-encryption-key\")","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">keyVault.<span class="lg-highlight-title lg-highlight-function">getKeyByAltName</span>(<span class="lg-highlight-string">"data-encryption-key"</span>)</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"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-method-KeyVault.getKeyByAltName" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> getKeyByAltName() </code> </span> </a> returns the following data encryption key: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{\n \"_id\" : UUID(\"b4b41b33-5c97-412e-a02b-743498346079\"),\n \"keyMaterial\" : BinData(0,\"PXRsLOAYxhzTS/mFQAI8486da7BwZgqA91UI7NKz/T/AjB0uJZxTvhvmQQsKbCJYsWVS/cp5Rqy/FUX2zZwxJOJmI3rosPhzV0OI5y1cuXhAlLWlj03CnTcOSRzE/YIrsCjMB0/NyiZ7MRWUYzLAEQnE30d947XCiiHIb8a0kt2SD0so8vZvSuP2n0Vtz4NYqnzF0CkhZSWFa2e2yA==\"),\n \"creationDate\" : ISODate(\"2019-08-12T21:21:30.569Z\"),\n \"updateDate\" : ISODate(\"2019-08-12T21:21:30.569Z\"),\n \"status\" : 0,\n \"version\" : NumberLong(0),\n \"masterKey\" : {\n \"provider\" : \"local\"\n },\n \"keyAltNames\" : [\n \"data-encryption-key\"\n ]\n}","programmingLanguage":"JSON"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><code class="lg-highlight-hljs-light json leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-punctuation">{</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">"_id"</span> <span class="lg-highlight-punctuation">:</span> UUID(<span class="lg-highlight-string">"b4b41b33-5c97-412e-a02b-743498346079"</span>)<span class="lg-highlight-punctuation">,</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">"keyMaterial"</span> <span class="lg-highlight-punctuation">:</span> BinData(<span class="lg-highlight-number">0</span><span class="lg-highlight-punctuation">,</span><span class="lg-highlight-string">"PXRsLOAYxhzTS/mFQAI8486da7BwZgqA91UI7NKz/T/AjB0uJZxTvhvmQQsKbCJYsWVS/cp5Rqy/FUX2zZwxJOJmI3rosPhzV0OI5y1cuXhAlLWlj03CnTcOSRzE/YIrsCjMB0/NyiZ7MRWUYzLAEQnE30d947XCiiHIb8a0kt2SD0so8vZvSuP2n0Vtz4NYqnzF0CkhZSWFa2e2yA=="</span>)<span class="lg-highlight-punctuation">,</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">"creationDate"</span> <span class="lg-highlight-punctuation">:</span> ISODate(<span class="lg-highlight-string">"2019-08-12T21:21:30.569Z"</span>)<span class="lg-highlight-punctuation">,</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">"updateDate"</span> <span class="lg-highlight-punctuation">:</span> ISODate(<span class="lg-highlight-string">"2019-08-12T21:21:30.569Z"</span>)<span class="lg-highlight-punctuation">,</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">"status"</span> <span class="lg-highlight-punctuation">:</span> <span class="lg-highlight-number">0</span><span class="lg-highlight-punctuation">,</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">"version"</span> <span class="lg-highlight-punctuation">:</span> NumberLong(<span class="lg-highlight-number">0</span>)<span class="lg-highlight-punctuation">,</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">"masterKey"</span> <span class="lg-highlight-punctuation">:</span> <span class="lg-highlight-punctuation">{</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">"provider"</span> <span class="lg-highlight-punctuation">:</span> <span class="lg-highlight-string">"local"</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-punctuation">}</span><span class="lg-highlight-punctuation">,</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">"keyAltNames"</span> <span class="lg-highlight-punctuation">:</span> <span class="lg-highlight-punctuation">[</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"data-encryption-key"</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-punctuation">]</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-punctuation">}</span></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> </section> </section>
https://www.mongodb.com/docs/manual/reference/operator/aggregation/gt/
<section> <h1 class="contains-headerlink leafygreen-ui-41fr9s" weight="medium"> $gt (aggregation) <a class="headerlink leafygreen-ui-1kepx47" href="#-gt--aggregation-" 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="-gt--aggregation-"> </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="#definition" target="_self"> <span> Definition </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#example" target="_self"> <span> Example </span> </a> </li> </ul> </div> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Definition <a class="headerlink leafygreen-ui-1kepx47" href="#definition" 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="definition"> </div> </a> </h2> <dl class="expression"> <dt> <code class="leafygreen-ui-1l06pbn"> $gt </code> <a class="headerlink leafygreen-ui-1kepx47" href="#mongodb-expression-exp.-gt" title="Permalink to this definition"> <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="mongodb-expression-exp.-gt"> </div> </a> </dt> <dd> <p class="leafygreen-ui-1kp3ins"> Compares two values and returns: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <code class="leafygreen-ui-1l06pbn"> true </code> when the first value is <em> greater than </em> the second value. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <code class="leafygreen-ui-1l06pbn"> false </code> when the first value is <em> less than or equal to </em> the second value. </p> </li> </ul> <p class="leafygreen-ui-1kp3ins"> The <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-expression-exp.-gt" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $gt </code> </span> </a> compares both value and type, using the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/bson-type-comparison-order/#std-label-bson-types-comparison-order"> specified BSON comparison order </a> for values of different types. </p> <p class="leafygreen-ui-1kp3ins"> <code class="leafygreen-ui-1l06pbn"> $gt </code> has the following syntax: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ $gt: [ &lt;expression1&gt;, &lt;expression2&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">{ <span class="lg-highlight-attr">$gt</span>: <!-- -->[ &lt;<!-- -->expression1<!-- -->&gt;<!-- -->,<!-- --> <!-- -->&lt;<!-- -->expression2<!-- -->&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"> For more information on expressions, see <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/#std-label-aggregation-expressions"> Expression Operators <!-- --> . </a> </p> </dd> </dl> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Example <a class="headerlink leafygreen-ui-1kepx47" href="#example" 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="example"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> Create an <code class="leafygreen-ui-1l06pbn"> inventory </code> collection with these documents: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.inventory.insertMany( [\n { _id : 1, item : \"abc1\", description: \"product 1\", qty: 300 },\n { _id : 2, item : \"abc2\", description: \"product 2\", qty: 200 },\n { _id : 3, item : \"xyz1\", description: \"product 3\", qty: 250 },\n { _id : 4, item : \"VWZ1\", description: \"product 4\", qty: 300 },\n { _id : 5, item : \"VWZ2\", description: \"product 5\", qty: 180 }\n] )","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><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">inventory</span>.<span class="lg-highlight-title lg-highlight-function">insertMany</span>( <!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <!-- -->_id <!-- -->: <span class="lg-highlight-number">1</span>, <!-- -->item <!-- -->: <span class="lg-highlight-string">"abc1"</span>, <span class="lg-highlight-attr">description</span>: <span class="lg-highlight-string">"product 1"</span>, <span class="lg-highlight-attr">qty</span>: <span class="lg-highlight-number">300</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <!-- -->_id <!-- -->: <span class="lg-highlight-number">2</span>, <!-- -->item <!-- -->: <span class="lg-highlight-string">"abc2"</span>, <span class="lg-highlight-attr">description</span>: <span class="lg-highlight-string">"product 2"</span>, <span class="lg-highlight-attr">qty</span>: <span class="lg-highlight-number">200</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <!-- -->_id <!-- -->: <span class="lg-highlight-number">3</span>, <!-- -->item <!-- -->: <span class="lg-highlight-string">"xyz1"</span>, <span class="lg-highlight-attr">description</span>: <span class="lg-highlight-string">"product 3"</span>, <span class="lg-highlight-attr">qty</span>: <span class="lg-highlight-number">250</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <!-- -->_id <!-- -->: <span class="lg-highlight-number">4</span>, <!-- -->item <!-- -->: <span class="lg-highlight-string">"VWZ1"</span>, <span class="lg-highlight-attr">description</span>: <span class="lg-highlight-string">"product 4"</span>, <span class="lg-highlight-attr">qty</span>: <span class="lg-highlight-number">300</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <!-- -->_id <!-- -->: <span class="lg-highlight-number">5</span>, <!-- -->item <!-- -->: <span class="lg-highlight-string">"VWZ2"</span>, <span class="lg-highlight-attr">description</span>: <span class="lg-highlight-string">"product 5"</span>, <span class="lg-highlight-attr">qty</span>: <span class="lg-highlight-number">180</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">] )</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"> Use the <code class="leafygreen-ui-1l06pbn"> $gt </code> operator to determine if <code class="leafygreen-ui-1l06pbn"> qty </code> is greater than <code class="leafygreen-ui-1l06pbn"> 250 </code> : </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.inventory.aggregate(\n [\n {\n $project:\n {\n item: 1,\n qty: 1,\n qtyGt250: { $gt: [ \"$qty\", 250 ] },\n _id: 0\n }\n }\n ]\n)","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">inventory</span>.<span class="lg-highlight-title lg-highlight-function">aggregate</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">$project</span>:</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">item</span>: <span class="lg-highlight-number">1</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">qty</span>: <span class="lg-highlight-number">1</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">qtyGt250</span>: <!-- -->{ <span class="lg-highlight-attr">$gt</span>: <!-- -->[ <span class="lg-highlight-string">"$qty"</span>, <span class="lg-highlight-number">250</span> ] }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">0</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> ]</td></tr><tr class=""><td class="leafygreen-ui-7razhx">)</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 operation returns the following results: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ item : \"abc1\", qty : 300, qtyGt250 : true }\n{ item : \"abc2\", qty : 200, qtyGt250 : false }\n{ item : \"xyz1\", qty : 250, qtyGt250 : false }\n{ item : \"VWZ1\", qty : 300, qtyGt250 : true }\n{ item : \"VWZ2\", qty : 180, qtyGt250 : false }","programmingLanguage":"JavaScript"} </script> <div class="css-1lju8ps"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1jheeh3"> <pre class="leafygreen-ui-1453az5" 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">{ <!-- -->item <!-- -->: <span class="lg-highlight-string">"abc1"</span>, <!-- -->qty <!-- -->: <span class="lg-highlight-number">300</span>, <!-- -->qtyGt250 <!-- -->: <span class="lg-highlight-literal">true</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <!-- -->item <!-- -->: <span class="lg-highlight-string">"abc2"</span>, <!-- -->qty <!-- -->: <span class="lg-highlight-number">200</span>, <!-- -->qtyGt250 <!-- -->: <span class="lg-highlight-literal">false</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <!-- -->item <!-- -->: <span class="lg-highlight-string">"xyz1"</span>, <!-- -->qty <!-- -->: <span class="lg-highlight-number">250</span>, <!-- -->qtyGt250 <!-- -->: <span class="lg-highlight-literal">false</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <!-- -->item <!-- -->: <span class="lg-highlight-string">"VWZ1"</span>, <!-- -->qty <!-- -->: <span class="lg-highlight-number">300</span>, <!-- -->qtyGt250 <!-- -->: <span class="lg-highlight-literal">true</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <!-- -->item <!-- -->: <span class="lg-highlight-string">"VWZ2"</span>, <!-- -->qty <!-- -->: <span class="lg-highlight-number">180</span>, <!-- -->qtyGt250 <!-- -->: <span class="lg-highlight-literal">false</span> }</td></tr></tbody></table></code></pre> </div> </div> </div> </section> </section>
https://www.mongodb.com/docs/manual/reference/method/KeyVault.rewrapManyDataKey/
<section> <h1 class="contains-headerlink leafygreen-ui-41fr9s" weight="medium"> KeyVault.rewrapManyDataKey() <a class="headerlink leafygreen-ui-1kepx47" href="#keyvault.rewrapmanydatakey--" 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="keyvault.rewrapmanydatakey--"> </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="#behavior" target="_self"> <span> Behavior </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#example" target="_self"> <span> Example </span> </a> </li> </ul> </div> <dl class="method"> <dt> <code class="leafygreen-ui-1l06pbn"> KeyVault.rewrapManyDataKey(filter, options) </code> <a class="headerlink leafygreen-ui-1kepx47" href="#mongodb-method-KeyVault.rewrapManyDataKey" title="Permalink to this definition"> <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="mongodb-method-KeyVault.rewrapManyDataKey"> </div> </a> </dt> <dd> <p class="leafygreen-ui-1kp3ins"> Decrypts multiple Data Encryption Keys (DEK) and re-encrypts them with a new Customer Master Key (CMK). Use this method to rotate the CMK that encrypts your DEKs. To learn more about CMKs and DEKs, see <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/queryable-encryption/fundamentals/keys-key-vaults/#std-label-qe-reference-keys-key-vaults"> Encryption Keys and Key Vaults <!-- --> . </a> </p> <p class="leafygreen-ui-1kp3ins"> You specify a CMK through the <code class="leafygreen-ui-1l06pbn"> masterKey </code> parameter. If you do not include a <code class="leafygreen-ui-1l06pbn"> masterKey </code> argument, the method decrypts and encrypts each DEK with the CMK referenced in that DEK's metadata. To learn more about the metadata of DEKs, see <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/csfle/reference/decryption/#std-label-csfle-reference-decryption-metadata"> Metadata Used for Decryption <!-- --> . </a> </p> <p class="leafygreen-ui-1kp3ins"> <code class="leafygreen-ui-1l06pbn"> KeyVault.rewrapManyDataKey </code> has the following syntax: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"let keyVault = db.getMongo().getKeyVault()\n\nkeyVault.rewrapManyDataKey(\n &lt;filter&gt;,\n &lt;options&gt;\n)","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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"><span class="lg-highlight-keyword">let</span> keyVault <!-- -->= <!-- -->db.<span class="lg-highlight-title lg-highlight-function">getMongo</span>(<!-- -->).<span class="lg-highlight-title lg-highlight-function">getKeyVault</span>(<!-- -->)</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><div class="leafygreen-ui-ihxujy"></div></td></tr><tr class=""><td class="leafygreen-ui-7razhx">keyVault.<span class="lg-highlight-title lg-highlight-function">rewrapManyDataKey</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> &lt;<!-- -->filter<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->&lt;<!-- -->options<!-- -->&gt;</td></tr><tr class=""><td class="leafygreen-ui-7razhx">)</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: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> Parameter </div> </div> </th> <th class="leafygreen-ui-13uteka" role="columnheader" scope="col"> <div class="leafygreen-ui-ui0te9"> <div> Type </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> <code class="leafygreen-ui-1l06pbn"> filter </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/document/#std-label-document-query-filter"> query filter document </a> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> The query filter for the keyvault collection </div> </div> </td> </tr> <tr class=""> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> options </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> document </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <p class="leafygreen-ui-1kp3ins"> This document has two fields: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <code class="leafygreen-ui-1l06pbn"> provider </code> : A <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/queryable-encryption/fundamentals/kms-providers/#std-label-qe-fundamentals-kms-providers"> KMS provider </a> (AWS KMS, Azure Key Vault, GCP KMS, the local provider, or KMIP) </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <code class="leafygreen-ui-1l06pbn"> masterKey </code> : A KMS-specific key used to encrypt the new data key </p> </li> </ul> </div> </div> </td> </tr> </tbody> </table> </div> <table class="css-11h39yh e1nex8bq0"> <colgroup> <col class="field-name"/> <col class="field-body"/> </colgroup> <tbody> <tr class="css-x8snli"> <th> Returns <!-- --> : </th> <td> A <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/BulkWriteResult/#std-label-server-bulkwriteresult-method"> BulkWriteResult </a> object that reports how many data keys were affected. </td> </tr> </tbody> </table> </dd> </dl> <div class="leafygreen-ui-1sjx7ru" role="note"> <h2 class="leafygreen-ui-29m78u"> Warning </h2> <h3 class="leafygreen-ui-144d5kf"> <strong> Back-Up Your Key Vault collection </strong> </h3> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> Before you rotate your Data Encryption Keys, ensure you create a backup of your Key Vault collection. If you lose access to your Data Encryption Keys, you will lose all your encrypted data. </p> <p class="leafygreen-ui-1kp3ins"> To learn how to create a backup of a collection, see <a class="leafygreen-ui-tqgtui" href="/docs/manual/tutorial/backup-and-restore-tools/#std-label-manual-tutorial-backup-and-restore"> Back Up and Restore a Self-Managed Deployment with MongoDB Tools <!-- --> . </a> </p> </div> </div> <div class="leafygreen-ui-85da11" role="note"> <h2 class="leafygreen-ui-1ac4g5h"> Important </h2> <h3 class="leafygreen-ui-144d5kf"> <strong> Key Rotation Support </strong> </h3> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> To view your driver's dependencies for the key rotation API, see <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/queryable-encryption/reference/compatibility/#std-label-csfle-reference-compatibility-key-rotation"> Compatibility <!-- --> . </a> </p> </div> </div> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Behavior <a class="headerlink leafygreen-ui-1kepx47" href="#behavior" 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="behavior"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> This operation is not atomic and should not be run in parallel with other key management operations. </p> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Requires Configuring Client-Side Field Level Encryption on Database Connection <a class="headerlink leafygreen-ui-1kepx47" href="#requires-configuring-client-side-field-level-encryption-on-database-connection" 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="requires-configuring-client-side-field-level-encryption-on-database-connection"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> The <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/mongodb-shell/#mongodb-binary-bin.mongosh" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongosh </code> </span> </a> client-side field level encryption methods require a database connection with client-side field level encryption enabled. If the current database connection was not initiated with client-side field level encryption enabled, either: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Use the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/Mongo/#mongodb-method-Mongo"> <code class="leafygreen-ui-1l06pbn"> Mongo() </code> </a> constructor from the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/mongodb-shell/#mongodb-binary-bin.mongosh" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongosh </code> </span> </a> to establish a connection with the required client-side field level encryption options. The <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/Mongo/#mongodb-method-Mongo"> <code class="leafygreen-ui-1l06pbn"> Mongo() </code> </a> method supports the following Key Management Service (KMS) providers for Customer Master Key (CMK) management: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/queryable-encryption/fundamentals/kms-providers/#std-label-qe-fundamentals-kms-providers-aws"> Amazon Web Services KMS </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/queryable-encryption/fundamentals/kms-providers/#std-label-qe-fundamentals-kms-providers-azure"> Azure Key Vault </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/queryable-encryption/fundamentals/kms-providers/#std-label-qe-fundamentals-kms-providers-gcp"> Google Cloud Platform KMS </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/queryable-encryption/fundamentals/kms-providers/#std-label-qe-fundamentals-kms-providers-local"> Locally Managed Key </a> </p> </li> </ul> <p class="leafygreen-ui-1kp3ins"> <em> or </em> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Use the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/mongodb-shell/#mongodb-binary-bin.mongosh" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongosh </code> </span> </a> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/mongodb-shell/reference/options/#std-label-mongosh-client-side-field-level-encryption-options" target="_self"> <span> command line options </span> </a> to establish a connection with the required options. The command line options only support the <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/queryable-encryption/fundamentals/kms-providers/#std-label-qe-fundamentals-kms-providers-aws"> Amazon Web Services KMS </a> provider for CMK management. </p> </li> </ul> </section> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Example <a class="headerlink leafygreen-ui-1kepx47" href="#example" 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="example"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> These examples allow you to rapidly evaluate client-side field level encryption. For specific examples using each supported <span class="leafygreen-ui-vm4wms" tabindex="0"> KMS </span> provider, see <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/csfle/fundamentals/manage-keys/#std-label-field-level-encryption-data-key-manage"> Encryption Key Management <!-- --> . </a> </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"HowTo","steps":[{"@type":"HowToStep","text":"Start the mongosh client.","name":"Start mongosh"},{"@type":"HowToStep","text":"To configure client-side field level encryption for a locally\nmanaged key, generate a base64-encoded 96-byte string with no line\nbreaks.","name":"Generate Your Key"},{"@type":"HowToStep","text":"Create the client-side field level encryption options using the\ngenerated local key string:","name":"Create the Client-Side Field Level Encryption Options"},{"@type":"HowToStep","text":"Use the Mongo() constructor with the client-side field level\nencryption options configured to create a database connection. Replace\nthe mongodb://myMongo.example.net URI with the connection\nstring URI of the target cluster.","name":"Create Your Encrypted Client"}],"name":"Example","image":"https://webimages.mongodb.com/_com_assets/cms/kuyj2focmkbxv7gh3-stacked_default_slate_blue.svg?auto=format%252Ccompress"} </script> <div class="css-4nyere eccljxs0"> <div class="css-1nuklj8 e1ckbxcu1"> <div class="css-18fui5z e1ckbxcu0"> <div class="css-19lsqsq e1ckbxcu2"> 1 </div> </div> <div class="css-1ed38mk"> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Start mongosh <a class="headerlink leafygreen-ui-1kepx47" href="#start-mongosh" 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="start-mongosh"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> Start the <code class="leafygreen-ui-1l06pbn"> mongosh </code> client. </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"mongosh --nodb","programmingLanguage":"Bash"} </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 bash leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">mongosh --nodb</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> </section> </div> </div> <div class="css-1nuklj8 e1ckbxcu1"> <div class="css-18fui5z e1ckbxcu0"> <div class="css-19lsqsq e1ckbxcu2"> 2 </div> </div> <div class="css-1ed38mk"> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Generate Your Key <a class="headerlink leafygreen-ui-1kepx47" href="#generate-your-key" 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="generate-your-key"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> To configure client-side field level encryption for a locally managed key, generate a base64-encoded 96-byte string with no line breaks. </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"const TEST_LOCAL_KEY = require(\"crypto\").randomBytes(96).toString(\"base64\")","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-1q4bxgx" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-keyword">const</span> <span class="lg-highlight-variable lg-highlight-constant">TEST_LOCAL_KEY</span> <!-- -->= <span class="lg-highlight-built_in">require</span>(<span class="lg-highlight-string">"crypto"</span>).<span class="lg-highlight-title lg-highlight-function">randomBytes</span>(<span class="lg-highlight-number">96</span>).<span class="lg-highlight-title lg-highlight-function">toString</span>(<span class="lg-highlight-string">"base64"</span>)</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> </section> </div> </div> <div class="css-1nuklj8 e1ckbxcu1"> <div class="css-18fui5z e1ckbxcu0"> <div class="css-19lsqsq e1ckbxcu2"> 3 </div> </div> <div class="css-1ed38mk"> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Create the Client-Side Field Level Encryption Options <a class="headerlink leafygreen-ui-1kepx47" href="#create-the-client-side-field-level-encryption-options" 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="create-the-client-side-field-level-encryption-options"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> Create the client-side field level encryption options using the generated local key string: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":" var autoEncryptionOpts = {\n \"keyVaultNamespace\" : \"encryption.__dataKeys\",\n \"kmsProviders\" : {\n \"local\" : {\n \"key\" : BinData(0, TEST_LOCAL_KEY)\n }\n }\n }","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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"> <span class="lg-highlight-keyword">var</span> autoEncryptionOpts <!-- -->= <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"keyVaultNamespace"</span> <!-- -->: <span class="lg-highlight-string">"encryption.__dataKeys"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"kmsProviders"</span> <!-- -->: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"local"</span> <!-- -->: <!-- -->{</td></tr><tr class="leafygreen-ui-1wr1lm6"><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"key"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">BinData</span>(<span class="lg-highlight-number">0</span>, <span class="lg-highlight-variable lg-highlight-constant">TEST_LOCAL_KEY</span>)</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</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> </section> </div> </div> <div class="css-1nuklj8 e1ckbxcu1"> <div class="css-18fui5z e1ckbxcu0"> <div class="css-19lsqsq e1ckbxcu2"> 4 </div> </div> <div class="css-1ed38mk"> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Create Your Encrypted Client <a class="headerlink leafygreen-ui-1kepx47" href="#create-your-encrypted-client" 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="create-your-encrypted-client"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> Use the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/Mongo/#mongodb-method-Mongo"> <code class="leafygreen-ui-1l06pbn"> Mongo() </code> </a> constructor with the client-side field level encryption options configured to create a database connection. Replace the <code class="leafygreen-ui-1l06pbn"> mongodb://myMongo.example.net </code> URI with the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/connection-string/#std-label-mongodb-uri"> connection string URI </a> of the target cluster. </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"encryptedClient = Mongo(\n \"mongodb://myMongo.example.net:27017/?replSetName=myMongo\",\n autoEncryptionOpts\n)","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">encryptedClient <!-- -->= <span class="lg-highlight-title lg-highlight-class">Mongo</span>(</td></tr><tr class="leafygreen-ui-1wr1lm6"><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"mongodb://myMongo.example.net:27017/?replSetName=myMongo"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->autoEncryptionOpts</td></tr><tr class=""><td class="leafygreen-ui-7razhx">)</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> </section> </div> </div> </div> <p class="leafygreen-ui-1kp3ins"> Retrieve the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/getKeyVault/#mongodb-method-getKeyVault"> <code class="leafygreen-ui-1l06pbn"> KeyVault </code> </a> object and use the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-method-KeyVault.rewrapManyDataKey" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> KeyVault.rewrapManyDataKey() </code> </span> </a> method to rewrap the existing keys in a new <code class="leafygreen-ui-1l06pbn"> masterKey </code> . If no new <code class="leafygreen-ui-1l06pbn"> masterKey </code> is given, each data key retains its respective current <code class="leafygreen-ui-1l06pbn"> masterKey </code> . </p> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Rewrap Data Keys with the Current masterKey <a class="headerlink leafygreen-ui-1kepx47" href="#rewrap-data-keys-with-the-current-masterkey" 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="rewrap-data-keys-with-the-current-masterkey"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> The following example shows how you can rewrap each data key with its respective current <code class="leafygreen-ui-1l06pbn"> masterKey </code> : </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"let keyVault = mongo.getKeyVault()\n\nkeyVault.rewrapManyDataKey()","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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"><span class="lg-highlight-keyword">let</span> keyVault <!-- -->= <!-- -->mongo.<span class="lg-highlight-title lg-highlight-function">getKeyVault</span>(<!-- -->)</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><div class="leafygreen-ui-ihxujy"></div></td></tr><tr class=""><td class="leafygreen-ui-7razhx">keyVault.<span class="lg-highlight-title lg-highlight-function">rewrapManyDataKey</span>(<!-- -->)</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> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Rewrap Data Keys with a New masterKey <a class="headerlink leafygreen-ui-1kepx47" href="#rewrap-data-keys-with-a-new-masterkey" 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="rewrap-data-keys-with-a-new-masterkey"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> The following example shows how you can rewrap each data key with a new <code class="leafygreen-ui-1l06pbn"> masterKey </code> : </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"let keyVault = mongo.getKeyVault()\n\nkeyVault.rewrapManyDataKey({}, {\n provider: 'aws',\n masterKey: {\n region: 'us-east-2',\n key: 'arn:aws:kms:us-east-2:...'\n }\n})","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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"><span class="lg-highlight-keyword">let</span> keyVault <!-- -->= <!-- -->mongo.<span class="lg-highlight-title lg-highlight-function">getKeyVault</span>(<!-- -->)</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><div class="leafygreen-ui-ihxujy"></div></td></tr><tr class=""><td class="leafygreen-ui-7razhx">keyVault.<span class="lg-highlight-title lg-highlight-function">rewrapManyDataKey</span>(<!-- -->{<!-- -->}<!-- -->, <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">provider</span>: <span class="lg-highlight-string">'aws'</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">masterKey</span>: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">region</span>: <span class="lg-highlight-string">'us-east-2'</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">key</span>: <span class="lg-highlight-string">'arn:aws:kms:us-east-2:...'</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">})</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> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Rewrap Data Keys That Have Not Been Rewrapped Recently <a class="headerlink leafygreen-ui-1kepx47" href="#rewrap-data-keys-that-have-not-been-rewrapped-recently" 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="rewrap-data-keys-that-have-not-been-rewrapped-recently"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> The following example shows how to rewrap data keys that have not been rewrapped in the previous thirty days. </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"let keyVault = mongo.getKeyVault()\n\nconst thirtyDaysAgo = new Date(Date.now() - 30 * 24 * 60 * 60 * 1000);\n\nkeyVault.rewrapManyDataKey({ updateDate: { $lt: thirtyDaysAgo } });","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-keyword">let</span> keyVault <!-- -->= <!-- -->mongo.<span class="lg-highlight-title lg-highlight-function">getKeyVault</span>(<!-- -->)</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><div class="leafygreen-ui-ihxujy"></div></td></tr><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-keyword">const</span> thirtyDaysAgo <!-- -->= <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">Date</span>(<span class="lg-highlight-title lg-highlight-class">Date</span>.<span class="lg-highlight-title lg-highlight-function">now</span>(<!-- -->) <!-- -->- <span class="lg-highlight-number">30</span> <!-- -->* <span class="lg-highlight-number">24</span> <!-- -->* <span class="lg-highlight-number">60</span> <!-- -->* <span class="lg-highlight-number">60</span> <!-- -->* <span class="lg-highlight-number">1000</span>)<!-- -->;</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><div class="leafygreen-ui-ihxujy"></div></td></tr><tr class=""><td class="leafygreen-ui-7razhx">keyVault.<span class="lg-highlight-title lg-highlight-function">rewrapManyDataKey</span>(<!-- -->{ <span class="lg-highlight-attr">updateDate</span>: <!-- -->{ <span class="lg-highlight-attr">$lt</span>: <!-- -->thirtyDaysAgo } })<!-- -->;</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> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Output <a class="headerlink leafygreen-ui-1kepx47" href="#output" 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="output"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-method-KeyVault.rewrapManyDataKey" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> KeyVault.rewrapManyDataKey() </code> </span> </a> returns a <code class="leafygreen-ui-1l06pbn"> BulkWriteResult </code> object detailing how many data keys were affected: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{\n bulkWriteResult: BulkWriteResult {\n result: {\n ok: 1,\n writeErrors: [],\n writeConcernErrors: [],\n insertedIds: [],\n nInserted: 0,\n nUpserted: 0,\n nMatched: 3,\n nModified: 3,\n nRemoved: 0,\n upserted: [],\n opTime: { ts: Timestamp({ t: 1655840760, i: 3 }), t: 23 }\n }\n }\n}","programmingLanguage":"JSON"} </script> <div class="css-1lju8ps"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-tyg50d"> <pre class="leafygreen-ui-1453az5" tabindex="0"><code class="lg-highlight-hljs-light json leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-punctuation">{</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> bulkWriteResult<span class="lg-highlight-punctuation">:</span> BulkWriteResult <span class="lg-highlight-punctuation">{</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> result<span class="lg-highlight-punctuation">:</span> <span class="lg-highlight-punctuation">{</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> ok<span class="lg-highlight-punctuation">:</span> <span class="lg-highlight-number">1</span><span class="lg-highlight-punctuation">,</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> writeErrors<span class="lg-highlight-punctuation">:</span> <span class="lg-highlight-punctuation">[</span><span class="lg-highlight-punctuation">]</span><span class="lg-highlight-punctuation">,</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> writeConcernErrors<span class="lg-highlight-punctuation">:</span> <span class="lg-highlight-punctuation">[</span><span class="lg-highlight-punctuation">]</span><span class="lg-highlight-punctuation">,</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> insertedIds<span class="lg-highlight-punctuation">:</span> <span class="lg-highlight-punctuation">[</span><span class="lg-highlight-punctuation">]</span><span class="lg-highlight-punctuation">,</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> nInserted<span class="lg-highlight-punctuation">:</span> <span class="lg-highlight-number">0</span><span class="lg-highlight-punctuation">,</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> nUpserted<span class="lg-highlight-punctuation">:</span> <span class="lg-highlight-number">0</span><span class="lg-highlight-punctuation">,</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> nMatched<span class="lg-highlight-punctuation">:</span> <span class="lg-highlight-number">3</span><span class="lg-highlight-punctuation">,</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> nModified<span class="lg-highlight-punctuation">:</span> <span class="lg-highlight-number">3</span><span class="lg-highlight-punctuation">,</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> nRemoved<span class="lg-highlight-punctuation">:</span> <span class="lg-highlight-number">0</span><span class="lg-highlight-punctuation">,</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> upserted<span class="lg-highlight-punctuation">:</span> <span class="lg-highlight-punctuation">[</span><span class="lg-highlight-punctuation">]</span><span class="lg-highlight-punctuation">,</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> opTime<span class="lg-highlight-punctuation">:</span> <span class="lg-highlight-punctuation">{</span> ts<span class="lg-highlight-punctuation">:</span> Timestamp(<span class="lg-highlight-punctuation">{</span> t<span class="lg-highlight-punctuation">:</span> <span class="lg-highlight-number">1655840760</span><span class="lg-highlight-punctuation">,</span> i<span class="lg-highlight-punctuation">:</span> <span class="lg-highlight-number">3</span> <span class="lg-highlight-punctuation">}</span>)<span class="lg-highlight-punctuation">,</span> t<span class="lg-highlight-punctuation">:</span> <span class="lg-highlight-number">23</span> <span class="lg-highlight-punctuation">}</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-punctuation">}</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-punctuation">}</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-punctuation">}</span></td></tr></tbody></table></code></pre> </div> </div> </div> </section> </section> </section>
https://www.mongodb.com/docs/manual/core/indexes/index-types/index-single/
<section> <h1 class="contains-headerlink leafygreen-ui-41fr9s" weight="medium"> Single Field Indexes <a class="headerlink leafygreen-ui-1kepx47" href="#single-field-indexes" 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="single-field-indexes"> </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="#use-cases" target="_self"> <span> Use Cases </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#get-started" target="_self"> <span> Get Started </span> </a> </li> </ul> </div> <p class="leafygreen-ui-1kp3ins"> Single field indexes store information from a single field in a collection. By default, all collections have an index on the <a class="leafygreen-ui-tqgtui" href="/docs/manual/indexes/#std-label-index-type-id"> _id field </a> . You can add additional indexes to speed up important queries and operations. </p> <p class="leafygreen-ui-1kp3ins"> You can create a single-field index on any field in a document, including: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Top-level document fields </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Embedded documents </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Fields within embedded documents </p> </li> </ul> <p class="leafygreen-ui-1kp3ins"> When you create an index, you specify: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> The field on which to create the index. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> The sort order for the indexed values (ascending or descending). </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> A sort order of <code class="leafygreen-ui-1l06pbn"> 1 </code> sorts values in ascending order. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> A sort order of <code class="leafygreen-ui-1l06pbn"> -1 </code> sorts values in descending order. </p> </li> </ul> </li> </ul> <div class="leafygreen-ui-85da11" role="note"> <h2 class="leafygreen-ui-1ac4g5h"> Important </h2> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> Using a descending single-field index may negatively impact index performance. For best performance, only use ascending single-field indexes. </p> </div> </div> <p class="leafygreen-ui-1kp3ins"> To create a single-field index, use the following prototype: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.&lt;collection&gt;.createIndex( { &lt;field&gt;: 1 } )","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.&lt;collection&gt;.<span class="lg-highlight-title lg-highlight-function">createIndex</span>( { &lt;field&gt;: <span class="lg-highlight-number">1</span> } )</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"> This image shows an ascending index on a single field, <code class="leafygreen-ui-1l06pbn"> score </code> : </p> <div class="figure css-5vkxs0" style="width: 720px;"> <img alt="Diagram of an index on the ``score`` field (ascending)." class="leafygreen-ui-1qnf57e" height="250" src="/docs/manual/images/index-ascending.bakedsvg.svg" style="--border-color: #C1C7C6;" width="720"/> </div> <p class="leafygreen-ui-1kp3ins"> In this example, each document in the collection that has a value for the <code class="leafygreen-ui-1l06pbn"> score </code> field is added to the index in ascending order. </p> <a class="css-53dzkk" href="https://www.mongodb.com/docs/atlas/atlas-ui/indexes/"> <div class="css-z0l49d"> <div class="css-fw7ipj"> <svg aria-label="Cloud Icon" class="leafygreen-ui-1t2jgtk" fill="none" height="16" role="img" viewbox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"> <path d="M12.571 8.143c0 1.775-.899 3.34-2.267 4.264l-.014.01a5.12 5.12 0 0 1-2.861.869H2.857a2.857 2.857 0 0 1-.545-5.663 5.144 5.144 0 0 1 10.26.52ZM13.821 8.143a6.38 6.38 0 0 1-2.358 4.96 3.429 3.429 0 1 0 2.17-6.506c.123.494.188 1.013.188 1.546Z" fill="currentColor"> </path> </svg> </div> <p class="leafygreen-ui-1kp3ins"> You can <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/atlas/atlas-ui/indexes/" target="_self"> <span> create and manage single field indexes in the UI </span> </a> for deployments hosted in <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> </p> </div> </a> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Use Cases <a class="headerlink leafygreen-ui-1kepx47" href="#use-cases" 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="use-cases"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> If your application repeatedly runs queries on the same field, you can create an index on that field to improve performance. For example, your human resources department often needs to look up employees by employee ID. You can create an index on the employee ID field to improve the performance of that query. </p> <p class="leafygreen-ui-1kp3ins"> Indexing commonly queried fields increases the chances of <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/query-optimization/#std-label-indexes-covered-queries"> covering </a> those queries. Covered queries are queries that can be satisfied entirely using an index, without examining any documents. This optimizes query performance. </p> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Get Started <a class="headerlink leafygreen-ui-1kepx47" href="#get-started" 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="get-started"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> To create an index on a single field, see these examples: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/indexes/index-types/index-single/create-single-field-index/#std-label-index-create-ascending-single-field"> Create an Index on a Single Field </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/indexes/index-types/index-single/create-single-field-index/#std-label-index-embedded-fields"> Create an Index on an Embedded Field </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/indexes/index-types/index-single/create-embedded-object-index/#std-label-index-embedded-documents"> Create an Index on an Embedded Document </a> </p> </li> </ul> </section> </section>
https://www.mongodb.com/docs/manual/reference/method/rs.reconfig/
<section> <h1 class="contains-headerlink leafygreen-ui-41fr9s" weight="medium"> rs.reconfig() <a class="headerlink leafygreen-ui-1kepx47" href="#rs.reconfig--" 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="rs.reconfig--"> </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="#definition" target="_self"> <span> Definition </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#behavior" target="_self"> <span> Behavior </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#examples" target="_self"> <span> Examples </span> </a> </li> </ul> </div> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Definition <a class="headerlink leafygreen-ui-1kepx47" href="#definition" 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="definition"> </div> </a> </h2> <dl class="method"> <dt> <code class="leafygreen-ui-1l06pbn"> rs.reconfig( configuration, { options } ) </code> <a class="headerlink leafygreen-ui-1kepx47" href="#mongodb-method-rs.reconfig" title="Permalink to this definition"> <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="mongodb-method-rs.reconfig"> </div> </a> </dt> <dd> <p class="leafygreen-ui-1kp3ins"> Reconfigures an existing replica set, overwriting the existing replica set configuration. To run the method, you must connect to the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-primary"> primary </a> of the replica set. </p> <div class="leafygreen-ui-85da11" role="note"> <h2 class="leafygreen-ui-1ac4g5h"> Important </h2> <h3 class="leafygreen-ui-144d5kf"> <strong> mongosh Method </strong> </h3> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> This page documents a <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/mongodb-shell/#mongodb-binary-bin.mongosh" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongosh </code> </span> </a> method. This is <em> not </em> the documentation for database commands or language-specific drivers, such as Node.js. </p> <p class="leafygreen-ui-1kp3ins"> For the database command, see the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/command/replSetReconfig/#mongodb-dbcommand-dbcmd.replSetReconfig"> <code class="leafygreen-ui-1l06pbn"> replSetReconfig </code> </a> command <!-- --> . </p> <p class="leafygreen-ui-1kp3ins"> For MongoDB API drivers, refer to the language-specific <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/drivers/" target="_self"> <span> MongoDB driver documentation <!-- --> . </span> </a> </p> </div> </div> <p class="leafygreen-ui-1kp3ins"> The <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-method-rs.reconfig" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> rs.reconfig() </code> </span> </a> method has the following syntax: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"rs.reconfig(\n &lt;configuration&gt;,\n {\n \"force\" : &lt;boolean&gt;,\n \"maxTimeMS\" : &lt;int&gt;\n }\n)","programmingLanguage":"Bash"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" tabindex="-1"><code class="lg-highlight-hljs-light bash leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">rs.reconfig(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> &lt;configuration&gt;,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> {</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"force"</span> : &lt;boolean&gt;,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"maxTimeMS"</span> : &lt;int&gt;</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">)</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: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> Parameter </div> </div> </th> <th class="leafygreen-ui-13uteka" role="columnheader" scope="col"> <div class="leafygreen-ui-ui0te9"> <div> Type </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> <span class="leafygreen-ui-1qnjd6d" id="std-label-rs-reconfig-method-configuration"> </span> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-rs-reconfig-method-configuration" target="_self"> <span> configuration </span> </a> </p> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> document </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> A <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/replica-configuration/#std-label-replica-set-configuration-settings"> document </a> that specifies the configuration of a replica set. </div> </div> </td> </tr> <tr class=""> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <span class="leafygreen-ui-1qnjd6d" id="std-label-rs-reconfig-method-force"> </span> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-rs-reconfig-method-force" target="_self"> <span> force </span> </a> </p> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> boolean </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <p class="leafygreen-ui-1kp3ins"> <em> Optional </em> </p> <p class="leafygreen-ui-1kp3ins"> Specify <code class="leafygreen-ui-1l06pbn"> true </code> to force the available replica set members to accept the new configuration. Defaults to <code class="leafygreen-ui-1l06pbn"> false </code> . </p> <p class="leafygreen-ui-1kp3ins"> Force reconfiguration can result in unexpected or undesired behavior, including <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/replica-set-rollbacks/#std-label-replica-set-rollbacks"> rollback </a> of <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/write-concern/#mongodb-writeconcern-writeconcern.-majority-"> <code class="leafygreen-ui-1l06pbn"> "majority" </code> </a> committed writes. </p> </div> </div> </td> </tr> <tr class=""> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <span class="leafygreen-ui-1qnjd6d" id="std-label-rs-reconfig-method-maxTimeMS"> </span> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-rs-reconfig-method-maxTimeMS" target="_self"> <span> maxTimeMS </span> </a> </p> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> integer </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <p class="leafygreen-ui-1kp3ins"> <em> Optional </em> </p> <p class="leafygreen-ui-1kp3ins"> Specifies a cumulative time limit in milliseconds for processing the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-method-rs.reconfig" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> rs.reconfig() </code> </span> </a> operation. By default, <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-method-rs.reconfig" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> rs.reconfig() </code> </span> </a> waits indefinitely for the replica configuration to propagate to a majority of replica set members. </p> </div> </div> </td> </tr> </tbody> </table> </div> <p class="leafygreen-ui-1kp3ins"> To reconfigure an existing replica set, first retrieve the current configuration with <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/rs.conf/#mongodb-method-rs.conf"> <code class="leafygreen-ui-1l06pbn"> rs.conf() </code> </a> , modify the configuration document as needed, and then pass the modified document to <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-method-rs.reconfig" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> rs.reconfig() </code> . </span> </a> </p> <p class="leafygreen-ui-1kp3ins"> The <code class="leafygreen-ui-1l06pbn"> force </code> parameter allows a reconfiguration command to be issued to a non-primary node. </p> </dd> </dl> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Behavior <a class="headerlink leafygreen-ui-1kepx47" href="#behavior" 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="behavior"> </div> </a> </h2> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Global Write Concern <a class="headerlink leafygreen-ui-1kepx47" href="#global-write-concern" 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="global-write-concern"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> Starting in MongoDB 5.0, you must explicitly set the global default <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/write-concern/#std-label-write-concern"> write concern </a> before attempting to reconfigure a <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-replica-set"> replica set </a> with a <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/replica-configuration/#std-label-replica-set-configuration-settings"> configuration </a> that would change the implicit default write concern. To set the global default write concern, use the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/command/setDefaultRWConcern/#mongodb-dbcommand-dbcmd.setDefaultRWConcern"> <code class="leafygreen-ui-1l06pbn"> setDefaultRWConcern </code> </a> command. </p> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> <code class="leafygreen-ui-1l06pbn"> term </code> Replica Configuration Field <a class="headerlink leafygreen-ui-1kepx47" href="#term-replica-configuration-field" 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="term-replica-configuration-field"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> The <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/replica-configuration/#mongodb-rsconf-rsconf.term"> <code class="leafygreen-ui-1l06pbn"> term </code> </a> field is set by the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-primary"> primary </a> replica set member. The primary ignores the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/replica-configuration/#mongodb-rsconf-rsconf.term"> <code class="leafygreen-ui-1l06pbn"> term </code> </a> field if set explicitly in the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-method-rs.reconfig" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> rs.reconfig() </code> </span> </a> operation. </p> <span class="leafygreen-ui-1qnjd6d" id="std-label-rs-reconfig-single-node"> </span> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Reconfiguration Can Add or Remove No More than One Voting Member at a Time <a class="headerlink leafygreen-ui-1kepx47" href="#reconfiguration-can-add-or-remove-no-more-than-one-voting-member-at-a-time" 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="reconfiguration-can-add-or-remove-no-more-than-one-voting-member-at-a-time"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-method-rs.reconfig" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> rs.reconfig() </code> </span> </a> by default allows adding or removing no more than <code class="leafygreen-ui-1l06pbn"> 1 </code> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/replica-configuration/#mongodb-rsconf-rsconf.members-n-.votes"> <code class="leafygreen-ui-1l06pbn"> voting </code> </a> member at a time. For example, a new configuration can make at most <em> one </em> of the following changes to the cluster <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/replica-configuration/#mongodb-rsconf-rsconf.members-n-.votes"> <code class="leafygreen-ui-1l06pbn"> membership </code> : </a> </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Adding a new voting replica set member. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Removing an existing voting replica set member. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Modifying the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/replica-configuration/#mongodb-rsconf-rsconf.members-n-.votes"> <code class="leafygreen-ui-1l06pbn"> votes </code> </a> for an existing replica set member. </p> </li> </ul> <p class="leafygreen-ui-1kp3ins"> To add or remove multiple voting members, issue a series of <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-method-rs.reconfig" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> rs.reconfig() </code> </span> </a> operations to add or remove one member at a time. </p> <p class="leafygreen-ui-1kp3ins"> Issuing a <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-rs-reconfig-method-force" target="_self"> <span> force </span> </a> reconfiguration immediately installs the new configuration even if it adds or removes multiple voting members. Force reconfiguration can cause unexpected behavior, such as the rollback of <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/write-concern/#mongodb-writeconcern-writeconcern.-majority-"> <code class="leafygreen-ui-1l06pbn"> "majority" </code> </a> committed write operations. </p> <span class="leafygreen-ui-1qnjd6d" id="std-label-rs-reconfig-majority-install"> </span> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Reconfiguration Waits Until a Majority of Members Install the Replica Configuration <a class="headerlink leafygreen-ui-1kepx47" href="#reconfiguration-waits-until-a-majority-of-members-install-the-replica-configuration" 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="reconfiguration-waits-until-a-majority-of-members-install-the-replica-configuration"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-method-rs.reconfig" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> rs.reconfig() </code> </span> </a> waits until a majority of voting replica set members install the new replica configuration before returning success. A voting member is <em> any </em> replica set member where <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/replica-configuration/#mongodb-rsconf-rsconf.members-n-.votes"> <code class="leafygreen-ui-1l06pbn"> members[n].votes </code> </a> is <code class="leafygreen-ui-1l06pbn"> 1 </code> , including arbiters. </p> <p class="leafygreen-ui-1kp3ins"> Replica set members propagate their replica configuration via <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/replica-set-elections/#std-label-replica-set-heartbeats"> heartbeats </a> . Whenever a member learns of a configuration with a higher <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/replica-configuration/#mongodb-rsconf-rsconf.version"> <code class="leafygreen-ui-1l06pbn"> version </code> </a> and <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/replica-configuration/#mongodb-rsconf-rsconf.term"> <code class="leafygreen-ui-1l06pbn"> term </code> </a> , it installs the new configuration. The reconfiguration process has two distinct 'waiting' phases: </p> <dl> <dt> 1) Wait for the current configuration to be <em> committed </em> before installing the new configuration. </dt> <dd class="css-1ufxuu7"> <p class="leafygreen-ui-1kp3ins"> The "current" configuration refers to the replica configuration in use by the primary at the time <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-method-rs.reconfig" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> rs.reconfig() </code> </span> </a> is issued. </p> <span class="leafygreen-ui-1qnjd6d" id="std-label-replSetReconfig-configuration-committed"> </span> <p class="leafygreen-ui-1kp3ins"> A configuration is committed when: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> A majority of voting replica set members have installed the current configuration, <em> and </em> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> All writes which were <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/write-concern/#mongodb-writeconcern-writeconcern.-majority-"> <code class="leafygreen-ui-1l06pbn"> "majority" </code> </a> committed in the previous configuration have also replicated to a majority in the current configuration. </p> </li> </ul> <p class="leafygreen-ui-1kp3ins"> Typically, the current configuration has already been installed on a majority of voting replica set members. However, the majority committed writes in the previous configuration may not all be committed in the current configuration. <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/replica-configuration/#mongodb-rsconf-rsconf.members-n-.secondaryDelaySecs"> <code class="leafygreen-ui-1l06pbn"> Delayed </code> </a> members <em> or </em> members that are <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/rs.printSecondaryReplicationInfo/#mongodb-method-rs.printSecondaryReplicationInfo"> <code class="leafygreen-ui-1l06pbn"> lagging behind </code> </a> the primary can increase the time spent in this phase. </p> <p class="leafygreen-ui-1kp3ins"> If the operation was issued with a <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-rs-reconfig-method-maxTimeMS" target="_self"> <span> maxTimeMS </span> </a> limit <em> and </em> the operation exceeds the limit while waiting, the operation returns an error and discard the new configuration. The limit is <em> cumulative </em> and does not reset after proceeding to the next phase. </p> </dd> <dt> 2) Wait for a majority of voting members in the new configuration to install the new configuration. </dt> <dd class="css-1ufxuu7"> <p class="leafygreen-ui-1kp3ins"> The "new" configuration refers to the replica configuration specified to <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-method-rs.reconfig" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> rs.reconfig() </code> </span> </a> . </p> <p class="leafygreen-ui-1kp3ins"> The primary installs and begins using the new replica configuration before propagating the configuration to the remaining replica set members. The operation only waits for a majority of voting members to install the new configuration, and does not require waiting for the new configuration to be <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-replSetReconfig-configuration-committed" target="_self"> <span> committed <!-- --> . </span> </a> </p> <p class="leafygreen-ui-1kp3ins"> If the operation was issued with a <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-rs-reconfig-method-maxTimeMS" target="_self"> <span> maxTimeMS </span> </a> limit <em> and </em> the operation exceeds the limit while waiting, the operation returns an error <em> but </em> continues using and propagating the new configuration. </p> </dd> </dl> <p class="leafygreen-ui-1kp3ins"> Issuing a <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-rs-reconfig-method-force" target="_self"> <span> force </span> </a> reconfiguration immediately installs the new configuration regardless of the commitment status of the previous configuration. Force reconfiguration can cause unexpected behavior, such as the rollback of <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/write-concern/#mongodb-writeconcern-writeconcern.-majority-"> <code class="leafygreen-ui-1l06pbn"> "majority" </code> </a> committed write operations. </p> <p class="leafygreen-ui-1kp3ins"> To check the commitment status of the current replica configuration, issue <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/command/replSetGetConfig/#mongodb-dbcommand-dbcmd.replSetGetConfig"> <code class="leafygreen-ui-1l06pbn"> replSetGetConfig </code> </a> with the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/command/replSetGetConfig/#std-label-replSetGetConfig-commitmentStatus"> commitmentStatus </a> parameter on the replica set <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-primary"> primary <!-- --> . </a> </p> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Access Control <a class="headerlink leafygreen-ui-1kepx47" href="#access-control" 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="access-control"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> To run the method on deployments that enforce <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/authorization/"> access control </a> , the user must have <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/privilege-actions/#mongodb-authaction-replSetConfigure"> <code class="leafygreen-ui-1l06pbn"> replSetConfigure </code> </a> privilege action on the cluster resource. The <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/built-in-roles/#mongodb-authrole-clusterManager"> <code class="leafygreen-ui-1l06pbn"> clusterManager </code> </a> built-in role, available in the <code class="leafygreen-ui-1l06pbn"> admin </code> database, provides the required privileges for this command. </p> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Locking Behavior <a class="headerlink leafygreen-ui-1kepx47" href="#locking-behavior" 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="locking-behavior"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-method-rs.reconfig" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> rs.reconfig() </code> </span> </a> obtains a special mutually exclusive lock to prevent more than one <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-method-rs.reconfig" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> rs.reconfig() </code> </span> </a> operation from occurring at the same time. </p> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Mixed Version Replica Set <a class="headerlink leafygreen-ui-1kepx47" href="#mixed-version-replica-set" 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="mixed-version-replica-set"> </div> </a> </h3> <div class="leafygreen-ui-1sjx7ru" role="note"> <h2 class="leafygreen-ui-29m78u"> Warning </h2> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> Avoid reconfiguring replica sets that contain members of different MongoDB versions as validation rules may differ across MongoDB versions. </p> </div> </div> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Availability <a class="headerlink leafygreen-ui-1kepx47" href="#availability" 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="availability"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> The <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-method-rs.reconfig" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> rs.reconfig() </code> </span> </a> shell method can trigger the current primary to step down in some situations. Primary step-down triggers an <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/replica-set-elections/#std-label-replica-set-elections"> election </a> to select a new <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-primary"> primary <!-- --> : </a> </p> <p class="leafygreen-ui-1kp3ins"> When the primary steps down, it stops any in-progress writes. For details, see <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/command/replSetStepDown/#std-label-replSetStepDown-behavior"> Behavior <!-- --> . </a> </p> <p class="leafygreen-ui-1kp3ins"> The median time before a cluster elects a new primary should not typically exceed 12 seconds, assuming default <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/replica-configuration/#mongodb-rsconf-rsconf.settings"> <code class="leafygreen-ui-1l06pbn"> replica configuration settings </code> </a> . This includes time required to mark the primary as <a class="leafygreen-ui-tqgtui" href="/docs/manual/replication/#std-label-replication-auto-failover"> unavailable </a> and call and complete an <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/replica-set-elections/#std-label-replica-set-elections"> election </a> . You can tune this time period by modifying the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/replica-configuration/#mongodb-rsconf-rsconf.settings.electionTimeoutMillis"> <code class="leafygreen-ui-1l06pbn"> settings.electionTimeoutMillis </code> </a> replication configuration option. Factors such as network latency may extend the time required for replica set elections to complete, which in turn affects the amount of time your cluster may operate without a primary. These factors are dependent on your particular cluster architecture. </p> <p class="leafygreen-ui-1kp3ins"> During the election process, the cluster cannot accept write operations until it elects the new primary. </p> <p class="leafygreen-ui-1kp3ins"> Your application connection logic should include tolerance for automatic failovers and the subsequent elections. MongoDB drivers can detect the loss of the primary and automatically <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/retryable-writes/#std-label-retryable-writes"> retry certain write operations </a> a single time, providing additional built-in handling of automatic failovers and elections: </p> <p class="leafygreen-ui-1kp3ins"> Compatible drivers enable retryable writes by default </p> <p class="leafygreen-ui-1kp3ins"> To further reduce potential impact to a production cluster, reconfigure only during scheduled maintenance periods. </p> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> <code class="leafygreen-ui-1l06pbn"> { force: true } </code> <a class="headerlink leafygreen-ui-1kepx47" href="#--force--true--" 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="--force--true--"> </div> </a> </h3> <div class="leafygreen-ui-1sjx7ru" role="note"> <h2 class="leafygreen-ui-29m78u"> Warning </h2> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> MongoDB does not synchronize a forced replica set reconfiguration between the replica sets in a cluster. Using <code class="leafygreen-ui-1l06pbn"> { force: true } </code> can lead to a <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-rollback"> rollback </a> of majority-committed writes and an inconsistent sharded cluster. Exercise caution when you use this option. </p> </div> </div> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Member Priority and Votes <a class="headerlink leafygreen-ui-1kepx47" href="#member-priority-and-votes" 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="member-priority-and-votes"> </div> </a> </h3> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Members with <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/replica-configuration/#mongodb-rsconf-rsconf.members-n-.priority"> <code class="leafygreen-ui-1l06pbn"> priority </code> </a> greater than 0 cannot have 0 <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/replica-configuration/#mongodb-rsconf-rsconf.members-n-.votes"> <code class="leafygreen-ui-1l06pbn"> votes </code> . </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Non-voting (i.e. <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/replica-configuration/#mongodb-rsconf-rsconf.members-n-.votes"> <code class="leafygreen-ui-1l06pbn"> votes </code> </a> is <code class="leafygreen-ui-1l06pbn"> 0 </code> ) members must have <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/replica-configuration/#mongodb-rsconf-rsconf.members-n-.priority"> <code class="leafygreen-ui-1l06pbn"> priority </code> </a> of 0. </p> </li> </ul> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Drop Outgoing Connections After Removing a Member <a class="headerlink leafygreen-ui-1kepx47" href="#drop-outgoing-connections-after-removing-a-member" 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="drop-outgoing-connections-after-removing-a-member"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> Using <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-method-rs.reconfig" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> rs.reconfig() </code> </span> </a> to remove a replica set member does not automatically drop open outgoing connections from other replica set members to the removed member. </p> <p class="leafygreen-ui-1kp3ins"> By default, replica set members wait for 5 minutes before dropping connections to the removed member. In sharded replica sets, you can modify this timeout using the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/parameters/#mongodb-parameter-param.ShardingTaskExecutorPoolHostTimeoutMS"> <code class="leafygreen-ui-1l06pbn"> ShardingTaskExecutorPoolHostTimeoutMS </code> </a> server parameter. </p> <p class="leafygreen-ui-1kp3ins"> To immediately drop all outgoing connections from the replica set to the removed member, run the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/command/dropConnections/#mongodb-dbcommand-dbcmd.dropConnections"> <code class="leafygreen-ui-1l06pbn"> dropConnections </code> </a> administrative command on each remaining member on the replica set: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.adminCommand(\n {\n \"dropConnections\" : 1,\n \"hostAndPort\" : [\n \"&lt;hostname&gt;:&lt;port&gt;\"\n ]\n }\n)","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">adminCommand</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"dropConnections"</span> <!-- -->: <span class="lg-highlight-number">1</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"hostAndPort"</span> <!-- -->: <!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"&lt;hostname&gt;:&lt;port&gt;"</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> ]</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">)</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"> Replace <code class="leafygreen-ui-1l06pbn"> &lt;hostname&gt; </code> and <code class="leafygreen-ui-1l06pbn"> &lt;port&gt; </code> with those of the removed member. </p> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Automatic Reconfiguration for New Voting Replica Set Members <a class="headerlink leafygreen-ui-1kepx47" href="#automatic-reconfiguration-for-new-voting-replica-set-members" 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="automatic-reconfiguration-for-new-voting-replica-set-members"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> Starting in MongoDB 5.0, a newly added secondary does not count as a voting member and cannot be elected until it has reached the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/replica-states/#mongodb-replstate-replstate.SECONDARY"> <code class="leafygreen-ui-1l06pbn"> SECONDARY </code> </a> state. </p> <p class="leafygreen-ui-1kp3ins"> When a new voting node is added to a replica set, <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/command/replSetReconfig/#mongodb-dbcommand-dbcmd.replSetReconfig"> <code class="leafygreen-ui-1l06pbn"> replSetReconfig </code> </a> will internally add a <code class="leafygreen-ui-1l06pbn"> newlyAdded </code> field to the node's configuration. Nodes with the <code class="leafygreen-ui-1l06pbn"> newlyAdded </code> field do not count towards the current number of voting nodes. When initial sync completes and the node reaches <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/replica-states/#mongodb-replstate-replstate.SECONDARY"> <code class="leafygreen-ui-1l06pbn"> SECONDARY </code> </a> state, the <code class="leafygreen-ui-1l06pbn"> newlyAdded </code> field is automatically removed. </p> <div class="leafygreen-ui-15mdk4" role="note"> <h2 class="leafygreen-ui-6n7b7d"> Note </h2> <div class="leafygreen-ui-9mycqc"> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Configurations that attempt to add a field named <code class="leafygreen-ui-1l06pbn"> newlyAdded </code> will error even if run with <code class="leafygreen-ui-1l06pbn"> { force: true } </code> . </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> If an existing node has a <code class="leafygreen-ui-1l06pbn"> newlyAdded </code> field, using <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-method-rs.reconfig" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> rs.reconfig() </code> </span> </a> to change the configuration will not remove the <code class="leafygreen-ui-1l06pbn"> newlyAdded </code> field. The <code class="leafygreen-ui-1l06pbn"> newlyAdded </code> field will be appended to the user provided configuration. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/command/replSetGetConfig/#mongodb-dbcommand-dbcmd.replSetGetConfig"> <code class="leafygreen-ui-1l06pbn"> replSetGetConfig </code> </a> will remove any <code class="leafygreen-ui-1l06pbn"> newlyAdded </code> fields from its output. If you would like to see any <code class="leafygreen-ui-1l06pbn"> newlyAdded </code> fields, you can query the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/local-database/#mongodb-data-local.system.replset"> <code class="leafygreen-ui-1l06pbn"> local.system.replset </code> </a> collection directly. </p> </li> </ul> </div> </div> <span class="leafygreen-ui-1qnjd6d" id="std-label-replica-set-reconfiguration-usage"> </span> </section> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Examples <a class="headerlink leafygreen-ui-1kepx47" href="#examples" 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="examples"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> A replica set named <code class="leafygreen-ui-1l06pbn"> rs0 </code> has the following configuration: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{\n \"_id\" : \"rs0\",\n \"version\" : 1,\n \"protocolVersion\" : NumberLong(1),\n \"members\" : [\n {\n \"_id\" : 0,\n \"host\" : \"mongodb0.example.net:27017\",\n \"arbiterOnly\" : false,\n \"buildIndexes\" : true,\n \"hidden\" : false,\n \"priority\" : 1,\n \"tags\" : {\n\n },\n \"secondaryDelaySecs\" : NumberLong(0),\n \"votes\" : 1\n },\n {\n \"_id\" : 1,\n \"host\" : \"mongodb1.example.net:27017\",\n \"arbiterOnly\" : false,\n \"buildIndexes\" : true,\n \"hidden\" : false,\n \"priority\" : 1,\n \"tags\" : {\n\n },\n \"secondaryDelaySecs\" : NumberLong(0),\n \"votes\" : 1\n },\n {\n \"_id\" : 2,\n \"host\" : \"mongodb2.example.net:27017\",\n \"arbiterOnly\" : false,\n \"buildIndexes\" : true,\n \"hidden\" : false,\n \"priority\" : 1,\n \"tags\" : {\n\n },\n \"secondaryDelaySecs\" : NumberLong(0),\n \"votes\" : 1\n }\n ],\n \"settings\" : {\n \"chainingAllowed\" : true,\n \"heartbeatIntervalMillis\" : 2000,\n \"heartbeatTimeoutSecs\" : 10,\n \"electionTimeoutMillis\" : 10000,\n \"catchUpTimeoutMillis\" : 2000,\n \"getLastErrorModes\" : {\n\n },\n \"getLastErrorDefaults\" : {\n \"w\" : 1,\n \"wtimeout\" : 0\n },\n \"replicaSetId\" : ObjectId(\"58858acc1f5609ed986b641b\")\n }\n}","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-string">"rs0"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"version"</span> <!-- -->: <span class="lg-highlight-number">1</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"protocolVersion"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">NumberLong</span>(<span class="lg-highlight-number">1</span>)<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"members"</span> <!-- -->: <!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">0</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"host"</span> <!-- -->: <span class="lg-highlight-string">"mongodb0.example.net:27017"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"arbiterOnly"</span> <!-- -->: <span class="lg-highlight-literal">false</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"buildIndexes"</span> <!-- -->: <span class="lg-highlight-literal">true</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"hidden"</span> <!-- -->: <span class="lg-highlight-literal">false</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"priority"</span> <!-- -->: <span class="lg-highlight-number">1</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"tags"</span> <!-- -->: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><div class="leafygreen-ui-ihxujy"></div></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->}<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"secondaryDelaySecs"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">NumberLong</span>(<span class="lg-highlight-number">0</span>)<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"votes"</span> <!-- -->: <span class="lg-highlight-number">1</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">1</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"host"</span> <!-- -->: <span class="lg-highlight-string">"mongodb1.example.net:27017"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"arbiterOnly"</span> <!-- -->: <span class="lg-highlight-literal">false</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"buildIndexes"</span> <!-- -->: <span class="lg-highlight-literal">true</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"hidden"</span> <!-- -->: <span class="lg-highlight-literal">false</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"priority"</span> <!-- -->: <span class="lg-highlight-number">1</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"tags"</span> <!-- -->: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><div class="leafygreen-ui-ihxujy"></div></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->}<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"secondaryDelaySecs"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">NumberLong</span>(<span class="lg-highlight-number">0</span>)<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"votes"</span> <!-- -->: <span class="lg-highlight-number">1</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">2</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"host"</span> <!-- -->: <span class="lg-highlight-string">"mongodb2.example.net:27017"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"arbiterOnly"</span> <!-- -->: <span class="lg-highlight-literal">false</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"buildIndexes"</span> <!-- -->: <span class="lg-highlight-literal">true</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"hidden"</span> <!-- -->: <span class="lg-highlight-literal">false</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"priority"</span> <!-- -->: <span class="lg-highlight-number">1</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"tags"</span> <!-- -->: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><div class="leafygreen-ui-ihxujy"></div></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->}<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"secondaryDelaySecs"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">NumberLong</span>(<span class="lg-highlight-number">0</span>)<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"votes"</span> <!-- -->: <span class="lg-highlight-number">1</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> ]<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"settings"</span> <!-- -->: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"chainingAllowed"</span> <!-- -->: <span class="lg-highlight-literal">true</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"heartbeatIntervalMillis"</span> <!-- -->: <span class="lg-highlight-number">2000</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"heartbeatTimeoutSecs"</span> <!-- -->: <span class="lg-highlight-number">10</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"electionTimeoutMillis"</span> <!-- -->: <span class="lg-highlight-number">10000</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"catchUpTimeoutMillis"</span> <!-- -->: <span class="lg-highlight-number">2000</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"getLastErrorModes"</span> <!-- -->: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><div class="leafygreen-ui-ihxujy"></div></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->}<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"getLastErrorDefaults"</span> <!-- -->: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"w"</span> <!-- -->: <span class="lg-highlight-number">1</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"wtimeout"</span> <!-- -->: <span class="lg-highlight-number">0</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"replicaSetId"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">ObjectId</span>(<span class="lg-highlight-string">"58858acc1f5609ed986b641b"</span>)</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">}</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> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Change Replica Set Member Priority <a class="headerlink leafygreen-ui-1kepx47" href="#change-replica-set-member-priority" 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="change-replica-set-member-priority"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> The following sequence of operations updates the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/replica-configuration/#mongodb-rsconf-rsconf.members-n-.priority"> <code class="leafygreen-ui-1l06pbn"> members[n].priority </code> </a> of the second member. The operations are issued through a <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/mongodb-shell/#mongodb-binary-bin.mongosh" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongosh </code> </span> </a> session that is connected to the primary. </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"cfg = rs.conf();\ncfg.members[1].priority = 2;\nrs.reconfig(cfg);","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">cfg <!-- -->= <!-- -->rs.<span class="lg-highlight-title lg-highlight-function">conf</span>(<!-- -->)<!-- -->;</td></tr><tr class=""><td class="leafygreen-ui-7razhx">cfg.<span class="lg-highlight-property">members</span>[<span class="lg-highlight-number">1</span>].<span class="lg-highlight-property">priority</span> <!-- -->= <span class="lg-highlight-number">2</span>;</td></tr><tr class=""><td class="leafygreen-ui-7razhx">rs.<span class="lg-highlight-title lg-highlight-function">reconfig</span>(<!-- -->cfg)<!-- -->;</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> <ol class="leafygreen-ui-rioki0" type="1"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> The first statement uses the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/rs.conf/#mongodb-method-rs.conf"> <code class="leafygreen-ui-1l06pbn"> rs.conf() </code> </a> method to retrieve a document containing the current <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/replica-configuration/#std-label-replSetGetConfig-output"> configuration </a> for the replica set and sets the document to the local variable <code class="leafygreen-ui-1l06pbn"> cfg </code> . </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> The second statement sets a <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/replica-configuration/#mongodb-rsconf-rsconf.members-n-.priority"> <code class="leafygreen-ui-1l06pbn"> members[n].priority </code> </a> value to the second document in the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/replica-configuration/#mongodb-rsconf-rsconf.members"> <code class="leafygreen-ui-1l06pbn"> members </code> </a> array. For additional settings, see <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/replica-configuration/#std-label-replSetGetConfig-output"> replica set configuration settings <!-- --> . </a> </p> <p class="leafygreen-ui-1kp3ins"> To access the member configuration document in the array, the statement uses the array index and <strong> not </strong> the replica set member's <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/replica-configuration/#mongodb-rsconf-rsconf.members-n-._id"> <code class="leafygreen-ui-1l06pbn"> members[n]._id </code> </a> field. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> The last statement calls the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-method-rs.reconfig" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> rs.reconfig() </code> </span> </a> method with the modified <code class="leafygreen-ui-1l06pbn"> cfg </code> to initialize this new configuration. Upon successful reconfiguration, the replica set configuration will resemble the following: </p> </li> </ol> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{\n \"_id\" : \"rs0\",\n \"version\" : 2,\n \"protocolVersion\" : NumberLong(1),\n \"members\" : [\n {\n \"_id\" : 0,\n \"host\" : \"mongodb0.example.net:27017\",\n \"arbiterOnly\" : false,\n \"buildIndexes\" : true,\n \"hidden\" : false,\n \"priority\" : 1,\n \"tags\" : {\n\n },\n \"secondaryDelaySecs\" : NumberLong(0),\n \"votes\" : 1\n },\n {\n \"_id\" : 1,\n \"host\" : \"mongodb1.example.net:27017\",\n \"arbiterOnly\" : false,\n \"buildIndexes\" : true,\n \"hidden\" : false,\n \"priority\" : 2,\n \"tags\" : {\n\n },\n \"secondaryDelaySecs\" : NumberLong(0),\n \"votes\" : 1\n },\n {\n \"_id\" : 2,\n \"host\" : \"mongodb2.example.net:27017\",\n \"arbiterOnly\" : false,\n \"buildIndexes\" : true,\n \"hidden\" : false,\n \"priority\" : 1,\n \"tags\" : {\n\n },\n \"secondaryDelaySecs\" : NumberLong(0),\n \"votes\" : 1\n }\n ],\n \"settings\" : {\n \"chainingAllowed\" : true,\n \"heartbeatIntervalMillis\" : 2000,\n \"heartbeatTimeoutSecs\" : 10,\n \"electionTimeoutMillis\" : 10000,\n \"catchUpTimeoutMillis\" : 2000,\n \"getLastErrorModes\" : {\n\n },\n \"getLastErrorDefaults\" : {\n \"w\" : 1,\n \"wtimeout\" : 0\n },\n \"replicaSetId\" : ObjectId(\"58858acc1f5609ed986b641b\")\n }\n}","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-string">"rs0"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"version"</span> <!-- -->: <span class="lg-highlight-number">2</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"protocolVersion"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">NumberLong</span>(<span class="lg-highlight-number">1</span>)<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"members"</span> <!-- -->: <!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">0</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"host"</span> <!-- -->: <span class="lg-highlight-string">"mongodb0.example.net:27017"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"arbiterOnly"</span> <!-- -->: <span class="lg-highlight-literal">false</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"buildIndexes"</span> <!-- -->: <span class="lg-highlight-literal">true</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"hidden"</span> <!-- -->: <span class="lg-highlight-literal">false</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"priority"</span> <!-- -->: <span class="lg-highlight-number">1</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"tags"</span> <!-- -->: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><div class="leafygreen-ui-ihxujy"></div></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->}<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"secondaryDelaySecs"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">NumberLong</span>(<span class="lg-highlight-number">0</span>)<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"votes"</span> <!-- -->: <span class="lg-highlight-number">1</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">1</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"host"</span> <!-- -->: <span class="lg-highlight-string">"mongodb1.example.net:27017"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"arbiterOnly"</span> <!-- -->: <span class="lg-highlight-literal">false</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"buildIndexes"</span> <!-- -->: <span class="lg-highlight-literal">true</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"hidden"</span> <!-- -->: <span class="lg-highlight-literal">false</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"priority"</span> <!-- -->: <span class="lg-highlight-number">2</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"tags"</span> <!-- -->: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><div class="leafygreen-ui-ihxujy"></div></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->}<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"secondaryDelaySecs"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">NumberLong</span>(<span class="lg-highlight-number">0</span>)<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"votes"</span> <!-- -->: <span class="lg-highlight-number">1</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">2</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"host"</span> <!-- -->: <span class="lg-highlight-string">"mongodb2.example.net:27017"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"arbiterOnly"</span> <!-- -->: <span class="lg-highlight-literal">false</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"buildIndexes"</span> <!-- -->: <span class="lg-highlight-literal">true</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"hidden"</span> <!-- -->: <span class="lg-highlight-literal">false</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"priority"</span> <!-- -->: <span class="lg-highlight-number">1</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"tags"</span> <!-- -->: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><div class="leafygreen-ui-ihxujy"></div></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->}<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"secondaryDelaySecs"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">NumberLong</span>(<span class="lg-highlight-number">0</span>)<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"votes"</span> <!-- -->: <span class="lg-highlight-number">1</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> ]<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"settings"</span> <!-- -->: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"chainingAllowed"</span> <!-- -->: <span class="lg-highlight-literal">true</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"heartbeatIntervalMillis"</span> <!-- -->: <span class="lg-highlight-number">2000</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"heartbeatTimeoutSecs"</span> <!-- -->: <span class="lg-highlight-number">10</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"electionTimeoutMillis"</span> <!-- -->: <span class="lg-highlight-number">10000</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"catchUpTimeoutMillis"</span> <!-- -->: <span class="lg-highlight-number">2000</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"getLastErrorModes"</span> <!-- -->: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><div class="leafygreen-ui-ihxujy"></div></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->}<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"getLastErrorDefaults"</span> <!-- -->: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"w"</span> <!-- -->: <span class="lg-highlight-number">1</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"wtimeout"</span> <!-- -->: <span class="lg-highlight-number">0</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"replicaSetId"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">ObjectId</span>(<span class="lg-highlight-string">"58858acc1f5609ed986b641b"</span>)</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">}</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> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Change Replica Set Settings <a class="headerlink leafygreen-ui-1kepx47" href="#change-replica-set-settings" 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="change-replica-set-settings"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> You can also modify the cluster replica set <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/replica-configuration/#mongodb-rsconf-rsconf.settings"> <code class="leafygreen-ui-1l06pbn"> settings </code> </a> document. The <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/replica-configuration/#mongodb-rsconf-rsconf.settings"> <code class="leafygreen-ui-1l06pbn"> settings </code> </a> document contains configuration options that apply to the whole replica set. </p> <p class="leafygreen-ui-1kp3ins"> The following sequence of operations updates the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/replica-configuration/#mongodb-rsconf-rsconf.settings.heartbeatTimeoutSecs"> <code class="leafygreen-ui-1l06pbn"> settings.heartbeatTimeoutSecs </code> </a> of the cluster to <code class="leafygreen-ui-1l06pbn"> 15 </code> . The operations are issued through a <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/mongodb-shell/#mongodb-binary-bin.mongosh" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongosh </code> </span> </a> session that is connected to the primary. </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"cfg = rs.conf();\ncfg.settings.heartbeatTimeoutSecs = 15;\nrs.reconfig(cfg);","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">cfg <!-- -->= <!-- -->rs.<span class="lg-highlight-title lg-highlight-function">conf</span>(<!-- -->)<!-- -->;</td></tr><tr class=""><td class="leafygreen-ui-7razhx">cfg.<span class="lg-highlight-property">settings</span>.<span class="lg-highlight-property">heartbeatTimeoutSecs</span> <!-- -->= <span class="lg-highlight-number">15</span>;</td></tr><tr class=""><td class="leafygreen-ui-7razhx">rs.<span class="lg-highlight-title lg-highlight-function">reconfig</span>(<!-- -->cfg)<!-- -->;</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-13vw3ie" role="note"> <h2 class="leafygreen-ui-1fn4p2b"> Tip </h2> <h3 class="leafygreen-ui-144d5kf"> <strong> See also: </strong> </h3> <div class="leafygreen-ui-9mycqc"> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/rs.conf/#mongodb-method-rs.conf"> <code class="leafygreen-ui-1l06pbn"> rs.conf() </code> </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/replica-configuration/#std-label-replSetGetConfig-output"> Replica Set Configuration Fields </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/administration/replica-set-member-configuration/"> Self-Managed Member Configuration Tutorials </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/administration/replica-set-maintenance/"> Self-Managed Replica Set Maintenance Tutorials </a> </p> </li> </ul> </div> </div> </section> </section> </section>
https://www.mongodb.com/docs/manual/core/tailable-cursors/
<section> <h1 class="contains-headerlink leafygreen-ui-41fr9s" weight="medium"> Tailable Cursors <a class="headerlink leafygreen-ui-1kepx47" href="#tailable-cursors" 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="tailable-cursors"> </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="#use-cases" target="_self"> <span> Use Cases </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#get-started" target="_self"> <span> Get Started </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#behavior" target="_self"> <span> Behavior </span> </a> </li> </ul> </div> <p class="leafygreen-ui-1kp3ins"> By default, MongoDB automatically closes a cursor when the client exhausts all results in the cursor. However, for <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/capped-collections/#std-label-manual-capped-collection"> capped collections </a> you can use a <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-tailable-cursor"> tailable cursor </a> that remains open after the client exhausts the results in the initial cursor. Tailable cursors are conceptually equivalent to the <code class="leafygreen-ui-1l06pbn"> tail </code> Unix command with the <code class="leafygreen-ui-1l06pbn"> -f </code> option ("follow" mode). After clients insert additional documents into a capped collection, the tailable cursor continues to retrieve documents. </p> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Use Cases <a class="headerlink leafygreen-ui-1kepx47" href="#use-cases" 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="use-cases"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> Use tailable cursors on capped collections that have high write volumes where indexes aren't practical. For instance, MongoDB <a class="leafygreen-ui-tqgtui" href="/docs/manual/replication/#std-label-replication"> replication </a> uses tailable cursors to tail the primary's <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-oplog"> oplog <!-- --> . </a> </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"> If your query is on an indexed field, use a regular cursor instead of a tailable cursor. Keep track of the last value of the indexed field returned by the query. To retrieve the newly added documents, query the collection again using the last value of the indexed field in the query criteria. For example: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.&lt;collection&gt;.find( { indexedField: { $gt: &lt;lastvalue&gt; } } )","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-1q4bxgx" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">db.<!-- -->&lt;<!-- -->collection<!-- -->&gt;<!-- -->.<span class="lg-highlight-title lg-highlight-function">find</span>( <!-- -->{ <span class="lg-highlight-attr">indexedField</span>: <!-- -->{ <span class="lg-highlight-attr">$gt</span>: &lt;<!-- -->lastvalue<!-- -->&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> </div> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Get Started <a class="headerlink leafygreen-ui-1kepx47" href="#get-started" 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="get-started"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> To create a tailable cursor in <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/mongodb-shell/#mongodb-binary-bin.mongosh" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongosh </code> </span> </a> , see <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/cursor.tailable/#mongodb-method-cursor.tailable"> <code class="leafygreen-ui-1l06pbn"> cursor.tailable() </code> . </a> </p> <p class="leafygreen-ui-1kp3ins"> To see tailable cursor methods for your driver, see your <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/drivers/" target="_self"> <span> driver documentation <!-- --> . </span> </a> </p> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Behavior <a class="headerlink leafygreen-ui-1kepx47" href="#behavior" 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="behavior"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> Consider the following behaviors related to tailable cursors: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Tailable cursors do not use indexes. They return documents in <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-natural-order"> natural order <!-- --> . </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Because tailable cursors do not use indexes, the initial scan for the query may be expensive. After initially exhausting the cursor, subsequent retrievals of the newly added documents are inexpensive. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> A tailable cursor can become invalid if the data at its current position is overwritten by new data. For example, this can happen if the speed of data insertion is faster than the speed of cursor iteration. </p> </li> </ul> </section> </section>
https://www.mongodb.com/docs/manual/reference/method/cursor.returnKey/
<section> <h1 class="contains-headerlink leafygreen-ui-41fr9s" weight="medium"> cursor.returnKey() <a class="headerlink leafygreen-ui-1kepx47" href="#cursor.returnkey--" 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="cursor.returnkey--"> </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="#definition" target="_self"> <span> Definition </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#behavior" target="_self"> <span> Behavior </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#example" target="_self"> <span> Example </span> </a> </li> </ul> </div> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Definition <a class="headerlink leafygreen-ui-1kepx47" href="#definition" 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="definition"> </div> </a> </h2> <dl class="method"> <dt> <code class="leafygreen-ui-1l06pbn"> cursor.returnKey() </code> <a class="headerlink leafygreen-ui-1kepx47" href="#mongodb-method-cursor.returnKey" title="Permalink to this definition"> <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="mongodb-method-cursor.returnKey"> </div> </a> </dt> <dd> <div class="leafygreen-ui-85da11" role="note"> <h2 class="leafygreen-ui-1ac4g5h"> Important </h2> <h3 class="leafygreen-ui-144d5kf"> <strong> mongosh Method </strong> </h3> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> This page documents a <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/mongodb-shell/#mongodb-binary-bin.mongosh" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongosh </code> </span> </a> method. This is <em> not </em> the documentation for a language-specific driver, such as Node.js. </p> <p class="leafygreen-ui-1kp3ins"> For MongoDB API drivers, refer to the language-specific <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/drivers/" target="_self"> <span> MongoDB driver documentation <!-- --> . </span> </a> </p> </div> </div> <div class="leafygreen-ui-13vw3ie" role="note"> <h2 class="leafygreen-ui-1fn4p2b"> Tip </h2> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/meta/#mongodb-expression-exp.-meta"> <code class="leafygreen-ui-1l06pbn"> $meta </code> </a> supports the keyword <code class="leafygreen-ui-1l06pbn"> "indexKey" </code> to return index key metadata if an index is used. The use of <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/meta/#mongodb-expression-exp.-meta"> <code class="leafygreen-ui-1l06pbn"> { $meta: "indexKey" } </code> </a> is preferred over <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-method-cursor.returnKey" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> cursor.returnKey() </code> . </span> </a> </p> </div> </div> <p class="leafygreen-ui-1kp3ins"> Modifies the cursor to return index keys rather than the documents. </p> <p class="leafygreen-ui-1kp3ins"> The <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-method-cursor.returnKey" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> cursor.returnKey() </code> </span> </a> has the following form: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"cursor.returnKey()","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">cursor.<span class="lg-highlight-title lg-highlight-function">returnKey</span>(<!-- -->)</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> <table class="css-11h39yh e1nex8bq0"> <colgroup> <col class="field-name"/> <col class="field-body"/> </colgroup> <tbody> <tr class="css-x8snli"> <th> Returns <!-- --> : </th> <td> The <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-cursor"> cursor </a> that <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-method-cursor.returnKey" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> returnKey() </code> </span> </a> is attached to with a modified result set. This allows for additional cursor modifiers to be chained. </td> </tr> </tbody> </table> </dd> </dl> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Behavior <a class="headerlink leafygreen-ui-1kepx47" href="#behavior" 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="behavior"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> If the query does not use an index to perform the read operation, the cursor returns empty documents. </p> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Example <a class="headerlink leafygreen-ui-1kepx47" href="#example" 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="example"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> The <code class="leafygreen-ui-1l06pbn"> restaurants </code> collection contains documents with the following schema: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{\n \"_id\" : ObjectId(\"564f3a35b385149fc7e3fab9\"),\n \"address\" : {\n \"building\" : \"2780\",\n \"coord\" : [\n -73.98241999999999,\n 40.579505\n ],\n \"street\" : \"Stillwell Avenue\",\n \"zipcode\" : \"11224\"\n },\n \"borough\" : \"Brooklyn\",\n \"cuisine\" : \"American \",\n \"grades\" : [\n {\n \"date\" : ISODate(\"2014-06-10T00:00:00Z\"),\n \"grade\" : \"A\",\n \"score\" : 5\n },\n {\n \"date\" : ISODate(\"2013-06-05T00:00:00Z\"),\n \"grade\" : \"A\",\n \"score\" : 7\n }\n ],\n \"name\" : \"Riviera Caterer\",\n \"restaurant_id\" : \"40356018\"\n}","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">ObjectId</span>(<span class="lg-highlight-string">"564f3a35b385149fc7e3fab9"</span>)<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"address"</span> <!-- -->: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"building"</span> <!-- -->: <span class="lg-highlight-string">"2780"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"coord"</span> <!-- -->: <!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->-<span class="lg-highlight-number">73.98241999999999</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-number">40.579505</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> ]<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"street"</span> <!-- -->: <span class="lg-highlight-string">"Stillwell Avenue"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"zipcode"</span> <!-- -->: <span class="lg-highlight-string">"11224"</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"borough"</span> <!-- -->: <span class="lg-highlight-string">"Brooklyn"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"cuisine"</span> <!-- -->: <span class="lg-highlight-string">"American "</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"grades"</span> <!-- -->: <!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"date"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">ISODate</span>(<span class="lg-highlight-string">"2014-06-10T00:00:00Z"</span>)<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"grade"</span> <!-- -->: <span class="lg-highlight-string">"A"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"score"</span> <!-- -->: <span class="lg-highlight-number">5</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"date"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">ISODate</span>(<span class="lg-highlight-string">"2013-06-05T00:00:00Z"</span>)<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"grade"</span> <!-- -->: <span class="lg-highlight-string">"A"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"score"</span> <!-- -->: <span class="lg-highlight-number">7</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> ]<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"name"</span> <!-- -->: <span class="lg-highlight-string">"Riviera Caterer"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"restaurant_id"</span> <!-- -->: <span class="lg-highlight-string">"40356018"</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx">}</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 collection has two indexes in addition to the default <code class="leafygreen-ui-1l06pbn"> _id </code> index: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{\n \"v\" : 1,\n \"key\" : {\n \"_id\" : 1\n },\n \"name\" : \"_id_\",\n \"ns\" : \"guidebook.restaurant\"\n},\n{\n \"v\" : 1,\n \"key\" : {\n \"cuisine\" : 1\n },\n \"name\" : \"cuisine_1\",\n \"ns\" : \"guidebook.restaurant\"\n},\n{\n \"v\" : 1,\n \"key\" : {\n \"_fts\" : \"text\",\n \"_ftsx\" : 1\n },\n \"name\" : \"name_text\",\n \"ns\" : \"guidebook.restaurant\",\n \"weights\" : {\n \"name\" : 1\n },\n \"default_language\" : \"english\",\n \"language_override\" : \"language\",\n \"textIndexVersion\" : 3\n}","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"v"</span> <!-- -->: <span class="lg-highlight-number">1</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"key"</span> <!-- -->: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">1</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"name"</span> <!-- -->: <span class="lg-highlight-string">"_id_"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"ns"</span> <!-- -->: <span class="lg-highlight-string">"guidebook.restaurant"</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx">}<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"v"</span> <!-- -->: <span class="lg-highlight-number">1</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"key"</span> <!-- -->: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"cuisine"</span> <!-- -->: <span class="lg-highlight-number">1</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"name"</span> <!-- -->: <span class="lg-highlight-string">"cuisine_1"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"ns"</span> <!-- -->: <span class="lg-highlight-string">"guidebook.restaurant"</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx">}<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"v"</span> <!-- -->: <span class="lg-highlight-number">1</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"key"</span> <!-- -->: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"_fts"</span> <!-- -->: <span class="lg-highlight-string">"text"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"_ftsx"</span> <!-- -->: <span class="lg-highlight-number">1</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"name"</span> <!-- -->: <span class="lg-highlight-string">"name_text"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"ns"</span> <!-- -->: <span class="lg-highlight-string">"guidebook.restaurant"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"weights"</span> <!-- -->: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"name"</span> <!-- -->: <span class="lg-highlight-number">1</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"default_language"</span> <!-- -->: <span class="lg-highlight-string">"english"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"language_override"</span> <!-- -->: <span class="lg-highlight-string">"language"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"textIndexVersion"</span> <!-- -->: <span class="lg-highlight-number">3</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx">}</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 code uses the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-method-cursor.returnKey" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> cursor.returnKey() </code> </span> </a> method to return only the indexed fields used for executing the query: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"var csr = db.restaurant.find( { \"cuisine\" : \"Japanese\" } )\ncsr.returnKey()","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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"><span class="lg-highlight-keyword">var</span> csr <!-- -->= <!-- -->db.<span class="lg-highlight-property">restaurant</span>.<span class="lg-highlight-title lg-highlight-function">find</span>( <!-- -->{ <span class="lg-highlight-string">"cuisine"</span> <!-- -->: <span class="lg-highlight-string">"Japanese"</span> } )</td></tr><tr class=""><td class="leafygreen-ui-7razhx">csr.<span class="lg-highlight-title lg-highlight-function">returnKey</span>(<!-- -->)</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"> This returns the following: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ \"cuisine\" : \"Japanese\" }\n{ \"cuisine\" : \"Japanese\" }\n{ \"cuisine\" : \"Japanese\" }\n{ \"cuisine\" : \"Japanese\" }\n...","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">{ <span class="lg-highlight-string">"cuisine"</span> <!-- -->: <span class="lg-highlight-string">"Japanese"</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"cuisine"</span> <!-- -->: <span class="lg-highlight-string">"Japanese"</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"cuisine"</span> <!-- -->: <span class="lg-highlight-string">"Japanese"</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"cuisine"</span> <!-- -->: <span class="lg-highlight-string">"Japanese"</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">...</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> </section> </section>
https://www.mongodb.com/docs/manual/reference/operator/aggregation/radiansToDegrees/
<section> <h1 class="contains-headerlink leafygreen-ui-41fr9s" weight="medium"> $radiansToDegrees (aggregation) <a class="headerlink leafygreen-ui-1kepx47" href="#-radianstodegrees--aggregation-" 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="-radianstodegrees--aggregation-"> </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="#definition" target="_self"> <span> Definition </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#behavior" target="_self"> <span> Behavior </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#example" target="_self"> <span> Example </span> </a> </li> </ul> </div> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Definition <a class="headerlink leafygreen-ui-1kepx47" href="#definition" 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="definition"> </div> </a> </h2> <dl class="expression"> <dt> <code class="leafygreen-ui-1l06pbn"> $radiansToDegrees </code> <a class="headerlink leafygreen-ui-1kepx47" href="#mongodb-expression-exp.-radiansToDegrees" title="Permalink to this definition"> <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="mongodb-expression-exp.-radiansToDegrees"> </div> </a> </dt> <dd> <p class="leafygreen-ui-1kp3ins"> Converts an input value measured in radians to degrees. </p> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-expression-exp.-radiansToDegrees" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $radiansToDegrees </code> </span> </a> has the following syntax: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ $radiansToDegrees: &lt;expression&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">{ <span class="lg-highlight-attr">$radiansToDegrees</span>: &lt;<!-- -->expression<!-- -->&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"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-expression-exp.-radiansToDegrees" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $radiansToDegrees </code> </span> </a> takes any valid <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/#std-label-aggregation-expressions"> expression </a> that resolves to a number. </p> <p class="leafygreen-ui-1kp3ins"> By default <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-expression-exp.-radiansToDegrees" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $radiansToDegrees </code> </span> </a> returns values as a <code class="leafygreen-ui-1l06pbn"> double </code> . <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-expression-exp.-radiansToDegrees" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $radiansToDegrees </code> </span> </a> can also return values as a <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/mongodb-shell/reference/data-types/#std-label-shell-type-decimal" target="_self"> <span> 128-bit decimal </span> </a> as long as the <code class="leafygreen-ui-1l06pbn"> &lt;expression&gt; </code> resolves to a 128-bit decimal value. </p> <p class="leafygreen-ui-1kp3ins"> For more information on expressions, see <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/#std-label-aggregation-expressions"> Expression Operators <!-- --> . </a> </p> </dd> </dl> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Behavior <a class="headerlink leafygreen-ui-1kepx47" href="#behavior" 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="behavior"> </div> </a> </h2> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> <code class="leafygreen-ui-1l06pbn"> null </code> , <code class="leafygreen-ui-1l06pbn"> NaN </code> , and <code class="leafygreen-ui-1l06pbn"> +/- Infinity </code> <a class="headerlink leafygreen-ui-1kepx47" href="#null--nan--and-----infinity" 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="null--nan--and-----infinity"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> If the argument resolves to a value of <code class="leafygreen-ui-1l06pbn"> null </code> or refers to a field that is missing, <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-expression-exp.-radiansToDegrees" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $radiansToDegrees </code> </span> </a> returns <code class="leafygreen-ui-1l06pbn"> null </code> . If the argument resolves to <code class="leafygreen-ui-1l06pbn"> NaN </code> , <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-expression-exp.-radiansToDegrees" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $radiansToDegrees </code> </span> </a> returns <code class="leafygreen-ui-1l06pbn"> NaN </code> . If the argument resolves to negative or positive infinity, <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-expression-exp.-radiansToDegrees" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $radiansToDegrees </code> </span> </a> negative or positive infinity respectively. </p> <div class="leafygreen-ui-skkc39" tabindex="0"> <table class="leafygreen-ui-hr8lsv"> <colgroup> <col style="width:85%"/> <col style="width:15%"/> </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> Example </div> </div> </th> <th class="leafygreen-ui-13uteka" role="columnheader" scope="col"> <div class="leafygreen-ui-ui0te9"> <div> Results </div> </div> </th> </tr> </thead> <tbody> <tr class=""> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> { $radiansToDegrees: NaN } </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> NaN </code> </div> </div> </td> </tr> <tr class=""> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> { $radiansToDegrees: null } </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> null </code> </div> </div> </td> </tr> <tr class=""> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> { $radiansToDegrees : Infinity} </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> Infinity </code> </div> </div> </td> </tr> <tr class=""> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> { $radiansToDegrees : -Infinity } </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> -Infinity </code> </div> </div> </td> </tr> </tbody> </table> </div> </section> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Example <a class="headerlink leafygreen-ui-1kepx47" href="#example" 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="example"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> The <code class="leafygreen-ui-1l06pbn"> trigonometry </code> collection contains a document that contains three angles measured in radians: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{\n \"angle_a\" : NumberDecimal(\"0.9272952180016122324285124629224290\"),\n \"angle_b\" : NumberDecimal(\"0.6435011087932843868028092287173227\"),\n \"angle_c\" : NumberDecimal(\"1.570796326794896619231321691639752\")\n}","programmingLanguage":"JSON"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><code class="lg-highlight-hljs-light json leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-punctuation">{</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">"angle_a"</span> <span class="lg-highlight-punctuation">:</span> NumberDecimal(<span class="lg-highlight-string">"0.9272952180016122324285124629224290"</span>)<span class="lg-highlight-punctuation">,</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">"angle_b"</span> <span class="lg-highlight-punctuation">:</span> NumberDecimal(<span class="lg-highlight-string">"0.6435011087932843868028092287173227"</span>)<span class="lg-highlight-punctuation">,</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">"angle_c"</span> <span class="lg-highlight-punctuation">:</span> NumberDecimal(<span class="lg-highlight-string">"1.570796326794896619231321691639752"</span>)</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-punctuation">}</span></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 aggregation operation uses the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-expression-exp.-radiansToDegrees" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $radiansToDegrees </code> </span> </a> expression to convert each value to its degree equivalent and add them to the input document using the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/addFields/#mongodb-pipeline-pipe.-addFields"> <code class="leafygreen-ui-1l06pbn"> $addFields </code> </a> pipeline stage. </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.trigangles.aggregate([\n {\n $addFields: {\n \"angle_a_deg\" : { $radiansToDegrees : \"$angle_a\"},\n \"angle_b_deg\" : { $radiansToDegrees : \"$angle_b\"},\n \"angle_c_deg\" : { $radiansToDegrees : \"$angle_c\"}\n }\n }\n])","programmingLanguage":"Bash"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" tabindex="-1"><code class="lg-highlight-hljs-light bash leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">db.trigangles.aggregate([</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> {</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-variable">$addFields</span>: {</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"angle_a_deg"</span> : { <span class="lg-highlight-variable">$radiansToDegrees</span> : <span class="lg-highlight-string">"</span><span class="lg-highlight-variable lg-highlight-string">$angle_a</span><span class="lg-highlight-string">"</span>},</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"angle_b_deg"</span> : { <span class="lg-highlight-variable">$radiansToDegrees</span> : <span class="lg-highlight-string">"</span><span class="lg-highlight-variable lg-highlight-string">$angle_b</span><span class="lg-highlight-string">"</span>},</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"angle_c_deg"</span> : { <span class="lg-highlight-variable">$radiansToDegrees</span> : <span class="lg-highlight-string">"</span><span class="lg-highlight-variable lg-highlight-string">$angle_c</span><span class="lg-highlight-string">"</span>}</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">])</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 operation returns the following document: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{\n \"_id\" : ObjectId(\"5c50aec71c75c59232b3ede4\"),\n \"angle_a\" : NumberDecimal(\"0.9272952180016122324285124629224290\"),\n \"angle_b\" : NumberDecimal(\"0.6435011087932843868028092287173227\"),\n \"angle_c\" : NumberDecimal(\"1.570796326794896619231321691639752\"),\n \"angle_a_deg\" : NumberDecimal(\"53.13010235415597870314438744090659\"),\n \"angle_b_deg\" : NumberDecimal(\"36.86989764584402129685561255909341\"),\n \"angle_c_deg\" : NumberDecimal(\"90.00000000000000000000000000000000\")\n}","programmingLanguage":"Bash"} </script> <div class="css-1lju8ps"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-tyg50d"> <pre class="leafygreen-ui-1453az5" tabindex="0"><code class="lg-highlight-hljs-light bash leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"_id"</span> : ObjectId(<span class="lg-highlight-string">"5c50aec71c75c59232b3ede4"</span>),</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"angle_a"</span> : NumberDecimal(<span class="lg-highlight-string">"0.9272952180016122324285124629224290"</span>),</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"angle_b"</span> : NumberDecimal(<span class="lg-highlight-string">"0.6435011087932843868028092287173227"</span>),</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"angle_c"</span> : NumberDecimal(<span class="lg-highlight-string">"1.570796326794896619231321691639752"</span>),</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"angle_a_deg"</span> : NumberDecimal(<span class="lg-highlight-string">"53.13010235415597870314438744090659"</span>),</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"angle_b_deg"</span> : NumberDecimal(<span class="lg-highlight-string">"36.86989764584402129685561255909341"</span>),</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"angle_c_deg"</span> : NumberDecimal(<span class="lg-highlight-string">"90.00000000000000000000000000000000"</span>)</td></tr><tr class=""><td class="leafygreen-ui-7razhx">}</td></tr></tbody></table></code></pre> </div> </div> </div> <p class="leafygreen-ui-1kp3ins"> Since <code class="leafygreen-ui-1l06pbn"> angle_a </code> , <code class="leafygreen-ui-1l06pbn"> angle_b </code> , and <code class="leafygreen-ui-1l06pbn"> angle_c </code> are stored as <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/mongodb-shell/reference/data-types/#std-label-shell-type-decimal" target="_self"> <span> 128-bit decimals </span> </a> , the output of <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-expression-exp.-radiansToDegrees" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $radiansToDegrees </code> </span> </a> is a 128-bit decimal. </p> </section> </section>
https://www.mongodb.com/docs/manual/tutorial/insert-documents/
<section> <h1 class="contains-headerlink leafygreen-ui-41fr9s" weight="medium"> Insert Documents <a class="headerlink leafygreen-ui-1kepx47" href="#insert-documents" 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="insert-documents"> </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="#insert-documents-in-the-mongodb-atlas-ui" target="_self"> <span> Insert Documents in the MongoDB Atlas UI </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#insert-a-single-document" target="_self"> <span> Insert a Single Document </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#insert-multiple-documents" target="_self"> <span> Insert Multiple Documents </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#insert-behavior" target="_self"> <span> Insert Behavior </span> </a> </li> </ul> </div> <hr class="css-1unva0n e4ru7ww0"/> <p class="leafygreen-ui-1kp3ins"> ➤ <!-- --> Use the <strong> Select your language </strong> drop-down menu in the upper-right to set the language of the following examples or select MongoDB Compass. </p> <hr class="css-1unva0n e4ru7ww0"/> <p class="leafygreen-ui-1kp3ins"> This page provides examples of insert operations in MongoDB. </p> <p class="leafygreen-ui-1kp3ins"> You can insert documents in MongoDB by using the following methods: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Your programming language's driver. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> The <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/atlas/" target="_self"> <span> MongoDB Atlas UI </span> </a> . To learn more, see <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-insert-documents-atlas" target="_self"> <span> Insert Documents in the MongoDB Atlas UI </span> </a> . </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/compass/current/" target="_self"> <span> MongoDB Compass <!-- --> . </span> </a> </p> </li> </ul> <div class="leafygreen-ui-15mdk4" role="note"> <h2 class="leafygreen-ui-6n7b7d"> Note </h2> <h3 class="leafygreen-ui-144d5kf"> <strong> Creating a Collection </strong> </h3> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> If the collection does not currently exist, insert operations will create the collection. </p> </div> </div> <span class="leafygreen-ui-1qnjd6d" id="std-label-insert-documents-atlas"> </span> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Insert Documents in the MongoDB Atlas UI <a class="headerlink leafygreen-ui-1kepx47" href="#insert-documents-in-the-mongodb-atlas-ui" 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="insert-documents-in-the-mongodb-atlas-ui"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> To insert a document in the MongoDB Atlas UI, complete the following steps. To learn more about working with documents in the MongoDB Atlas UI, see <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/atlas/atlas-ui/documents/" target="_self"> <span> Create, View, Update, and Delete Documents <!-- --> . </span> </a> </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"HowTo","steps":[{"@type":"HowToStep","text":"If it's not already displayed, select the organization that\ncontains your desired project from the Organizations menu in the\nnavigation bar.If it's not already displayed, select your project\nfrom the Projects menu in the navigation bar.If it's not already displayed, click Clusters in the\nsidebar.The Clusters page displays.","name":"In the MongoDB Atlas UI, go to the Clusters page for your project."},{"@type":"HowToStep","text":"For the cluster to which you want to add documents,\nclick Browse Collections.In the left navigation pane, select the database.In the left navigation pane, select the collection.","name":"Navigate to the collection"},{"@type":"HowToStep","text":"Click Insert Document.Click the {} icon, which opens the JSON view.Paste the document array into the text entry field. For\nexample, the following entry creates four documents, each of\nwhich contain three fields:","name":"Add the documents"},{"@type":"HowToStep","text":"MongoDB Atlas adds the documents to the collection.","name":"Click Insert."}],"name":"Insert Documents in the MongoDB Atlas UI","image":"https://webimages.mongodb.com/_com_assets/cms/kuyj2focmkbxv7gh3-stacked_default_slate_blue.svg?auto=format%252Ccompress"} </script> <div class="css-4nyere eccljxs0"> <div class="css-1nuklj8 e1ckbxcu1"> <div class="css-18fui5z e1ckbxcu0"> <div class="css-19lsqsq e1ckbxcu2"> 1 </div> </div> <div class="css-1ed38mk"> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> In the MongoDB Atlas UI, go to the <span class="guilabel css-h15tq0"> Clusters </span> page for your project. <a class="headerlink leafygreen-ui-1kepx47" href="#in-the-mongodb-atlas-ui--go-to-the-clusters-page-for-your-project." 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="in-the-mongodb-atlas-ui--go-to-the-clusters-page-for-your-project."> </div> </a> </h3> <ol class="leafygreen-ui-rioki0" type="a"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> If it's not already displayed, select the organization that contains your desired project from the <i class="mms-icon-office mms-icon"> </i> <span class="guilabel css-h15tq0"> Organizations </span> menu <!-- --> in the navigation bar. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> If it's not already displayed, select your project from the <span class="guilabel css-h15tq0"> Projects </span> menu in the navigation bar. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> If it's not already displayed, click <span class="guilabel css-h15tq0"> Clusters </span> in the sidebar. </p> <p class="leafygreen-ui-1kp3ins"> The <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://cloud.mongodb.com/go?l=https%3A%2F%2Fcloud.mongodb.com%2Fv2%2F%3Cproject%3E%23%2Fclusters" target="_self"> <span> Clusters </span> </a> page displays. </p> </li> </ol> </section> </div> </div> <div class="css-1nuklj8 e1ckbxcu1"> <div class="css-18fui5z e1ckbxcu0"> <div class="css-19lsqsq e1ckbxcu2"> 2 </div> </div> <div class="css-1ed38mk"> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Navigate to the collection <a class="headerlink leafygreen-ui-1kepx47" href="#navigate-to-the-collection" 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="navigate-to-the-collection"> </div> </a> </h3> <ol class="leafygreen-ui-rioki0" type="a"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> For the cluster to which you want to add documents, click <span class="guilabel css-h15tq0"> Browse Collections </span> . </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> In the left navigation pane, select the database. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> In the left navigation pane, select the collection. </p> </li> </ol> </section> </div> </div> <div class="css-1nuklj8 e1ckbxcu1"> <div class="css-18fui5z e1ckbxcu0"> <div class="css-19lsqsq e1ckbxcu2"> 3 </div> </div> <div class="css-1ed38mk"> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Add the documents <a class="headerlink leafygreen-ui-1kepx47" href="#add-the-documents" 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="add-the-documents"> </div> </a> </h3> <ol class="leafygreen-ui-rioki0" type="a"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Click <span class="guilabel css-h15tq0"> Insert Document </span> . </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Click the <span class="guilabel css-h15tq0"> {} </span> icon, which opens the JSON view. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Paste the document array into the text entry field. For example, the following entry creates four documents, each of which contain three fields: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"[\n { \"prodId\": 100, \"price\": 20, \"quantity\": 125 },\n { \"prodId\": 101, \"price\": 10, \"quantity\": 234 },\n { \"prodId\": 102, \"price\": 15, \"quantity\": 432 },\n { \"prodId\": 103, \"price\": 17, \"quantity\": 320 }\n]"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><code class="lg-highlight-hljs-light none leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> { "prodId": 100, "price": 20, "quantity": 125 },</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> { "prodId": 101, "price": 10, "quantity": 234 },</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> { "prodId": 102, "price": 15, "quantity": 432 },</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> { "prodId": 103, "price": 17, "quantity": 320 }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">]</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> </li> </ol> </section> </div> </div> <div class="css-1nuklj8 e1ckbxcu1"> <div class="css-18fui5z e1ckbxcu0"> <div class="css-19lsqsq e1ckbxcu2"> 4 </div> </div> <div class="css-1ed38mk"> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Click Insert. <a class="headerlink leafygreen-ui-1kepx47" href="#click-insert." 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="click-insert."> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> MongoDB Atlas adds the documents to the collection. </p> </section> </div> </div> </div> <span class="leafygreen-ui-1qnjd6d" id="std-label-write-op-insertOne"> </span> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Insert a Single Document <a class="headerlink leafygreen-ui-1kepx47" href="#insert-a-single-document" 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="insert-a-single-document"> </div> </a> </h2> <div aria-hidden="true"> </div> <div class="leafygreen-ui-f2qztv" data-lgid="lg-tabs"> <div class="leafygreen-ui-jp7pox" id="tabs-10"> <div aria-label="Tabs to describe usage of drivers" aria-orientation="horizontal" class="leafygreen-ui-m8p1vb lg-ui-tab-list-0000" data-lgid="lg-tabs-tab_list" role="tablist"> <button aria-controls="_3cum8ckjd" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_ogjhe8qcy" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> MongoDB Shell </div> </button> <button aria-controls="_yx3c6vkcp" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_oratzz6n8" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Compass </div> </button> <button aria-controls="_07q5htacy" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_nye7bvugx" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> C </div> </button> <button aria-controls="_5fl29zmmd" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_w5e3labug" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> C# </div> </button> <button aria-controls="_igs2geq0e" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_26529s41h" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Go </div> </button> <button aria-controls="_p7qoadwe1" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_8selv6hxz" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Java (Async) </div> </button> <button aria-controls="_20pnj8zvv" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_qhosy0ght" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Java (Sync) </div> </button> <button aria-controls="_ub0xgstf1" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_be3stsyu4" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Kotlin (Coroutine) </div> </button> <button aria-controls="_84fmfmn5m" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_fb09ivnpx" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Motor </div> </button> <button aria-controls="_1bqgyftsi" aria-selected="true" class="leafygreen-ui-1l773z1" data-text="" id="_jgg6erk07" name="" role="tab" tabindex="0"> <div class="leafygreen-ui-1nxuzmg"> Node.js </div> </button> <button aria-controls="_nb13y9byk" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_23y5zz6vh" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Perl </div> </button> <button aria-controls="_gdia9pk44" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_2cs18nsq5" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> PHP </div> </button> <button aria-controls="_4zc5j60u1" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_ahcrnmytn" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Python </div> </button> <button aria-controls="_3dki5vwbd" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_zv6cvmnac" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Ruby </div> </button> <button aria-controls="_6ktz79tmz" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_ygxxyzljy" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Scala </div> </button> </div> <div class="leafygreen-ui-ov1ktg"> <div class="leafygreen-ui-1sg2lsz"> </div> </div> </div> <div class="lg-ui-tab-panels-0000" data-lgid="lg-tabs-tab_panels"> <div> <div aria-labelledby="_2ynl91xrc" class="leafygreen-ui-38lglc" id="_ocb0g9for" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/db.collection.insertOne/#mongodb-method-db.collection.insertOne"> <code class="leafygreen-ui-1l06pbn"> db.collection.insertOne() </code> </a> inserts a <em> single </em> <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/document/#std-label-bson-document-format"> document </a> into a collection. </p> <p class="leafygreen-ui-1kp3ins"> The following example inserts a new document into the <code class="leafygreen-ui-1l06pbn"> inventory </code> collection. If the document does not specify an <code class="leafygreen-ui-1l06pbn"> _id </code> field, MongoDB adds the <code class="leafygreen-ui-1l06pbn"> _id </code> field with an ObjectId value to the new document. See <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-write-op-insert-behavior" target="_self"> <span> Insert Behavior <!-- --> . </span> </a> </p> </div> </div> </div> <div> <div aria-labelledby="_flthb8nzs" class="leafygreen-ui-38lglc" id="_gof4hjw91" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <p class="leafygreen-ui-1kp3ins"> To insert a single document using <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/compass/current/#std-label-compass-index" target="_self"> <span> MongoDB Compass <!-- --> : </span> </a> </p> <ol class="leafygreen-ui-rioki0" type="1"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Navigate to the collection you wish to insert the document into: </p> <ol class="leafygreen-ui-rioki0" type="a"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> In the left-hand MongoDB Compass navigation pane, click the database to which your target collection belongs. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> From the database view, click the target collection name. </p> </li> </ol> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Click the <span class="guilabel css-h15tq0"> Insert Document </span> button: </p> <div class="figure css-5vkxs0" style="width:auto"> <div class="gatsby-image-wrapper gatsby-image-wrapper-constrained leafygreen-ui-12xaq6r" data-gatsby-image-wrapper=""> <div style="max-width:750px;display:block"> <img alt="" aria-hidden="true" role="presentation" src="data:image/svg+xml;charset=utf-8,%3Csvg%20height='183.00000000000003'%20width='750'%20xmlns='http://www.w3.org/2000/svg'%20version='1.1'%3E%3C/svg%3E" style="max-width:100%;display:block;position:static"/> </div> <div aria-hidden="true" data-placeholder-image="" style="opacity:1;transition:opacity 500ms linear"> </div> <img alt="Compass insert button" data-main-image="" decoding="async" height="183.00000000000003" loading="lazy" sizes="(min-width: 750px) 750px, 100vw" src="/docs/manual/static/1e5739913a10d7e330c2b9ab3fb94207/b7b89/compass-insert-button.webp" srcset="/docs/manual/static/1e5739913a10d7e330c2b9ab3fb94207/2e628/compass-insert-button.webp 188w,/docs/manual/static/1e5739913a10d7e330c2b9ab3fb94207/101ef/compass-insert-button.webp 375w,/docs/manual/static/1e5739913a10d7e330c2b9ab3fb94207/b7b89/compass-insert-button.webp 750w" style="--border-color:#C1C7C6;opacity:0" width="750"/> <noscript> <img alt="Compass insert button" data-gatsby-image-ssr="" data-main-image="" decoding="async" height="183.00000000000003" loading="lazy" sizes="(min-width: 750px) 750px, 100vw" src="/docs/manual/static/1e5739913a10d7e330c2b9ab3fb94207/b7b89/compass-insert-button.webp" srcset="/docs/manual/static/1e5739913a10d7e330c2b9ab3fb94207/2e628/compass-insert-button.webp 188w,/docs/manual/static/1e5739913a10d7e330c2b9ab3fb94207/101ef/compass-insert-button.webp 375w,/docs/manual/static/1e5739913a10d7e330c2b9ab3fb94207/b7b89/compass-insert-button.webp 750w" style="--border-color:#C1C7C6;opacity:0" width="750"/> </noscript> <script type="module"> const t="undefined"!=typeof HTMLImageElement&&"loading"in HTMLImageElement.prototype;if(t){const t=document.querySelectorAll("img[data-main-image]");for(let e of t){e.dataset.src&&(e.setAttribute("src",e.dataset.src),e.removeAttribute("data-src")),e.dataset.srcset&&(e.setAttribute("srcset",e.dataset.srcset),e.removeAttribute("data-srcset"));const t=e.parentNode.querySelectorAll("source[data-srcset]");for(let e of t)e.setAttribute("srcset",e.dataset.srcset),e.removeAttribute("data-srcset");e.complete&&(e.style.opacity=1,e.parentNode.parentNode.querySelector("[data-placeholder-image]").style.opacity=0)}} </script> </div> </div> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> For each field in the document, select the field type and fill in the field name and value. Add fields by clicking the last line number, then clicking <span class="guilabel css-h15tq0"> Add Field After ... </span> </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> For <code class="leafygreen-ui-1l06pbn"> Object </code> types, add nested fields by clicking the last field's number and selecting <span class="guilabel css-h15tq0"> Add Field After ... </span> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> For <code class="leafygreen-ui-1l06pbn"> Array </code> types, add additional elements to the array by clicking the last element's line number and selecting <span class="guilabel css-h15tq0"> Add Array Element After ... </span> </p> </li> </ul> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Once all fields have been filled out, click <span class="guilabel css-h15tq0"> Insert </span> . </p> </li> </ol> <p class="leafygreen-ui-1kp3ins"> The following example inserts a new document into the <code class="leafygreen-ui-1l06pbn"> test.inventory </code> collection: </p> </div> </div> </div> <div> <div aria-labelledby="_qhxc4x374" class="leafygreen-ui-38lglc" id="_qc69ncmxr" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <p class="leafygreen-ui-1kp3ins"> The following example inserts a new document into the <code class="leafygreen-ui-1l06pbn"> inventory </code> collection. If the document does not specify an <code class="leafygreen-ui-1l06pbn"> _id </code> field, the C driver adds the <code class="leafygreen-ui-1l06pbn"> _id </code> field with an ObjectId value to the new document. For more information, see <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-write-op-insert-behavior" target="_self"> <span> Insert Behavior <!-- --> . </span> </a> </p> </div> </div> </div> <div> <div aria-labelledby="_zbcfzt2pu" class="leafygreen-ui-38lglc" id="_knvqmkxm0" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://mongodb.github.io/mongo-csharp-driver/2.10/apidocs/html/M_MongoDB_Driver_IMongoCollection_1_InsertOne.htm" rel="noopener noreferrer"> <span> IMongoCollection.InsertOne() </span> <svg alt="" aria-hidden="true" class="leafygreen-ui-1ie5kuq" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M13.823 2.4491C13.8201 2.30008 13.6999 2.17994 13.5509 2.17704L9.5062 2.09836C9.25654 2.09351 9.12821 2.39519 9.30482 2.5718L10.3856 3.65257L7.93433 6.10383C7.87964 6.15852 7.83047 6.21665 7.78683 6.27752L5.99909 8.06525C5.46457 8.59977 5.46457 9.4664 5.99909 10.0009C6.53361 10.5354 7.40023 10.5354 7.93475 10.0009L9.72249 8.21317C9.78336 8.16953 9.84148 8.12037 9.89618 8.06567L12.3474 5.61441L13.4282 6.69518C13.6048 6.87179 13.9065 6.74347 13.9016 6.4938L13.823 2.4491Z" fill="currentColor"> </path> <path d="M7.25 3.12893C7.66421 3.12893 8 3.46472 8 3.87893C8 4.29315 7.66421 4.62893 7.25 4.62893H4C3.72386 4.62893 3.5 4.85279 3.5 5.12893V11.9929C3.5 12.2691 3.72386 12.4929 4 12.4929H10.864C11.1401 12.4929 11.364 12.2691 11.364 11.9929V8.75C11.364 8.33579 11.6998 8 12.114 8C12.5282 8 12.864 8.33579 12.864 8.75V11.9929C12.864 13.0975 11.9686 13.9929 10.864 13.9929H4C2.89543 13.9929 2 13.0975 2 11.9929V5.12893C2 4.02436 2.89543 3.12893 4 3.12893H7.25Z" fill="currentColor"> </path> </svg> </a> inserts a <em> single </em> <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/document/#std-label-bson-document-format"> document </a> into a collection. </p> <p class="leafygreen-ui-1kp3ins"> The following example inserts a new document into the <code class="leafygreen-ui-1l06pbn"> inventory </code> collection. If the document does not specify an <code class="leafygreen-ui-1l06pbn"> _id </code> field, the C# driver adds the <code class="leafygreen-ui-1l06pbn"> _id </code> field with an ObjectId value to the new document. See <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-write-op-insert-behavior" target="_self"> <span> Insert Behavior <!-- --> . </span> </a> </p> </div> </div> </div> <div> <div aria-labelledby="_xnvxdpkbc" class="leafygreen-ui-38lglc" id="_9ey5xo1ym" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://godoc.org/github.com/mongodb/mongo-go-driver/mongo#Collection.InsertOne" rel="noopener noreferrer"> <span> Collection.InsertOne </span> <svg alt="" aria-hidden="true" class="leafygreen-ui-1ie5kuq" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M13.823 2.4491C13.8201 2.30008 13.6999 2.17994 13.5509 2.17704L9.5062 2.09836C9.25654 2.09351 9.12821 2.39519 9.30482 2.5718L10.3856 3.65257L7.93433 6.10383C7.87964 6.15852 7.83047 6.21665 7.78683 6.27752L5.99909 8.06525C5.46457 8.59977 5.46457 9.4664 5.99909 10.0009C6.53361 10.5354 7.40023 10.5354 7.93475 10.0009L9.72249 8.21317C9.78336 8.16953 9.84148 8.12037 9.89618 8.06567L12.3474 5.61441L13.4282 6.69518C13.6048 6.87179 13.9065 6.74347 13.9016 6.4938L13.823 2.4491Z" fill="currentColor"> </path> <path d="M7.25 3.12893C7.66421 3.12893 8 3.46472 8 3.87893C8 4.29315 7.66421 4.62893 7.25 4.62893H4C3.72386 4.62893 3.5 4.85279 3.5 5.12893V11.9929C3.5 12.2691 3.72386 12.4929 4 12.4929H10.864C11.1401 12.4929 11.364 12.2691 11.364 11.9929V8.75C11.364 8.33579 11.6998 8 12.114 8C12.5282 8 12.864 8.33579 12.864 8.75V11.9929C12.864 13.0975 11.9686 13.9929 10.864 13.9929H4C2.89543 13.9929 2 13.0975 2 11.9929V5.12893C2 4.02436 2.89543 3.12893 4 3.12893H7.25Z" fill="currentColor"> </path> </svg> </a> inserts a <em> single </em> <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/document/#std-label-bson-document-format"> document </a> into a collection. </p> <p class="leafygreen-ui-1kp3ins"> The following example inserts a new document into the <code class="leafygreen-ui-1l06pbn"> inventory </code> collection. If the document does not specify an <code class="leafygreen-ui-1l06pbn"> _id </code> field, the driver adds the <code class="leafygreen-ui-1l06pbn"> _id </code> field with an ObjectId value to the new document. See <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-write-op-insert-behavior" target="_self"> <span> Insert Behavior <!-- --> . </span> </a> </p> </div> </div> </div> <div> <div aria-labelledby="_7nuqum6qi" class="leafygreen-ui-38lglc" id="_j0nr1yzs8" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="http://mongodb.github.io/mongo-java-driver-reactivestreams/1.6/javadoc/com/mongodb/reactivestreams/client/MongoCollection.html#insertOne(TDocument)" rel="noopener noreferrer"> <span> com.mongodb.reactivestreams.client.MongoCollection.insertOne </span> <svg alt="" aria-hidden="true" class="leafygreen-ui-1ie5kuq" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M13.823 2.4491C13.8201 2.30008 13.6999 2.17994 13.5509 2.17704L9.5062 2.09836C9.25654 2.09351 9.12821 2.39519 9.30482 2.5718L10.3856 3.65257L7.93433 6.10383C7.87964 6.15852 7.83047 6.21665 7.78683 6.27752L5.99909 8.06525C5.46457 8.59977 5.46457 9.4664 5.99909 10.0009C6.53361 10.5354 7.40023 10.5354 7.93475 10.0009L9.72249 8.21317C9.78336 8.16953 9.84148 8.12037 9.89618 8.06567L12.3474 5.61441L13.4282 6.69518C13.6048 6.87179 13.9065 6.74347 13.9016 6.4938L13.823 2.4491Z" fill="currentColor"> </path> <path d="M7.25 3.12893C7.66421 3.12893 8 3.46472 8 3.87893C8 4.29315 7.66421 4.62893 7.25 4.62893H4C3.72386 4.62893 3.5 4.85279 3.5 5.12893V11.9929C3.5 12.2691 3.72386 12.4929 4 12.4929H10.864C11.1401 12.4929 11.364 12.2691 11.364 11.9929V8.75C11.364 8.33579 11.6998 8 12.114 8C12.5282 8 12.864 8.33579 12.864 8.75V11.9929C12.864 13.0975 11.9686 13.9929 10.864 13.9929H4C2.89543 13.9929 2 13.0975 2 11.9929V5.12893C2 4.02436 2.89543 3.12893 4 3.12893H7.25Z" fill="currentColor"> </path> </svg> </a> inserts a <em> single </em> <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/document/#std-label-bson-document-format"> document </a> into a collection with the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="http://mongodb.github.io/mongo-java-driver-reactivestreams/1.6/" rel="noopener noreferrer"> <span> Java Reactive Streams Driver </span> <svg alt="" aria-hidden="true" class="leafygreen-ui-1ie5kuq" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M13.823 2.4491C13.8201 2.30008 13.6999 2.17994 13.5509 2.17704L9.5062 2.09836C9.25654 2.09351 9.12821 2.39519 9.30482 2.5718L10.3856 3.65257L7.93433 6.10383C7.87964 6.15852 7.83047 6.21665 7.78683 6.27752L5.99909 8.06525C5.46457 8.59977 5.46457 9.4664 5.99909 10.0009C6.53361 10.5354 7.40023 10.5354 7.93475 10.0009L9.72249 8.21317C9.78336 8.16953 9.84148 8.12037 9.89618 8.06567L12.3474 5.61441L13.4282 6.69518C13.6048 6.87179 13.9065 6.74347 13.9016 6.4938L13.823 2.4491Z" fill="currentColor"> </path> <path d="M7.25 3.12893C7.66421 3.12893 8 3.46472 8 3.87893C8 4.29315 7.66421 4.62893 7.25 4.62893H4C3.72386 4.62893 3.5 4.85279 3.5 5.12893V11.9929C3.5 12.2691 3.72386 12.4929 4 12.4929H10.864C11.1401 12.4929 11.364 12.2691 11.364 11.9929V8.75C11.364 8.33579 11.6998 8 12.114 8C12.5282 8 12.864 8.33579 12.864 8.75V11.9929C12.864 13.0975 11.9686 13.9929 10.864 13.9929H4C2.89543 13.9929 2 13.0975 2 11.9929V5.12893C2 4.02436 2.89543 3.12893 4 3.12893H7.25Z" fill="currentColor"> </path> </svg> </a> : </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ item: \"canvas\", qty: 100, tags: [\"cotton\"], size: { h: 28, w: 35.5, uom: \"cm\" } }","programmingLanguage":"JSON"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <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">{ <span class="lg-highlight-attr">item</span>: <span class="lg-highlight-string">"canvas"</span>, <span class="lg-highlight-attr">qty</span>: <span class="lg-highlight-number">100</span>, <span class="lg-highlight-attr">tags</span>: [<span class="lg-highlight-string">"cotton"</span>], <span class="lg-highlight-attr">size</span>: { <span class="lg-highlight-attr">h</span>: <span class="lg-highlight-number">28</span>, <span class="lg-highlight-attr">w</span>: <span class="lg-highlight-number">35.5</span>, <span class="lg-highlight-attr">uom</span>: <span class="lg-highlight-string">"cm"</span> } }</td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-26-menu" aria-describedby="select-26-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-27" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:r7g:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":r7g:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r7g:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r7g:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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 example inserts the document above into the <code class="leafygreen-ui-1l06pbn"> inventory </code> collection. If the document does not specify an <code class="leafygreen-ui-1l06pbn"> _id </code> field, the driver adds the <code class="leafygreen-ui-1l06pbn"> _id </code> field with an ObjectId value to the new document. See <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-write-op-insert-behavior" target="_self"> <span> Insert Behavior <!-- --> . </span> </a> </p> </div> </div> </div> <div> <div aria-labelledby="_8xgkgtxfz" class="leafygreen-ui-38lglc" id="_y3d6ip9f4" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://mongodb.github.io/mongo-java-driver/3.4/javadoc/com/mongodb/client/MongoCollection.html#insertOne-TDocument-" rel="noopener noreferrer"> <span> com.mongodb.client.MongoCollection.insertOne </span> <svg alt="" aria-hidden="true" class="leafygreen-ui-1ie5kuq" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M13.823 2.4491C13.8201 2.30008 13.6999 2.17994 13.5509 2.17704L9.5062 2.09836C9.25654 2.09351 9.12821 2.39519 9.30482 2.5718L10.3856 3.65257L7.93433 6.10383C7.87964 6.15852 7.83047 6.21665 7.78683 6.27752L5.99909 8.06525C5.46457 8.59977 5.46457 9.4664 5.99909 10.0009C6.53361 10.5354 7.40023 10.5354 7.93475 10.0009L9.72249 8.21317C9.78336 8.16953 9.84148 8.12037 9.89618 8.06567L12.3474 5.61441L13.4282 6.69518C13.6048 6.87179 13.9065 6.74347 13.9016 6.4938L13.823 2.4491Z" fill="currentColor"> </path> <path d="M7.25 3.12893C7.66421 3.12893 8 3.46472 8 3.87893C8 4.29315 7.66421 4.62893 7.25 4.62893H4C3.72386 4.62893 3.5 4.85279 3.5 5.12893V11.9929C3.5 12.2691 3.72386 12.4929 4 12.4929H10.864C11.1401 12.4929 11.364 12.2691 11.364 11.9929V8.75C11.364 8.33579 11.6998 8 12.114 8C12.5282 8 12.864 8.33579 12.864 8.75V11.9929C12.864 13.0975 11.9686 13.9929 10.864 13.9929H4C2.89543 13.9929 2 13.0975 2 11.9929V5.12893C2 4.02436 2.89543 3.12893 4 3.12893H7.25Z" fill="currentColor"> </path> </svg> </a> inserts a <em> single </em> <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/document/#std-label-bson-document-format"> document </a> into a collection. </p> <p class="leafygreen-ui-1kp3ins"> The following example inserts a new document into the <code class="leafygreen-ui-1l06pbn"> inventory </code> collection. If the document does not specify an <code class="leafygreen-ui-1l06pbn"> _id </code> field, the driver adds the <code class="leafygreen-ui-1l06pbn"> _id </code> field with an ObjectId value to the new document. See <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-write-op-insert-behavior" target="_self"> <span> Insert Behavior <!-- --> . </span> </a> </p> </div> </div> </div> <div> <div aria-labelledby="_u2txs0oha" class="leafygreen-ui-38lglc" id="_e6ecoeoeo" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://mongodb.github.io/mongo-java-driver/4.11/apidocs/mongodb-driver-kotlin-coroutine/mongodb-driver-kotlin-coroutine/com.mongodb.kotlin.client.coroutine/-mongo-collection/insert-one.html" rel="noopener noreferrer"> <span> MongoCollection.insertOne </span> <svg alt="" aria-hidden="true" class="leafygreen-ui-1ie5kuq" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M13.823 2.4491C13.8201 2.30008 13.6999 2.17994 13.5509 2.17704L9.5062 2.09836C9.25654 2.09351 9.12821 2.39519 9.30482 2.5718L10.3856 3.65257L7.93433 6.10383C7.87964 6.15852 7.83047 6.21665 7.78683 6.27752L5.99909 8.06525C5.46457 8.59977 5.46457 9.4664 5.99909 10.0009C6.53361 10.5354 7.40023 10.5354 7.93475 10.0009L9.72249 8.21317C9.78336 8.16953 9.84148 8.12037 9.89618 8.06567L12.3474 5.61441L13.4282 6.69518C13.6048 6.87179 13.9065 6.74347 13.9016 6.4938L13.823 2.4491Z" fill="currentColor"> </path> <path d="M7.25 3.12893C7.66421 3.12893 8 3.46472 8 3.87893C8 4.29315 7.66421 4.62893 7.25 4.62893H4C3.72386 4.62893 3.5 4.85279 3.5 5.12893V11.9929C3.5 12.2691 3.72386 12.4929 4 12.4929H10.864C11.1401 12.4929 11.364 12.2691 11.364 11.9929V8.75C11.364 8.33579 11.6998 8 12.114 8C12.5282 8 12.864 8.33579 12.864 8.75V11.9929C12.864 13.0975 11.9686 13.9929 10.864 13.9929H4C2.89543 13.9929 2 13.0975 2 11.9929V5.12893C2 4.02436 2.89543 3.12893 4 3.12893H7.25Z" fill="currentColor"> </path> </svg> </a> inserts a <em> single </em> <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/document/#std-label-bson-document-format"> document </a> into a collection. </p> <p class="leafygreen-ui-1kp3ins"> The following example inserts a new document into the <code class="leafygreen-ui-1l06pbn"> inventory </code> collection. If the document does not specify an <code class="leafygreen-ui-1l06pbn"> _id </code> field, the driver adds the <code class="leafygreen-ui-1l06pbn"> _id </code> field with an ObjectId value to the new document. See <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-write-op-insert-behavior" target="_self"> <span> Insert Behavior <!-- --> . </span> </a> </p> </div> </div> </div> <div> <div aria-labelledby="_zputl9ls2" class="leafygreen-ui-38lglc" id="_984tgh2k8" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://motor.readthedocs.io/en/stable/api-asyncio/asyncio_motor_collection.html#motor.motor_asyncio.AsyncIOMotorCollection.insert_one" rel="noopener noreferrer"> <span> <code class="leafygreen-ui-1l06pbn"> motor.motor_asyncio.AsyncIOMotorCollection.insert_one </code> </span> <svg alt="" aria-hidden="true" class="leafygreen-ui-1ie5kuq" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M13.823 2.4491C13.8201 2.30008 13.6999 2.17994 13.5509 2.17704L9.5062 2.09836C9.25654 2.09351 9.12821 2.39519 9.30482 2.5718L10.3856 3.65257L7.93433 6.10383C7.87964 6.15852 7.83047 6.21665 7.78683 6.27752L5.99909 8.06525C5.46457 8.59977 5.46457 9.4664 5.99909 10.0009C6.53361 10.5354 7.40023 10.5354 7.93475 10.0009L9.72249 8.21317C9.78336 8.16953 9.84148 8.12037 9.89618 8.06567L12.3474 5.61441L13.4282 6.69518C13.6048 6.87179 13.9065 6.74347 13.9016 6.4938L13.823 2.4491Z" fill="currentColor"> </path> <path d="M7.25 3.12893C7.66421 3.12893 8 3.46472 8 3.87893C8 4.29315 7.66421 4.62893 7.25 4.62893H4C3.72386 4.62893 3.5 4.85279 3.5 5.12893V11.9929C3.5 12.2691 3.72386 12.4929 4 12.4929H10.864C11.1401 12.4929 11.364 12.2691 11.364 11.9929V8.75C11.364 8.33579 11.6998 8 12.114 8C12.5282 8 12.864 8.33579 12.864 8.75V11.9929C12.864 13.0975 11.9686 13.9929 10.864 13.9929H4C2.89543 13.9929 2 13.0975 2 11.9929V5.12893C2 4.02436 2.89543 3.12893 4 3.12893H7.25Z" fill="currentColor"> </path> </svg> </a> inserts a <em> single </em> <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/document/#std-label-bson-document-format"> document </a> into a collection. </p> <p class="leafygreen-ui-1kp3ins"> The following example inserts a new document into the <code class="leafygreen-ui-1l06pbn"> inventory </code> collection. If the document does not specify an <code class="leafygreen-ui-1l06pbn"> _id </code> field, the Motor driver adds the <code class="leafygreen-ui-1l06pbn"> _id </code> field with an ObjectId value to the new document. See <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-write-op-insert-behavior" target="_self"> <span> Insert Behavior <!-- --> . </span> </a> </p> </div> </div> </div> <div> <div aria-labelledby="_94in3399k" class="" id="_5dq36b45g" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="http://mongodb.github.io/node-mongodb-native/3.6/api/Collection.html#insertOne" rel="noopener noreferrer"> <span> Collection.insertOne() </span> <svg alt="" aria-hidden="true" class="leafygreen-ui-1ie5kuq" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M13.823 2.4491C13.8201 2.30008 13.6999 2.17994 13.5509 2.17704L9.5062 2.09836C9.25654 2.09351 9.12821 2.39519 9.30482 2.5718L10.3856 3.65257L7.93433 6.10383C7.87964 6.15852 7.83047 6.21665 7.78683 6.27752L5.99909 8.06525C5.46457 8.59977 5.46457 9.4664 5.99909 10.0009C6.53361 10.5354 7.40023 10.5354 7.93475 10.0009L9.72249 8.21317C9.78336 8.16953 9.84148 8.12037 9.89618 8.06567L12.3474 5.61441L13.4282 6.69518C13.6048 6.87179 13.9065 6.74347 13.9016 6.4938L13.823 2.4491Z" fill="currentColor"> </path> <path d="M7.25 3.12893C7.66421 3.12893 8 3.46472 8 3.87893C8 4.29315 7.66421 4.62893 7.25 4.62893H4C3.72386 4.62893 3.5 4.85279 3.5 5.12893V11.9929C3.5 12.2691 3.72386 12.4929 4 12.4929H10.864C11.1401 12.4929 11.364 12.2691 11.364 11.9929V8.75C11.364 8.33579 11.6998 8 12.114 8C12.5282 8 12.864 8.33579 12.864 8.75V11.9929C12.864 13.0975 11.9686 13.9929 10.864 13.9929H4C2.89543 13.9929 2 13.0975 2 11.9929V5.12893C2 4.02436 2.89543 3.12893 4 3.12893H7.25Z" fill="currentColor"> </path> </svg> </a> inserts a <em> single </em> <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/document/#std-label-bson-document-format"> document </a> into a collection. </p> <p class="leafygreen-ui-1kp3ins"> The following example inserts a new document into the <code class="leafygreen-ui-1l06pbn"> inventory </code> collection. If the document does not specify an <code class="leafygreen-ui-1l06pbn"> _id </code> field, the Node.js driver adds the <code class="leafygreen-ui-1l06pbn"> _id </code> field with an ObjectId value to the new document. See <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-write-op-insert-behavior" target="_self"> <span> Insert Behavior <!-- --> . </span> </a> </p> </div> </div> </div> <div> <div aria-labelledby="_q23e1is85" class="leafygreen-ui-38lglc" id="_9xvzd0tt5" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://metacpan.org/pod/MongoDB::Collection#insert_one" rel="noopener noreferrer"> <span> MongoDB::Collection::insert_one() </span> <svg alt="" aria-hidden="true" class="leafygreen-ui-1ie5kuq" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M13.823 2.4491C13.8201 2.30008 13.6999 2.17994 13.5509 2.17704L9.5062 2.09836C9.25654 2.09351 9.12821 2.39519 9.30482 2.5718L10.3856 3.65257L7.93433 6.10383C7.87964 6.15852 7.83047 6.21665 7.78683 6.27752L5.99909 8.06525C5.46457 8.59977 5.46457 9.4664 5.99909 10.0009C6.53361 10.5354 7.40023 10.5354 7.93475 10.0009L9.72249 8.21317C9.78336 8.16953 9.84148 8.12037 9.89618 8.06567L12.3474 5.61441L13.4282 6.69518C13.6048 6.87179 13.9065 6.74347 13.9016 6.4938L13.823 2.4491Z" fill="currentColor"> </path> <path d="M7.25 3.12893C7.66421 3.12893 8 3.46472 8 3.87893C8 4.29315 7.66421 4.62893 7.25 4.62893H4C3.72386 4.62893 3.5 4.85279 3.5 5.12893V11.9929C3.5 12.2691 3.72386 12.4929 4 12.4929H10.864C11.1401 12.4929 11.364 12.2691 11.364 11.9929V8.75C11.364 8.33579 11.6998 8 12.114 8C12.5282 8 12.864 8.33579 12.864 8.75V11.9929C12.864 13.0975 11.9686 13.9929 10.864 13.9929H4C2.89543 13.9929 2 13.0975 2 11.9929V5.12893C2 4.02436 2.89543 3.12893 4 3.12893H7.25Z" fill="currentColor"> </path> </svg> </a> inserts a <em> single </em> <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/document/#std-label-bson-document-format"> document </a> into a collection. </p> <p class="leafygreen-ui-1kp3ins"> The following example inserts a new document into the <code class="leafygreen-ui-1l06pbn"> inventory </code> collection. If the document does not specify an <code class="leafygreen-ui-1l06pbn"> _id </code> field, the Perl driver adds the <code class="leafygreen-ui-1l06pbn"> _id </code> field with an ObjectId value to the new document. See <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-write-op-insert-behavior" target="_self"> <span> Insert Behavior <!-- --> . </span> </a> </p> </div> </div> </div> <div> <div aria-labelledby="_b94jim0t6" class="leafygreen-ui-38lglc" id="_q709e35dx" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/php-library/upcoming/reference/method/MongoDBCollection-insertOne/#mongodb-phpmethod-phpmethod.MongoDB-Collection--insertOne--" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> MongoDB\\Collection::insertOne() </code> </span> </a> inserts a <em> single </em> <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/document/#std-label-bson-document-format"> document </a> into a collection. </p> <p class="leafygreen-ui-1kp3ins"> The following example inserts a new document into the <code class="leafygreen-ui-1l06pbn"> inventory </code> collection. If the document does not specify an <code class="leafygreen-ui-1l06pbn"> _id </code> field, the PHP driver adds the <code class="leafygreen-ui-1l06pbn"> _id </code> field with an ObjectId value to the new document. See <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-write-op-insert-behavior" target="_self"> <span> Insert Behavior <!-- --> . </span> </a> </p> </div> </div> </div> <div> <div aria-labelledby="_sq7kkaac1" class="leafygreen-ui-38lglc" id="_fg3q8roas" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://pymongo.readthedocs.io/en/stable/api/pymongo/collection.html#pymongo.collection.Collection.insert_one" rel="noopener noreferrer"> <span> <code class="leafygreen-ui-1l06pbn"> pymongo.collection.Collection.insert_one </code> </span> <svg alt="" aria-hidden="true" class="leafygreen-ui-1ie5kuq" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M13.823 2.4491C13.8201 2.30008 13.6999 2.17994 13.5509 2.17704L9.5062 2.09836C9.25654 2.09351 9.12821 2.39519 9.30482 2.5718L10.3856 3.65257L7.93433 6.10383C7.87964 6.15852 7.83047 6.21665 7.78683 6.27752L5.99909 8.06525C5.46457 8.59977 5.46457 9.4664 5.99909 10.0009C6.53361 10.5354 7.40023 10.5354 7.93475 10.0009L9.72249 8.21317C9.78336 8.16953 9.84148 8.12037 9.89618 8.06567L12.3474 5.61441L13.4282 6.69518C13.6048 6.87179 13.9065 6.74347 13.9016 6.4938L13.823 2.4491Z" fill="currentColor"> </path> <path d="M7.25 3.12893C7.66421 3.12893 8 3.46472 8 3.87893C8 4.29315 7.66421 4.62893 7.25 4.62893H4C3.72386 4.62893 3.5 4.85279 3.5 5.12893V11.9929C3.5 12.2691 3.72386 12.4929 4 12.4929H10.864C11.1401 12.4929 11.364 12.2691 11.364 11.9929V8.75C11.364 8.33579 11.6998 8 12.114 8C12.5282 8 12.864 8.33579 12.864 8.75V11.9929C12.864 13.0975 11.9686 13.9929 10.864 13.9929H4C2.89543 13.9929 2 13.0975 2 11.9929V5.12893C2 4.02436 2.89543 3.12893 4 3.12893H7.25Z" fill="currentColor"> </path> </svg> </a> inserts a <em> single </em> <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/document/#std-label-bson-document-format"> document </a> into a collection. </p> <p class="leafygreen-ui-1kp3ins"> The following example inserts a new document into the <code class="leafygreen-ui-1l06pbn"> inventory </code> collection. If the document does not specify an <code class="leafygreen-ui-1l06pbn"> _id </code> field, the PyMongo driver adds the <code class="leafygreen-ui-1l06pbn"> _id </code> field with an ObjectId value to the new document. See <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-write-op-insert-behavior" target="_self"> <span> Insert Behavior <!-- --> . </span> </a> </p> </div> </div> </div> <div> <div aria-labelledby="_9102mxi0f" class="leafygreen-ui-38lglc" id="_akw0vb4lq" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="http://api.mongodb.com/ruby/current/Mongo/Collection.html#insert_one-instance_method" target="_self"> <span> Mongo::Collection#insert_one() </span> </a> inserts a <em> single </em> <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/document/#std-label-bson-document-format"> document </a> into a collection. </p> <p class="leafygreen-ui-1kp3ins"> The following example inserts a new document into the <code class="leafygreen-ui-1l06pbn"> inventory </code> collection. If the document does not specify an <code class="leafygreen-ui-1l06pbn"> _id </code> field, the Ruby driver adds the <code class="leafygreen-ui-1l06pbn"> _id </code> field with an ObjectId value to the new document. See <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-write-op-insert-behavior" target="_self"> <span> Insert Behavior <!-- --> . </span> </a> </p> </div> </div> </div> <div> <div aria-labelledby="_qztjz88ur" class="leafygreen-ui-38lglc" id="_d2upr85vh" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="http://mongodb.github.io/mongo-scala-driver/2.9/scaladoc/org/mongodb/scala/MongoCollection.html#insertOne(document:TResult,options:org.mongodb.scala.model.InsertOneOptions):org.mongodb.scala.SingleObservable[org.mongodb.scala.Completed]" rel="noopener noreferrer"> <span> collection.insertOne() </span> <svg alt="" aria-hidden="true" class="leafygreen-ui-1ie5kuq" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M13.823 2.4491C13.8201 2.30008 13.6999 2.17994 13.5509 2.17704L9.5062 2.09836C9.25654 2.09351 9.12821 2.39519 9.30482 2.5718L10.3856 3.65257L7.93433 6.10383C7.87964 6.15852 7.83047 6.21665 7.78683 6.27752L5.99909 8.06525C5.46457 8.59977 5.46457 9.4664 5.99909 10.0009C6.53361 10.5354 7.40023 10.5354 7.93475 10.0009L9.72249 8.21317C9.78336 8.16953 9.84148 8.12037 9.89618 8.06567L12.3474 5.61441L13.4282 6.69518C13.6048 6.87179 13.9065 6.74347 13.9016 6.4938L13.823 2.4491Z" fill="currentColor"> </path> <path d="M7.25 3.12893C7.66421 3.12893 8 3.46472 8 3.87893C8 4.29315 7.66421 4.62893 7.25 4.62893H4C3.72386 4.62893 3.5 4.85279 3.5 5.12893V11.9929C3.5 12.2691 3.72386 12.4929 4 12.4929H10.864C11.1401 12.4929 11.364 12.2691 11.364 11.9929V8.75C11.364 8.33579 11.6998 8 12.114 8C12.5282 8 12.864 8.33579 12.864 8.75V11.9929C12.864 13.0975 11.9686 13.9929 10.864 13.9929H4C2.89543 13.9929 2 13.0975 2 11.9929V5.12893C2 4.02436 2.89543 3.12893 4 3.12893H7.25Z" fill="currentColor"> </path> </svg> </a> inserts a <em> single </em> <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/document/#std-label-bson-document-format"> document </a> into a collection. </p> <p class="leafygreen-ui-1kp3ins"> The following example inserts a new document into the <code class="leafygreen-ui-1l06pbn"> inventory </code> collection. If the document does not specify an <code class="leafygreen-ui-1l06pbn"> _id </code> field, the Scala driver adds the <code class="leafygreen-ui-1l06pbn"> _id </code> field with an ObjectId value to the new document. See <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-write-op-insert-behavior" target="_self"> <span> Insert Behavior <!-- --> . </span> </a> </p> </div> </div> </div> </div> </div> <div aria-hidden="true"> </div> <div class="leafygreen-ui-f2qztv" data-lgid="lg-tabs"> <div class="leafygreen-ui-jp7pox" id="tabs-11"> <div aria-label="Tabs to describe usage of drivers" aria-orientation="horizontal" class="leafygreen-ui-m8p1vb lg-ui-tab-list-0000" data-lgid="lg-tabs-tab_list" role="tablist"> <button aria-controls="_9kaskbixr" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_dubew7zeu" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> MongoDB Shell </div> </button> <button aria-controls="_shmy4kl5g" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_r2fkr6r4e" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Compass </div> </button> <button aria-controls="_uhshjg04g" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_8l4mzis4n" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> C </div> </button> <button aria-controls="_s3fpetw4s" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_84emklofv" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> C# </div> </button> <button aria-controls="_g0j37tns1" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_3wc2k1ggr" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Go </div> </button> <button aria-controls="_1hug96x5e" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_12d6wslfd" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Java (Async) </div> </button> <button aria-controls="_rulrvth3c" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_nfo2rdfxp" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Java (Sync) </div> </button> <button aria-controls="_wk4kkc7uf" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_q2txqhifj" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Kotlin (Coroutine) </div> </button> <button aria-controls="_ynx0omfkj" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_tkt3md0dz" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Motor </div> </button> <button aria-controls="_haf8apzm7" aria-selected="true" class="leafygreen-ui-1l773z1" data-text="" id="_d4yls763j" name="" role="tab" tabindex="0"> <div class="leafygreen-ui-1nxuzmg"> Node.js </div> </button> <button aria-controls="_38luda2xc" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_1q1k6ygc0" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Perl </div> </button> <button aria-controls="_ty6hjubb1" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_myxnxzf8w" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> PHP </div> </button> <button aria-controls="_tkg3599yf" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_jxoi2xgcv" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Python </div> </button> <button aria-controls="_hvefklvc2" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_llf7iugnv" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Ruby </div> </button> <button aria-controls="_do3vac4ua" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_nu78lsced" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Scala </div> </button> </div> <div class="leafygreen-ui-ov1ktg"> <div class="leafygreen-ui-1sg2lsz"> </div> </div> </div> <div class="lg-ui-tab-panels-0000" data-lgid="lg-tabs-tab_panels"> <div> <div aria-labelledby="_athh7ttcx" class="leafygreen-ui-38lglc" id="_nlyvqq6zs" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.inventory.insertOne(\n { item: \"canvas\", qty: 100, tags: [\"cotton\"], size: { h: 28, w: 35.5, uom: \"cm\" } }\n)","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <pre class="leafygreen-ui-11itue3" 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">inventory</span>.<span class="lg-highlight-title lg-highlight-function">insertOne</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">item</span>: <span class="lg-highlight-string">"canvas"</span>, <span class="lg-highlight-attr">qty</span>: <span class="lg-highlight-number">100</span>, <span class="lg-highlight-attr">tags</span>: <!-- -->[<span class="lg-highlight-string">"cotton"</span>]<!-- -->, <span class="lg-highlight-attr">size</span>: <!-- -->{ <span class="lg-highlight-attr">h</span>: <span class="lg-highlight-number">28</span>, <span class="lg-highlight-attr">w</span>: <span class="lg-highlight-number">35.5</span>, <span class="lg-highlight-attr">uom</span>: <span class="lg-highlight-string">"cm"</span> } }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">)</td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-29-menu" aria-describedby="select-29-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-30" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:r7h:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":r7h:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r7h:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r7h:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_ybf7632rb" class="leafygreen-ui-38lglc" id="_x04e395rp" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <div class="figure css-5vkxs0" style="width:auto"> <div class="gatsby-image-wrapper gatsby-image-wrapper-constrained leafygreen-ui-12xaq6r" data-gatsby-image-wrapper=""> <div style="max-width:595px;display:block"> <img alt="" aria-hidden="true" role="presentation" src="data:image/svg+xml;charset=utf-8,%3Csvg%20height='333'%20width='595'%20xmlns='http://www.w3.org/2000/svg'%20version='1.1'%3E%3C/svg%3E" style="max-width:100%;display:block;position:static"/> </div> <div aria-hidden="true" data-placeholder-image="" style="opacity:1;transition:opacity 500ms linear"> </div> <img alt="Compass insert new document into collection" data-main-image="" decoding="async" height="333" loading="lazy" sizes="(min-width: 595px) 595px, 100vw" src="/docs/manual/static/2d694df48ae42b01eb9b9cb72c3f12c8/dedbb/compass-insert-document-inventory.webp" srcset="/docs/manual/static/2d694df48ae42b01eb9b9cb72c3f12c8/6ec1f/compass-insert-document-inventory.webp 149w,/docs/manual/static/2d694df48ae42b01eb9b9cb72c3f12c8/ea6fa/compass-insert-document-inventory.webp 298w,/docs/manual/static/2d694df48ae42b01eb9b9cb72c3f12c8/dedbb/compass-insert-document-inventory.webp 595w" style="--border-color:#C1C7C6;opacity:0" width="595"/> <noscript> <img alt="Compass insert new document into collection" data-gatsby-image-ssr="" data-main-image="" decoding="async" height="333" loading="lazy" sizes="(min-width: 595px) 595px, 100vw" src="/docs/manual/static/2d694df48ae42b01eb9b9cb72c3f12c8/dedbb/compass-insert-document-inventory.webp" srcset="/docs/manual/static/2d694df48ae42b01eb9b9cb72c3f12c8/6ec1f/compass-insert-document-inventory.webp 149w,/docs/manual/static/2d694df48ae42b01eb9b9cb72c3f12c8/ea6fa/compass-insert-document-inventory.webp 298w,/docs/manual/static/2d694df48ae42b01eb9b9cb72c3f12c8/dedbb/compass-insert-document-inventory.webp 595w" style="--border-color:#C1C7C6;opacity:0" width="595"/> </noscript> <script type="module"> const t="undefined"!=typeof HTMLImageElement&&"loading"in HTMLImageElement.prototype;if(t){const t=document.querySelectorAll("img[data-main-image]");for(let e of t){e.dataset.src&&(e.setAttribute("src",e.dataset.src),e.removeAttribute("data-src")),e.dataset.srcset&&(e.setAttribute("srcset",e.dataset.srcset),e.removeAttribute("data-srcset"));const t=e.parentNode.querySelectorAll("source[data-srcset]");for(let e of t)e.setAttribute("srcset",e.dataset.srcset),e.removeAttribute("data-srcset");e.complete&&(e.style.opacity=1,e.parentNode.parentNode.querySelector("[data-placeholder-image]").style.opacity=0)}} </script> </div> </div> </div> </div> </div> <div> <div aria-labelledby="_2vksxr2kh" class="leafygreen-ui-38lglc" id="_58p3i6uvm" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"mongoc_collection_t *collection;\nbson_t *doc;\nbool r;\nbson_error_t error;\n\ncollection = mongoc_database_get_collection (db, \"inventory\");\ndoc = BCON_NEW (\n \"item\", BCON_UTF8 (\"canvas\"),\n \"qty\", BCON_INT64 (100),\n \"tags\", \"[\",\n BCON_UTF8 (\"cotton\"),\n \"]\",\n \"size\", \"{\",\n \"h\", BCON_DOUBLE (28),\n \"w\", BCON_DOUBLE (35.5),\n \"uom\", BCON_UTF8 (\"cm\"),\n \"}\");\n\nr = mongoc_collection_insert_one (collection, doc, NULL, NULL, &amp;error);\nbson_destroy (doc);\n\nif (!r) {\n MONGOC_ERROR (\"%s\\n\", error.message);\n goto done;\n}","programmingLanguage":"C"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <pre class="leafygreen-ui-11itue3" 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">mongoc_collection_t *collection;</td></tr><tr class=""><td class="leafygreen-ui-7razhx">bson_t *doc;</td></tr><tr class=""><td class="leafygreen-ui-7razhx">bool r;</td></tr><tr class=""><td class="leafygreen-ui-7razhx">bson_error_t error;</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><div class="leafygreen-ui-ihxujy"></div></td></tr><tr class=""><td class="leafygreen-ui-7razhx">collection <!-- -->= <!-- -->mongoc_database_get_collection (db<!-- -->, <span class="lg-highlight-string">"inventory"</span>);</td></tr><tr class=""><td class="leafygreen-ui-7razhx">doc <!-- -->= <!-- --><span class="lg-highlight-variable lg-highlight-constant">BCON_NEW</span> (</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"item"</span>, <!-- --><span class="lg-highlight-variable lg-highlight-constant">BCON_UTF8</span> (<!-- --><span class="lg-highlight-string">"canvas"</span>),</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"qty"</span>, <!-- --><span class="lg-highlight-variable lg-highlight-constant">BCON_INT64</span> (<!-- --><span class="lg-highlight-number">100</span>),</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"tags"</span>, <span class="lg-highlight-string">"["</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- --><span class="lg-highlight-variable lg-highlight-constant">BCON_UTF8</span> (<!-- --><span class="lg-highlight-string">"cotton"</span>),</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"]"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"size"</span>, <span class="lg-highlight-string">"{"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"h"</span>, <!-- --><span class="lg-highlight-variable lg-highlight-constant">BCON_DOUBLE</span> (<!-- --><span class="lg-highlight-number">28</span>),</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"w"</span>, <!-- --><span class="lg-highlight-variable lg-highlight-constant">BCON_DOUBLE</span> (<!-- --><span class="lg-highlight-number">35.5</span>),</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"uom"</span>, <!-- --><span class="lg-highlight-variable lg-highlight-constant">BCON_UTF8</span> (<!-- --><span class="lg-highlight-string">"cm"</span>),</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"}"</span>)<!-- -->;</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><div class="leafygreen-ui-ihxujy"></div></td></tr><tr class=""><td class="leafygreen-ui-7razhx">r <!-- -->= <!-- -->mongoc_collection_insert_one (collection, doc<!-- -->, <span class="lg-highlight-variable lg-highlight-constant">NULL</span>, <span class="lg-highlight-variable lg-highlight-constant">NULL</span>, &amp;error);</td></tr><tr class=""><td class="leafygreen-ui-7razhx">bson_destroy <!-- -->(<!-- -->doc);</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><div class="leafygreen-ui-ihxujy"></div></td></tr><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-keyword">if</span> <!-- -->(<!-- -->!r) {</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- --><span class="lg-highlight-variable lg-highlight-constant">MONGOC_ERROR</span> (<span class="lg-highlight-string">"%s</span><!-- --><span class="lg-highlight-string">\n</span><span class="lg-highlight-string">"</span>, error.<span class="lg-highlight-property">message</span>);</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> goto done;</td></tr><tr class=""><td class="leafygreen-ui-7razhx">}</td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-32-menu" aria-describedby="select-32-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-33" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:r7i:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":r7i:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r7i:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r7i:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_gscrbit0b" class="leafygreen-ui-38lglc" id="_lc21k4vt4" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"var document = new BsonDocument\n{\n { \"item\", \"canvas\" },\n { \"qty\", 100 },\n { \"tags\", new BsonArray { \"cotton\" } },\n { \"size\", new BsonDocument { { \"h\", 28 }, { \"w\", 35.5 }, { \"uom\", \"cm\" } } }\n};\ncollection.InsertOne(document);","programmingLanguage":"C#"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <pre class="leafygreen-ui-11itue3" 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"><span class="lg-highlight-keyword">var</span> <span class="lg-highlight-variable lg-highlight-language">document</span> = <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">BsonDocument</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx">{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> { <span class="lg-highlight-string">"item"</span>, <span class="lg-highlight-string">"canvas"</span> },</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> { <span class="lg-highlight-string">"qty"</span>, <span class="lg-highlight-number">100</span> },</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> { <span class="lg-highlight-string">"tags"</span>, <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">BsonArray</span> { <span class="lg-highlight-string">"cotton"</span> } },</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> { <span class="lg-highlight-string">"size"</span>, <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">BsonDocument</span> { { <span class="lg-highlight-string">"h"</span>, <span class="lg-highlight-number">28</span> }, { <span class="lg-highlight-string">"w"</span>, <span class="lg-highlight-number">35.5</span> }, { <span class="lg-highlight-string">"uom"</span>, <span class="lg-highlight-string">"cm"</span> } } }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">};</td></tr><tr class=""><td class="leafygreen-ui-7razhx">collection.<span class="lg-highlight-title lg-highlight-class">InsertOne</span>(<span class="lg-highlight-variable lg-highlight-language">document</span>);</td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-35-menu" aria-describedby="select-35-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-36" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:r7j:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":r7j:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r7j:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r7j:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_pwkyjwtws" class="leafygreen-ui-38lglc" id="_n89b01uk3" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"\nresult, err := coll.InsertOne(\n\tcontext.TODO(),\n\tbson.D{\n\t\t{\"item\", \"canvas\"},\n\t\t{\"qty\", 100},\n\t\t{\"tags\", bson.A{\"cotton\"}},\n\t\t{\"size\", bson.D{\n\t\t\t{\"h\", 28},\n\t\t\t{\"w\", 35.5},\n\t\t\t{\"uom\", \"cm\"},\n\t\t}},\n\t})\n","programmingLanguage":"Golang"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <pre class="leafygreen-ui-11itue3" 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">result<!-- -->, <!-- -->err := coll.<span class="lg-highlight-title lg-highlight-class">InsertOne</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> context.<span class="lg-highlight-title lg-highlight-function">TODO</span>(),</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> bson.<span class="lg-highlight-property">D</span>{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> {<span class="lg-highlight-string">"item"</span>, <span class="lg-highlight-string">"canvas"</span>},</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> {<span class="lg-highlight-string">"qty"</span>, <span class="lg-highlight-number">100</span>},</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> {<span class="lg-highlight-string">"tags"</span>, bson.<span class="lg-highlight-property">A</span>{<span class="lg-highlight-string">"cotton"</span>}},</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> {<span class="lg-highlight-string">"size"</span>, bson.<span class="lg-highlight-property">D</span>{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> {<span class="lg-highlight-string">"h"</span>, <span class="lg-highlight-number">28</span>},</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> {<span class="lg-highlight-string">"w"</span>, <span class="lg-highlight-number">35.5</span>},</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> {<span class="lg-highlight-string">"uom"</span>, <span class="lg-highlight-string">"cm"</span>},</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }},</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> })</td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-38-menu" aria-describedby="select-38-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-39" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:r7k:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":r7k:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r7k:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r7k:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_xb1ypwz8h" class="leafygreen-ui-38lglc" id="_anrwgwpsf" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"Document canvas = new Document(\"item\", \"canvas\")\n .append(\"qty\", 100)\n .append(\"tags\", singletonList(\"cotton\"));\n\nDocument size = new Document(\"h\", 28)\n .append(\"w\", 35.5)\n .append(\"uom\", \"cm\");\ncanvas.put(\"size\", size);\n\nPublisher&lt;success&gt; insertOnePublisher = collection.insertOne(canvas);","programmingLanguage":"Java"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <pre class="leafygreen-ui-11itue3" 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"><span class="lg-highlight-title lg-highlight-class">Document</span> canvas = <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">Document</span>(<span class="lg-highlight-string">"item"</span>, <span class="lg-highlight-string">"canvas"</span>)</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> .<span class="lg-highlight-title lg-highlight-function">append</span>(<span class="lg-highlight-string">"qty"</span>, <span class="lg-highlight-number">100</span>)</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> .<span class="lg-highlight-title lg-highlight-function">append</span>(<span class="lg-highlight-string">"tags"</span>, <span class="lg-highlight-title lg-highlight-function">singletonList</span>(<span class="lg-highlight-string">"cotton"</span>));</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><div class="leafygreen-ui-ihxujy"></div></td></tr><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-title lg-highlight-class">Document</span> size = <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">Document</span>(<span class="lg-highlight-string">"h"</span>, <span class="lg-highlight-number">28</span>)</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> .<span class="lg-highlight-title lg-highlight-function">append</span>(<span class="lg-highlight-string">"w"</span>, <span class="lg-highlight-number">35.5</span>)</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> .<span class="lg-highlight-title lg-highlight-function">append</span>(<span class="lg-highlight-string">"uom"</span>, <span class="lg-highlight-string">"cm"</span>);</td></tr><tr class=""><td class="leafygreen-ui-7razhx">canvas.<span class="lg-highlight-title lg-highlight-function">put</span>(<span class="lg-highlight-string">"size"</span>, size);</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><div class="leafygreen-ui-ihxujy"></div></td></tr><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-title lg-highlight-class">Publisher</span>&lt;<span class="lg-highlight-title lg-highlight-class">Success</span>&gt; insertOnePublisher = collection.<span class="lg-highlight-title lg-highlight-function">insertOne</span>(canvas);</td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-41-menu" aria-describedby="select-41-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-42" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:r7l:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":r7l:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r7l:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r7l:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_gnbwvwaty" class="leafygreen-ui-38lglc" id="_zseiwpz8p" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"Document canvas = new Document(\"item\", \"canvas\")\n .append(\"qty\", 100)\n .append(\"tags\", singletonList(\"cotton\"));\n\nDocument size = new Document(\"h\", 28)\n .append(\"w\", 35.5)\n .append(\"uom\", \"cm\");\ncanvas.put(\"size\", size);\n\ncollection.insertOne(canvas);","programmingLanguage":"Java"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <pre class="leafygreen-ui-11itue3" 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"><span class="lg-highlight-title lg-highlight-class">Document</span> canvas = <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">Document</span>(<span class="lg-highlight-string">"item"</span>, <span class="lg-highlight-string">"canvas"</span>)</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> .<span class="lg-highlight-title lg-highlight-function">append</span>(<span class="lg-highlight-string">"qty"</span>, <span class="lg-highlight-number">100</span>)</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> .<span class="lg-highlight-title lg-highlight-function">append</span>(<span class="lg-highlight-string">"tags"</span>, <span class="lg-highlight-title lg-highlight-function">singletonList</span>(<span class="lg-highlight-string">"cotton"</span>));</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><div class="leafygreen-ui-ihxujy"></div></td></tr><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-title lg-highlight-class">Document</span> size = <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">Document</span>(<span class="lg-highlight-string">"h"</span>, <span class="lg-highlight-number">28</span>)</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> .<span class="lg-highlight-title lg-highlight-function">append</span>(<span class="lg-highlight-string">"w"</span>, <span class="lg-highlight-number">35.5</span>)</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> .<span class="lg-highlight-title lg-highlight-function">append</span>(<span class="lg-highlight-string">"uom"</span>, <span class="lg-highlight-string">"cm"</span>);</td></tr><tr class=""><td class="leafygreen-ui-7razhx">canvas.<span class="lg-highlight-title lg-highlight-function">put</span>(<span class="lg-highlight-string">"size"</span>, size);</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><div class="leafygreen-ui-ihxujy"></div></td></tr><tr class=""><td class="leafygreen-ui-7razhx">collection.<span class="lg-highlight-title lg-highlight-function">insertOne</span>(canvas);</td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-44-menu" aria-describedby="select-44-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-45" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:r7m:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":r7m:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r7m:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r7m:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_ofgzsirpg" class="leafygreen-ui-38lglc" id="_pbixlroh8" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"result = collection.insertOne(\nDocument(\"item\", \"canvas\")\n .append(\"qty\", 100)\n .append(\"tags\", listOf(\"cotton\"))\n .append(\"size\", Document(\"h\", 28)\n .append(\"w\", 35.5)\n .append(\"uom\", \"cm\")\n )\n","programmingLanguage":"Kotlin"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <pre class="leafygreen-ui-11itue3" 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">result = collection.<span class="lg-highlight-title lg-highlight-function">insertOne</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-title lg-highlight-class">Document</span>(<span class="lg-highlight-string">"item"</span>, <span class="lg-highlight-string">"canvas"</span>)</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> .<span class="lg-highlight-title lg-highlight-function">append</span>(<span class="lg-highlight-string">"qty"</span>, <span class="lg-highlight-number">100</span>)</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> .<span class="lg-highlight-title lg-highlight-function">append</span>(<span class="lg-highlight-string">"tags"</span>, <span class="lg-highlight-title lg-highlight-function">listOf</span>(<span class="lg-highlight-string">"cotton"</span>))</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> .<span class="lg-highlight-title lg-highlight-function">append</span>(<span class="lg-highlight-string">"size"</span>, <span class="lg-highlight-title lg-highlight-class">Document</span>(<span class="lg-highlight-string">"h"</span>, <span class="lg-highlight-number">28</span>)</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> .<span class="lg-highlight-title lg-highlight-function">append</span>(<span class="lg-highlight-string">"w"</span>, <span class="lg-highlight-number">35.5</span>)</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> .<span class="lg-highlight-title lg-highlight-function">append</span>(<span class="lg-highlight-string">"uom"</span>, <span class="lg-highlight-string">"cm"</span>)</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> )</td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-47-menu" aria-describedby="select-47-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-48" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:r7n:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":r7n:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r7n:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r7n:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_38x0nsto0" class="leafygreen-ui-38lglc" id="_jwi1338ww" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"await db.inventory.insert_one(\n {\n \"item\": \"canvas\",\n \"qty\": 100,\n \"tags\": [\"cotton\"],\n \"size\": {\"h\": 28, \"w\": 35.5, \"uom\": \"cm\"},\n }\n)","programmingLanguage":"Python"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <pre class="leafygreen-ui-11itue3" 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"><span class="lg-highlight-keyword">await</span> db.<span class="lg-highlight-property">inventory</span>.<span class="lg-highlight-title lg-highlight-function">insert_one</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> {</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"item"</span>: <span class="lg-highlight-string">"canvas"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"qty"</span>: <span class="lg-highlight-number">100</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"tags"</span>: [<span class="lg-highlight-string">"cotton"</span>],</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"size"</span>: {<span class="lg-highlight-string">"h"</span>: <span class="lg-highlight-number">28</span>, <span class="lg-highlight-string">"w"</span>: <span class="lg-highlight-number">35.5</span>, <span class="lg-highlight-string">"uom"</span>: <span class="lg-highlight-string">"cm"</span>},</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">)</td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-50-menu" aria-describedby="select-50-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-51" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:r7o:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":r7o:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r7o:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r7o:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_13mo9xsh3" class="" id="_jsu0ie5av" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"await db.collection('inventory').insertOne({\n item: 'canvas',\n qty: 100,\n tags: ['cotton'],\n size: { h: 28, w: 35.5, uom: 'cm' }\n});","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <pre class="leafygreen-ui-11itue3" 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"><span class="lg-highlight-keyword">await</span> db.<span class="lg-highlight-title lg-highlight-function">collection</span>(<span class="lg-highlight-string">'inventory'</span>).<span class="lg-highlight-title lg-highlight-function">insertOne</span>(<!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">item</span>: <span class="lg-highlight-string">'canvas'</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">qty</span>: <span class="lg-highlight-number">100</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">tags</span>: <!-- -->[<span class="lg-highlight-string">'cotton'</span>]<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">size</span>: <!-- -->{ <span class="lg-highlight-attr">h</span>: <span class="lg-highlight-number">28</span>, <span class="lg-highlight-attr">w</span>: <span class="lg-highlight-number">35.5</span>, <span class="lg-highlight-attr">uom</span>: <span class="lg-highlight-string">'cm'</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">})<!-- -->;</td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-53-menu" aria-describedby="select-53-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-54" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:r7p:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":r7p:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r7p:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r7p:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_luwiy536m" class="leafygreen-ui-38lglc" id="_5j0yjwa4f" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"$db-&gt;coll(\"inventory\")-&gt;insert_one(\n {\n item =&gt; \"canvas\",\n qty =&gt; 100,\n tags =&gt; [\"cotton\"],\n size =&gt; { h =&gt; 28, w =&gt; 35.5, uom =&gt; \"cm\" }\n }\n);","programmingLanguage":"Perl"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <pre class="leafygreen-ui-11itue3" 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<!-- -->-<!-- -->&gt;<!-- --><!-- --><span class="lg-highlight-title lg-highlight-function">coll</span>(<span class="lg-highlight-string">"inventory"</span>)<!-- -->-<!-- -->&gt;<!-- --><!-- --><span class="lg-highlight-title lg-highlight-function">insert_one</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-params lg-highlight-function">item</span><span class="lg-highlight-function"> =&gt;</span> <span class="lg-highlight-string">"canvas"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-params lg-highlight-function">qty</span><span class="lg-highlight-function"> =&gt;</span> <span class="lg-highlight-number">100</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-params lg-highlight-function">tags</span><!-- --><span class="lg-highlight-function"> =&gt;</span> <!-- -->[<span class="lg-highlight-string">"cotton"</span>],</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-params lg-highlight-function">size</span><!-- --><span class="lg-highlight-function"> =&gt;</span> { <span class="lg-highlight-params lg-highlight-function">h</span><span class="lg-highlight-function"> =&gt;</span> <span class="lg-highlight-number">28</span>, <span class="lg-highlight-params lg-highlight-function">w</span><span class="lg-highlight-function"> =&gt;</span> <span class="lg-highlight-number">35.5</span>, <span class="lg-highlight-params lg-highlight-function">uom</span><span class="lg-highlight-function"> =&gt;</span> <span class="lg-highlight-string">"cm"</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">)<!-- -->;</td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-56-menu" aria-describedby="select-56-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-57" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:r7q:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":r7q:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r7q:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r7q:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_36k8rlslg" class="leafygreen-ui-38lglc" id="_1wbvt6b6k" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"$insertOneResult = $db-&gt;inventory-&gt;insertOne([\n 'item' =&gt; 'canvas',\n 'qty' =&gt; 100,\n 'tags' =&gt; ['cotton'],\n 'size' =&gt; ['h' =&gt; 28, 'w' =&gt; 35.5, 'uom' =&gt; 'cm'],\n]);","programmingLanguage":"PHP"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <pre class="leafygreen-ui-11itue3" 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">$insertOneResult = $db-&gt;inventory-&gt;<span class="lg-highlight-title lg-highlight-function">insertOne</span>([</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">'item'</span> =&gt; <span class="lg-highlight-string">'canvas'</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">'qty'</span> =&gt; <span class="lg-highlight-number">100</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">'tags'</span> =&gt; [<span class="lg-highlight-string">'cotton'</span>],</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">'size'</span> =&gt; [<span class="lg-highlight-string">'h'</span> =&gt; <span class="lg-highlight-number">28</span>, <span class="lg-highlight-string">'w'</span> =&gt; <span class="lg-highlight-number">35.5</span>, <span class="lg-highlight-string">'uom'</span> =&gt; <span class="lg-highlight-string">'cm'</span>],</td></tr><tr class=""><td class="leafygreen-ui-7razhx">])<!-- -->;</td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-59-menu" aria-describedby="select-59-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-60" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:r7r:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":r7r:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r7r:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r7r:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_nwlu01jxz" class="leafygreen-ui-38lglc" id="_osukf8wc6" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.inventory.insert_one(\n {\n \"item\": \"canvas\",\n \"qty\": 100,\n \"tags\": [\"cotton\"],\n \"size\": {\"h\": 28, \"w\": 35.5, \"uom\": \"cm\"},\n }\n)","programmingLanguage":"Python"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <pre class="leafygreen-ui-11itue3" 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">inventory</span>.<span class="lg-highlight-title lg-highlight-function">insert_one</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> {</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"item"</span>: <span class="lg-highlight-string">"canvas"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"qty"</span>: <span class="lg-highlight-number">100</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"tags"</span>: [<span class="lg-highlight-string">"cotton"</span>],</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"size"</span>: {<span class="lg-highlight-string">"h"</span>: <span class="lg-highlight-number">28</span>, <span class="lg-highlight-string">"w"</span>: <span class="lg-highlight-number">35.5</span>, <span class="lg-highlight-string">"uom"</span>: <span class="lg-highlight-string">"cm"</span>},</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">)</td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-62-menu" aria-describedby="select-62-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-63" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:r7s:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":r7s:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r7s:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r7s:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_4rqudaunj" class="leafygreen-ui-38lglc" id="_0rj16ls0v" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"client[:inventory].insert_one({ item: 'canvas',\n qty: 100,\n tags: [ 'cotton' ],\n size: { h: 28, w: 35.5, uom: 'cm' } })","programmingLanguage":"Ruby"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <pre class="leafygreen-ui-11itue3" 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">client<!-- -->[<!-- -->:inventory].<span class="lg-highlight-title lg-highlight-function">insert_one</span>(<!-- -->{ <span class="lg-highlight-attr">item</span>: <span class="lg-highlight-string">'canvas'</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">qty</span>: <span class="lg-highlight-number">100</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">tags</span>: <!-- -->[ <span class="lg-highlight-string">'cotton'</span> ]<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">size</span>: <!-- -->{ <span class="lg-highlight-attr">h</span>: <span class="lg-highlight-number">28</span>, <span class="lg-highlight-attr">w</span>: <span class="lg-highlight-number">35.5</span>, <span class="lg-highlight-attr">uom</span>: <span class="lg-highlight-string">'cm'</span> } })</td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-65-menu" aria-describedby="select-65-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-66" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:r7t:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":r7t:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r7t:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r7t:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_2cajqdojy" class="leafygreen-ui-38lglc" id="_zsctvw7i5" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"collection.insertOne(\n Document(\"item\" -&gt; \"canvas\", \"qty\" -&gt; 100, \"tags\" -&gt; Seq(\"cotton\"), \"size\" -&gt; Document(\"h\" -&gt; 28, \"w\" -&gt; 35.5, \"uom\" -&gt; \"cm\"))\n).execute()","programmingLanguage":"Scala"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <pre class="leafygreen-ui-11itue3" 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">collection.<span class="lg-highlight-title lg-highlight-function">insertOne</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-title lg-highlight-class">Document</span>(<span class="lg-highlight-string">"item"</span> -&gt; <span class="lg-highlight-string">"canvas"</span>, <span class="lg-highlight-string">"qty"</span> -&gt; <span class="lg-highlight-number">100</span>, <span class="lg-highlight-string">"tags"</span> -&gt; <span class="lg-highlight-title lg-highlight-class">Seq</span>(<span class="lg-highlight-string">"cotton"</span>), <span class="lg-highlight-string">"size"</span> -&gt; <span class="lg-highlight-title lg-highlight-class">Document</span>(<span class="lg-highlight-string">"h"</span> -&gt; <span class="lg-highlight-number">28</span>, <span class="lg-highlight-string">"w"</span> -&gt; <span class="lg-highlight-number">35.5</span>, <span class="lg-highlight-string">"uom"</span> -&gt; <span class="lg-highlight-string">"cm"</span>))</td></tr><tr class=""><td class="leafygreen-ui-7razhx">).<span class="lg-highlight-title lg-highlight-function">execute</span>()</td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-68-menu" aria-describedby="select-68-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-69" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:r7u:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":r7u:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r7u:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r7u:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> </div> </div> <div aria-hidden="true"> </div> <div class="leafygreen-ui-f2qztv" data-lgid="lg-tabs"> <div class="leafygreen-ui-jp7pox" id="tabs-12"> <div aria-label="Tabs to describe usage of drivers" aria-orientation="horizontal" class="leafygreen-ui-m8p1vb lg-ui-tab-list-0000" data-lgid="lg-tabs-tab_list" role="tablist"> <button aria-controls="_ddjp5s1a5" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_eidaoml9m" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> MongoDB Shell </div> </button> <button aria-controls="_c7povt8kj" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_p8x510v2u" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Compass </div> </button> <button aria-controls="_oj835ylo7" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_gycehq634" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> C </div> </button> <button aria-controls="_ps7jgajkp" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_c5zcj7lbo" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> C# </div> </button> <button aria-controls="_17lhc94y7" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_akhwv2mfn" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Go </div> </button> <button aria-controls="_tvadv3gss" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_4n3p3tl0v" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Java (Async) </div> </button> <button aria-controls="_xp35ox03m" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_j21as87w5" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Java (Sync) </div> </button> <button aria-controls="_b4bt0douy" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_a6o35nuxe" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Kotlin (Coroutine) </div> </button> <button aria-controls="_se7kh50ax" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_23hmw9w1p" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Motor </div> </button> <button aria-controls="_01qb19h6f" aria-selected="true" class="leafygreen-ui-1l773z1" data-text="" id="_fjrvgw6rb" name="" role="tab" tabindex="0"> <div class="leafygreen-ui-1nxuzmg"> Node.js </div> </button> <button aria-controls="_9jljk066u" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_a127sypeb" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Perl </div> </button> <button aria-controls="_mtmk665pv" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_vdkx4t8kw" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> PHP </div> </button> <button aria-controls="_q5bomocda" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_1ajfxxelb" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Python </div> </button> <button aria-controls="_vq3xg5m60" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_q3anhdjty" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Ruby </div> </button> <button aria-controls="_s6g4k5njv" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_z7t1nbf6m" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Scala </div> </button> </div> <div class="leafygreen-ui-ov1ktg"> <div class="leafygreen-ui-1sg2lsz"> </div> </div> </div> <div class="lg-ui-tab-panels-0000" data-lgid="lg-tabs-tab_panels"> <div> <div aria-labelledby="_jqbkt7x5c" class="leafygreen-ui-38lglc" id="_1v0vtzyqn" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/db.collection.insertOne/#mongodb-method-db.collection.insertOne"> <code class="leafygreen-ui-1l06pbn"> insertOne() </code> </a> returns a document that includes the newly inserted document's <code class="leafygreen-ui-1l06pbn"> _id </code> field value. For an example of a return document, see <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/db.collection.insertOne/#std-label-insertOne-examples"> db.collection.insertOne() reference <!-- --> . </a> </p> </div> </div> </div> <div> <div aria-labelledby="_fnh4clkpm" class="leafygreen-ui-38lglc" id="_tqb2xe730" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <div class="leafygreen-ui-15mdk4" role="note"> <h2 class="leafygreen-ui-6n7b7d"> Note </h2> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> MongoDB Compass generates the <code class="leafygreen-ui-1l06pbn"> _id </code> field and its value automatically. The generated <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-ObjectId"> ObjectId </a> consists of a unique randomly generated hexadecimal value. </p> <p class="leafygreen-ui-1kp3ins"> You can change this value prior to inserting your document so long as it remains unique and is a valid <code class="leafygreen-ui-1l06pbn"> ObjectId </code> . For more information on the <code class="leafygreen-ui-1l06pbn"> _id </code> field, see <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-insert-id-field" target="_self"> <span> _id Field <!-- --> . </span> </a> </p> </div> </div> </div> </div> </div> <div> <div aria-labelledby="_8rcx53yr9" class="leafygreen-ui-38lglc" id="_is1jnv66u" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://mongoc.org/libmongoc/current/mongoc_collection_insert_one.html" rel="noopener noreferrer"> <span> mongoc_collection_insert_one </span> <svg alt="" aria-hidden="true" class="leafygreen-ui-1ie5kuq" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M13.823 2.4491C13.8201 2.30008 13.6999 2.17994 13.5509 2.17704L9.5062 2.09836C9.25654 2.09351 9.12821 2.39519 9.30482 2.5718L10.3856 3.65257L7.93433 6.10383C7.87964 6.15852 7.83047 6.21665 7.78683 6.27752L5.99909 8.06525C5.46457 8.59977 5.46457 9.4664 5.99909 10.0009C6.53361 10.5354 7.40023 10.5354 7.93475 10.0009L9.72249 8.21317C9.78336 8.16953 9.84148 8.12037 9.89618 8.06567L12.3474 5.61441L13.4282 6.69518C13.6048 6.87179 13.9065 6.74347 13.9016 6.4938L13.823 2.4491Z" fill="currentColor"> </path> <path d="M7.25 3.12893C7.66421 3.12893 8 3.46472 8 3.87893C8 4.29315 7.66421 4.62893 7.25 4.62893H4C3.72386 4.62893 3.5 4.85279 3.5 5.12893V11.9929C3.5 12.2691 3.72386 12.4929 4 12.4929H10.864C11.1401 12.4929 11.364 12.2691 11.364 11.9929V8.75C11.364 8.33579 11.6998 8 12.114 8C12.5282 8 12.864 8.33579 12.864 8.75V11.9929C12.864 13.0975 11.9686 13.9929 10.864 13.9929H4C2.89543 13.9929 2 13.0975 2 11.9929V5.12893C2 4.02436 2.89543 3.12893 4 3.12893H7.25Z" fill="currentColor"> </path> </svg> </a> returns <code class="leafygreen-ui-1l06pbn"> true </code> if successful, or returns <code class="leafygreen-ui-1l06pbn"> false </code> and sets error if there are invalid arguments or a server or network error. </p> </div> </div> </div> <div> <div aria-labelledby="_0h3i20hmq" class="leafygreen-ui-38lglc" id="_53rmi9t8g" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> </div> </div> </div> <div> <div aria-labelledby="_xxqs7u2or" class="leafygreen-ui-38lglc" id="_cjpc29apu" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://godoc.org/github.com/mongodb/mongo-go-driver/mongo#Collection.InsertOne" rel="noopener noreferrer"> <span> Collection.InsertOne </span> <svg alt="" aria-hidden="true" class="leafygreen-ui-1ie5kuq" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M13.823 2.4491C13.8201 2.30008 13.6999 2.17994 13.5509 2.17704L9.5062 2.09836C9.25654 2.09351 9.12821 2.39519 9.30482 2.5718L10.3856 3.65257L7.93433 6.10383C7.87964 6.15852 7.83047 6.21665 7.78683 6.27752L5.99909 8.06525C5.46457 8.59977 5.46457 9.4664 5.99909 10.0009C6.53361 10.5354 7.40023 10.5354 7.93475 10.0009L9.72249 8.21317C9.78336 8.16953 9.84148 8.12037 9.89618 8.06567L12.3474 5.61441L13.4282 6.69518C13.6048 6.87179 13.9065 6.74347 13.9016 6.4938L13.823 2.4491Z" fill="currentColor"> </path> <path d="M7.25 3.12893C7.66421 3.12893 8 3.46472 8 3.87893C8 4.29315 7.66421 4.62893 7.25 4.62893H4C3.72386 4.62893 3.5 4.85279 3.5 5.12893V11.9929C3.5 12.2691 3.72386 12.4929 4 12.4929H10.864C11.1401 12.4929 11.364 12.2691 11.364 11.9929V8.75C11.364 8.33579 11.6998 8 12.114 8C12.5282 8 12.864 8.33579 12.864 8.75V11.9929C12.864 13.0975 11.9686 13.9929 10.864 13.9929H4C2.89543 13.9929 2 13.0975 2 11.9929V5.12893C2 4.02436 2.89543 3.12893 4 3.12893H7.25Z" fill="currentColor"> </path> </svg> </a> function returns an instance of <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://godoc.org/github.com/mongodb/mongo-go-driver/mongo#InsertOneResult" rel="noopener noreferrer"> <span> InsertOneResult </span> <svg alt="" aria-hidden="true" class="leafygreen-ui-1ie5kuq" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M13.823 2.4491C13.8201 2.30008 13.6999 2.17994 13.5509 2.17704L9.5062 2.09836C9.25654 2.09351 9.12821 2.39519 9.30482 2.5718L10.3856 3.65257L7.93433 6.10383C7.87964 6.15852 7.83047 6.21665 7.78683 6.27752L5.99909 8.06525C5.46457 8.59977 5.46457 9.4664 5.99909 10.0009C6.53361 10.5354 7.40023 10.5354 7.93475 10.0009L9.72249 8.21317C9.78336 8.16953 9.84148 8.12037 9.89618 8.06567L12.3474 5.61441L13.4282 6.69518C13.6048 6.87179 13.9065 6.74347 13.9016 6.4938L13.823 2.4491Z" fill="currentColor"> </path> <path d="M7.25 3.12893C7.66421 3.12893 8 3.46472 8 3.87893C8 4.29315 7.66421 4.62893 7.25 4.62893H4C3.72386 4.62893 3.5 4.85279 3.5 5.12893V11.9929C3.5 12.2691 3.72386 12.4929 4 12.4929H10.864C11.1401 12.4929 11.364 12.2691 11.364 11.9929V8.75C11.364 8.33579 11.6998 8 12.114 8C12.5282 8 12.864 8.33579 12.864 8.75V11.9929C12.864 13.0975 11.9686 13.9929 10.864 13.9929H4C2.89543 13.9929 2 13.0975 2 11.9929V5.12893C2 4.02436 2.89543 3.12893 4 3.12893H7.25Z" fill="currentColor"> </path> </svg> </a> whose <code class="leafygreen-ui-1l06pbn"> InsertedID </code> attribute contains the <code class="leafygreen-ui-1l06pbn"> _id </code> of the newly inserted document. </p> </div> </div> </div> <div> <div aria-labelledby="_l3qnt96wo" class="leafygreen-ui-38lglc" id="_xx73d8xii" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="http://mongodb.github.io/mongo-java-driver-reactivestreams/1.6/javadoc/com/mongodb/reactivestreams/client/MongoCollection.html#insertOne(TDocument)" rel="noopener noreferrer"> <span> com.mongodb.reactivestreams.client.MongoCollection.insertOne </span> <svg alt="" aria-hidden="true" class="leafygreen-ui-1ie5kuq" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M13.823 2.4491C13.8201 2.30008 13.6999 2.17994 13.5509 2.17704L9.5062 2.09836C9.25654 2.09351 9.12821 2.39519 9.30482 2.5718L10.3856 3.65257L7.93433 6.10383C7.87964 6.15852 7.83047 6.21665 7.78683 6.27752L5.99909 8.06525C5.46457 8.59977 5.46457 9.4664 5.99909 10.0009C6.53361 10.5354 7.40023 10.5354 7.93475 10.0009L9.72249 8.21317C9.78336 8.16953 9.84148 8.12037 9.89618 8.06567L12.3474 5.61441L13.4282 6.69518C13.6048 6.87179 13.9065 6.74347 13.9016 6.4938L13.823 2.4491Z" fill="currentColor"> </path> <path d="M7.25 3.12893C7.66421 3.12893 8 3.46472 8 3.87893C8 4.29315 7.66421 4.62893 7.25 4.62893H4C3.72386 4.62893 3.5 4.85279 3.5 5.12893V11.9929C3.5 12.2691 3.72386 12.4929 4 12.4929H10.864C11.1401 12.4929 11.364 12.2691 11.364 11.9929V8.75C11.364 8.33579 11.6998 8 12.114 8C12.5282 8 12.864 8.33579 12.864 8.75V11.9929C12.864 13.0975 11.9686 13.9929 10.864 13.9929H4C2.89543 13.9929 2 13.0975 2 11.9929V5.12893C2 4.02436 2.89543 3.12893 4 3.12893H7.25Z" fill="currentColor"> </path> </svg> </a> returns a <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="http://www.reactive-streams.org/reactive-streams-1.0.1-javadoc/org/reactivestreams/Publisher.html" rel="noopener noreferrer"> <span> Publisher </span> <svg alt="" aria-hidden="true" class="leafygreen-ui-1ie5kuq" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M13.823 2.4491C13.8201 2.30008 13.6999 2.17994 13.5509 2.17704L9.5062 2.09836C9.25654 2.09351 9.12821 2.39519 9.30482 2.5718L10.3856 3.65257L7.93433 6.10383C7.87964 6.15852 7.83047 6.21665 7.78683 6.27752L5.99909 8.06525C5.46457 8.59977 5.46457 9.4664 5.99909 10.0009C6.53361 10.5354 7.40023 10.5354 7.93475 10.0009L9.72249 8.21317C9.78336 8.16953 9.84148 8.12037 9.89618 8.06567L12.3474 5.61441L13.4282 6.69518C13.6048 6.87179 13.9065 6.74347 13.9016 6.4938L13.823 2.4491Z" fill="currentColor"> </path> <path d="M7.25 3.12893C7.66421 3.12893 8 3.46472 8 3.87893C8 4.29315 7.66421 4.62893 7.25 4.62893H4C3.72386 4.62893 3.5 4.85279 3.5 5.12893V11.9929C3.5 12.2691 3.72386 12.4929 4 12.4929H10.864C11.1401 12.4929 11.364 12.2691 11.364 11.9929V8.75C11.364 8.33579 11.6998 8 12.114 8C12.5282 8 12.864 8.33579 12.864 8.75V11.9929C12.864 13.0975 11.9686 13.9929 10.864 13.9929H4C2.89543 13.9929 2 13.0975 2 11.9929V5.12893C2 4.02436 2.89543 3.12893 4 3.12893H7.25Z" fill="currentColor"> </path> </svg> </a> object. The <code class="leafygreen-ui-1l06pbn"> Publisher </code> inserts the document into a collection when subscribers request data. </p> </div> </div> </div> <div> <div aria-labelledby="_g32j9d7gd" class="leafygreen-ui-38lglc" id="_erwjg70wm" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://mongodb.github.io/mongo-java-driver/4.11/apidocs/mongodb-driver-sync/com/mongodb/client/MongoCollection.html#insertOne(TDocument)" rel="noopener noreferrer"> <span> com.mongodb.client.MongoCollection.insertOne </span> <svg alt="" aria-hidden="true" class="leafygreen-ui-1ie5kuq" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M13.823 2.4491C13.8201 2.30008 13.6999 2.17994 13.5509 2.17704L9.5062 2.09836C9.25654 2.09351 9.12821 2.39519 9.30482 2.5718L10.3856 3.65257L7.93433 6.10383C7.87964 6.15852 7.83047 6.21665 7.78683 6.27752L5.99909 8.06525C5.46457 8.59977 5.46457 9.4664 5.99909 10.0009C6.53361 10.5354 7.40023 10.5354 7.93475 10.0009L9.72249 8.21317C9.78336 8.16953 9.84148 8.12037 9.89618 8.06567L12.3474 5.61441L13.4282 6.69518C13.6048 6.87179 13.9065 6.74347 13.9016 6.4938L13.823 2.4491Z" fill="currentColor"> </path> <path d="M7.25 3.12893C7.66421 3.12893 8 3.46472 8 3.87893C8 4.29315 7.66421 4.62893 7.25 4.62893H4C3.72386 4.62893 3.5 4.85279 3.5 5.12893V11.9929C3.5 12.2691 3.72386 12.4929 4 12.4929H10.864C11.1401 12.4929 11.364 12.2691 11.364 11.9929V8.75C11.364 8.33579 11.6998 8 12.114 8C12.5282 8 12.864 8.33579 12.864 8.75V11.9929C12.864 13.0975 11.9686 13.9929 10.864 13.9929H4C2.89543 13.9929 2 13.0975 2 11.9929V5.12893C2 4.02436 2.89543 3.12893 4 3.12893H7.25Z" fill="currentColor"> </path> </svg> </a> returns an instance of <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://mongodb.github.io/mongo-java-driver/4.11/apidocs/mongodb-driver-core/com/mongodb/client/result/InsertOneResult.html" rel="noopener noreferrer"> <span> InsertOneResult </span> <svg alt="" aria-hidden="true" class="leafygreen-ui-1ie5kuq" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M13.823 2.4491C13.8201 2.30008 13.6999 2.17994 13.5509 2.17704L9.5062 2.09836C9.25654 2.09351 9.12821 2.39519 9.30482 2.5718L10.3856 3.65257L7.93433 6.10383C7.87964 6.15852 7.83047 6.21665 7.78683 6.27752L5.99909 8.06525C5.46457 8.59977 5.46457 9.4664 5.99909 10.0009C6.53361 10.5354 7.40023 10.5354 7.93475 10.0009L9.72249 8.21317C9.78336 8.16953 9.84148 8.12037 9.89618 8.06567L12.3474 5.61441L13.4282 6.69518C13.6048 6.87179 13.9065 6.74347 13.9016 6.4938L13.823 2.4491Z" fill="currentColor"> </path> <path d="M7.25 3.12893C7.66421 3.12893 8 3.46472 8 3.87893C8 4.29315 7.66421 4.62893 7.25 4.62893H4C3.72386 4.62893 3.5 4.85279 3.5 5.12893V11.9929C3.5 12.2691 3.72386 12.4929 4 12.4929H10.864C11.1401 12.4929 11.364 12.2691 11.364 11.9929V8.75C11.364 8.33579 11.6998 8 12.114 8C12.5282 8 12.864 8.33579 12.864 8.75V11.9929C12.864 13.0975 11.9686 13.9929 10.864 13.9929H4C2.89543 13.9929 2 13.0975 2 11.9929V5.12893C2 4.02436 2.89543 3.12893 4 3.12893H7.25Z" fill="currentColor"> </path> </svg> </a> . You can access the <code class="leafygreen-ui-1l06pbn"> _id </code> field of the inserted document by calling the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://mongodb.github.io/mongo-java-driver/4.11/apidocs/mongodb-driver-core/com/mongodb/client/result/InsertOneResult.html#getInsertedId()" rel="noopener noreferrer"> <span> getInsertedId() </span> <svg alt="" aria-hidden="true" class="leafygreen-ui-1ie5kuq" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M13.823 2.4491C13.8201 2.30008 13.6999 2.17994 13.5509 2.17704L9.5062 2.09836C9.25654 2.09351 9.12821 2.39519 9.30482 2.5718L10.3856 3.65257L7.93433 6.10383C7.87964 6.15852 7.83047 6.21665 7.78683 6.27752L5.99909 8.06525C5.46457 8.59977 5.46457 9.4664 5.99909 10.0009C6.53361 10.5354 7.40023 10.5354 7.93475 10.0009L9.72249 8.21317C9.78336 8.16953 9.84148 8.12037 9.89618 8.06567L12.3474 5.61441L13.4282 6.69518C13.6048 6.87179 13.9065 6.74347 13.9016 6.4938L13.823 2.4491Z" fill="currentColor"> </path> <path d="M7.25 3.12893C7.66421 3.12893 8 3.46472 8 3.87893C8 4.29315 7.66421 4.62893 7.25 4.62893H4C3.72386 4.62893 3.5 4.85279 3.5 5.12893V11.9929C3.5 12.2691 3.72386 12.4929 4 12.4929H10.864C11.1401 12.4929 11.364 12.2691 11.364 11.9929V8.75C11.364 8.33579 11.6998 8 12.114 8C12.5282 8 12.864 8.33579 12.864 8.75V11.9929C12.864 13.0975 11.9686 13.9929 10.864 13.9929H4C2.89543 13.9929 2 13.0975 2 11.9929V5.12893C2 4.02436 2.89543 3.12893 4 3.12893H7.25Z" fill="currentColor"> </path> </svg> </a> method on the result. </p> </div> </div> </div> <div> <div aria-labelledby="_a3ljt63og" class="leafygreen-ui-38lglc" id="_jlgom00ma" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://mongodb.github.io/mongo-java-driver/4.11/apidocs/mongodb-driver-kotlin-coroutine/mongodb-driver-kotlin-coroutine/com.mongodb.kotlin.client.coroutine/-mongo-collection/insert-one.html" rel="noopener noreferrer"> <span> MongoCollection.insertOne </span> <svg alt="" aria-hidden="true" class="leafygreen-ui-1ie5kuq" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M13.823 2.4491C13.8201 2.30008 13.6999 2.17994 13.5509 2.17704L9.5062 2.09836C9.25654 2.09351 9.12821 2.39519 9.30482 2.5718L10.3856 3.65257L7.93433 6.10383C7.87964 6.15852 7.83047 6.21665 7.78683 6.27752L5.99909 8.06525C5.46457 8.59977 5.46457 9.4664 5.99909 10.0009C6.53361 10.5354 7.40023 10.5354 7.93475 10.0009L9.72249 8.21317C9.78336 8.16953 9.84148 8.12037 9.89618 8.06567L12.3474 5.61441L13.4282 6.69518C13.6048 6.87179 13.9065 6.74347 13.9016 6.4938L13.823 2.4491Z" fill="currentColor"> </path> <path d="M7.25 3.12893C7.66421 3.12893 8 3.46472 8 3.87893C8 4.29315 7.66421 4.62893 7.25 4.62893H4C3.72386 4.62893 3.5 4.85279 3.5 5.12893V11.9929C3.5 12.2691 3.72386 12.4929 4 12.4929H10.864C11.1401 12.4929 11.364 12.2691 11.364 11.9929V8.75C11.364 8.33579 11.6998 8 12.114 8C12.5282 8 12.864 8.33579 12.864 8.75V11.9929C12.864 13.0975 11.9686 13.9929 10.864 13.9929H4C2.89543 13.9929 2 13.0975 2 11.9929V5.12893C2 4.02436 2.89543 3.12893 4 3.12893H7.25Z" fill="currentColor"> </path> </svg> </a> returns an instance of <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://mongodb.github.io/mongo-java-driver/4.11/apidocs/mongodb-driver-core/com/mongodb/client/result/InsertOneResult.html" rel="noopener noreferrer"> <span> InsertOneResult </span> <svg alt="" aria-hidden="true" class="leafygreen-ui-1ie5kuq" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M13.823 2.4491C13.8201 2.30008 13.6999 2.17994 13.5509 2.17704L9.5062 2.09836C9.25654 2.09351 9.12821 2.39519 9.30482 2.5718L10.3856 3.65257L7.93433 6.10383C7.87964 6.15852 7.83047 6.21665 7.78683 6.27752L5.99909 8.06525C5.46457 8.59977 5.46457 9.4664 5.99909 10.0009C6.53361 10.5354 7.40023 10.5354 7.93475 10.0009L9.72249 8.21317C9.78336 8.16953 9.84148 8.12037 9.89618 8.06567L12.3474 5.61441L13.4282 6.69518C13.6048 6.87179 13.9065 6.74347 13.9016 6.4938L13.823 2.4491Z" fill="currentColor"> </path> <path d="M7.25 3.12893C7.66421 3.12893 8 3.46472 8 3.87893C8 4.29315 7.66421 4.62893 7.25 4.62893H4C3.72386 4.62893 3.5 4.85279 3.5 5.12893V11.9929C3.5 12.2691 3.72386 12.4929 4 12.4929H10.864C11.1401 12.4929 11.364 12.2691 11.364 11.9929V8.75C11.364 8.33579 11.6998 8 12.114 8C12.5282 8 12.864 8.33579 12.864 8.75V11.9929C12.864 13.0975 11.9686 13.9929 10.864 13.9929H4C2.89543 13.9929 2 13.0975 2 11.9929V5.12893C2 4.02436 2.89543 3.12893 4 3.12893H7.25Z" fill="currentColor"> </path> </svg> </a> . You can access the <code class="leafygreen-ui-1l06pbn"> _id </code> field of the inserted document by accessing the <code class="leafygreen-ui-1l06pbn"> insertedId </code> field of the result. </p> </div> </div> </div> <div> <div aria-labelledby="_g860cjyfv" class="leafygreen-ui-38lglc" id="_xkmzb789x" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://motor.readthedocs.io/en/stable/api-asyncio/asyncio_motor_collection.html#motor.motor_asyncio.AsyncIOMotorCollection.insert_one" rel="noopener noreferrer"> <span> <code class="leafygreen-ui-1l06pbn"> insert_one </code> </span> <svg alt="" aria-hidden="true" class="leafygreen-ui-1ie5kuq" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M13.823 2.4491C13.8201 2.30008 13.6999 2.17994 13.5509 2.17704L9.5062 2.09836C9.25654 2.09351 9.12821 2.39519 9.30482 2.5718L10.3856 3.65257L7.93433 6.10383C7.87964 6.15852 7.83047 6.21665 7.78683 6.27752L5.99909 8.06525C5.46457 8.59977 5.46457 9.4664 5.99909 10.0009C6.53361 10.5354 7.40023 10.5354 7.93475 10.0009L9.72249 8.21317C9.78336 8.16953 9.84148 8.12037 9.89618 8.06567L12.3474 5.61441L13.4282 6.69518C13.6048 6.87179 13.9065 6.74347 13.9016 6.4938L13.823 2.4491Z" fill="currentColor"> </path> <path d="M7.25 3.12893C7.66421 3.12893 8 3.46472 8 3.87893C8 4.29315 7.66421 4.62893 7.25 4.62893H4C3.72386 4.62893 3.5 4.85279 3.5 5.12893V11.9929C3.5 12.2691 3.72386 12.4929 4 12.4929H10.864C11.1401 12.4929 11.364 12.2691 11.364 11.9929V8.75C11.364 8.33579 11.6998 8 12.114 8C12.5282 8 12.864 8.33579 12.864 8.75V11.9929C12.864 13.0975 11.9686 13.9929 10.864 13.9929H4C2.89543 13.9929 2 13.0975 2 11.9929V5.12893C2 4.02436 2.89543 3.12893 4 3.12893H7.25Z" fill="currentColor"> </path> </svg> </a> returns an instance of <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://pymongo.readthedocs.io/en/stable/api/pymongo/results.html#pymongo.results.InsertOneResult" rel="noopener noreferrer"> <span> <code class="leafygreen-ui-1l06pbn"> pymongo.results.InsertOneResult </code> </span> <svg alt="" aria-hidden="true" class="leafygreen-ui-1ie5kuq" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M13.823 2.4491C13.8201 2.30008 13.6999 2.17994 13.5509 2.17704L9.5062 2.09836C9.25654 2.09351 9.12821 2.39519 9.30482 2.5718L10.3856 3.65257L7.93433 6.10383C7.87964 6.15852 7.83047 6.21665 7.78683 6.27752L5.99909 8.06525C5.46457 8.59977 5.46457 9.4664 5.99909 10.0009C6.53361 10.5354 7.40023 10.5354 7.93475 10.0009L9.72249 8.21317C9.78336 8.16953 9.84148 8.12037 9.89618 8.06567L12.3474 5.61441L13.4282 6.69518C13.6048 6.87179 13.9065 6.74347 13.9016 6.4938L13.823 2.4491Z" fill="currentColor"> </path> <path d="M7.25 3.12893C7.66421 3.12893 8 3.46472 8 3.87893C8 4.29315 7.66421 4.62893 7.25 4.62893H4C3.72386 4.62893 3.5 4.85279 3.5 5.12893V11.9929C3.5 12.2691 3.72386 12.4929 4 12.4929H10.864C11.1401 12.4929 11.364 12.2691 11.364 11.9929V8.75C11.364 8.33579 11.6998 8 12.114 8C12.5282 8 12.864 8.33579 12.864 8.75V11.9929C12.864 13.0975 11.9686 13.9929 10.864 13.9929H4C2.89543 13.9929 2 13.0975 2 11.9929V5.12893C2 4.02436 2.89543 3.12893 4 3.12893H7.25Z" fill="currentColor"> </path> </svg> </a> whose <code class="leafygreen-ui-1l06pbn"> inserted_id </code> field contains the <code class="leafygreen-ui-1l06pbn"> _id </code> of the newly inserted document. </p> </div> </div> </div> <div> <div aria-labelledby="_k1o2mnc2p" class="" id="_2thhflt39" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="http://mongodb.github.io/node-mongodb-native/3.6/api/Collection.html#insertOne" rel="noopener noreferrer"> <span> insertOne() </span> <svg alt="" aria-hidden="true" class="leafygreen-ui-1ie5kuq" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M13.823 2.4491C13.8201 2.30008 13.6999 2.17994 13.5509 2.17704L9.5062 2.09836C9.25654 2.09351 9.12821 2.39519 9.30482 2.5718L10.3856 3.65257L7.93433 6.10383C7.87964 6.15852 7.83047 6.21665 7.78683 6.27752L5.99909 8.06525C5.46457 8.59977 5.46457 9.4664 5.99909 10.0009C6.53361 10.5354 7.40023 10.5354 7.93475 10.0009L9.72249 8.21317C9.78336 8.16953 9.84148 8.12037 9.89618 8.06567L12.3474 5.61441L13.4282 6.69518C13.6048 6.87179 13.9065 6.74347 13.9016 6.4938L13.823 2.4491Z" fill="currentColor"> </path> <path d="M7.25 3.12893C7.66421 3.12893 8 3.46472 8 3.87893C8 4.29315 7.66421 4.62893 7.25 4.62893H4C3.72386 4.62893 3.5 4.85279 3.5 5.12893V11.9929C3.5 12.2691 3.72386 12.4929 4 12.4929H10.864C11.1401 12.4929 11.364 12.2691 11.364 11.9929V8.75C11.364 8.33579 11.6998 8 12.114 8C12.5282 8 12.864 8.33579 12.864 8.75V11.9929C12.864 13.0975 11.9686 13.9929 10.864 13.9929H4C2.89543 13.9929 2 13.0975 2 11.9929V5.12893C2 4.02436 2.89543 3.12893 4 3.12893H7.25Z" fill="currentColor"> </path> </svg> </a> returns a promise that provides a <code class="leafygreen-ui-1l06pbn"> result </code> . The <code class="leafygreen-ui-1l06pbn"> result.insertedId </code> promise contains the <code class="leafygreen-ui-1l06pbn"> _id </code> of the newly inserted document. </p> </div> </div> </div> <div> <div aria-labelledby="_16dwy6mvr" class="leafygreen-ui-38lglc" id="_ezbyo4d4u" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <p class="leafygreen-ui-1kp3ins"> Upon successful insert, the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://metacpan.org/pod/MongoDB::Collection#insert_one" rel="noopener noreferrer"> <span> insert_one() </span> <svg alt="" aria-hidden="true" class="leafygreen-ui-1ie5kuq" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M13.823 2.4491C13.8201 2.30008 13.6999 2.17994 13.5509 2.17704L9.5062 2.09836C9.25654 2.09351 9.12821 2.39519 9.30482 2.5718L10.3856 3.65257L7.93433 6.10383C7.87964 6.15852 7.83047 6.21665 7.78683 6.27752L5.99909 8.06525C5.46457 8.59977 5.46457 9.4664 5.99909 10.0009C6.53361 10.5354 7.40023 10.5354 7.93475 10.0009L9.72249 8.21317C9.78336 8.16953 9.84148 8.12037 9.89618 8.06567L12.3474 5.61441L13.4282 6.69518C13.6048 6.87179 13.9065 6.74347 13.9016 6.4938L13.823 2.4491Z" fill="currentColor"> </path> <path d="M7.25 3.12893C7.66421 3.12893 8 3.46472 8 3.87893C8 4.29315 7.66421 4.62893 7.25 4.62893H4C3.72386 4.62893 3.5 4.85279 3.5 5.12893V11.9929C3.5 12.2691 3.72386 12.4929 4 12.4929H10.864C11.1401 12.4929 11.364 12.2691 11.364 11.9929V8.75C11.364 8.33579 11.6998 8 12.114 8C12.5282 8 12.864 8.33579 12.864 8.75V11.9929C12.864 13.0975 11.9686 13.9929 10.864 13.9929H4C2.89543 13.9929 2 13.0975 2 11.9929V5.12893C2 4.02436 2.89543 3.12893 4 3.12893H7.25Z" fill="currentColor"> </path> </svg> </a> method returns an instance of <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://metacpan.org/pod/MongoDB::InsertOneResult" rel="noopener noreferrer"> <span> MongoDB::InsertOneResult </span> <svg alt="" aria-hidden="true" class="leafygreen-ui-1ie5kuq" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M13.823 2.4491C13.8201 2.30008 13.6999 2.17994 13.5509 2.17704L9.5062 2.09836C9.25654 2.09351 9.12821 2.39519 9.30482 2.5718L10.3856 3.65257L7.93433 6.10383C7.87964 6.15852 7.83047 6.21665 7.78683 6.27752L5.99909 8.06525C5.46457 8.59977 5.46457 9.4664 5.99909 10.0009C6.53361 10.5354 7.40023 10.5354 7.93475 10.0009L9.72249 8.21317C9.78336 8.16953 9.84148 8.12037 9.89618 8.06567L12.3474 5.61441L13.4282 6.69518C13.6048 6.87179 13.9065 6.74347 13.9016 6.4938L13.823 2.4491Z" fill="currentColor"> </path> <path d="M7.25 3.12893C7.66421 3.12893 8 3.46472 8 3.87893C8 4.29315 7.66421 4.62893 7.25 4.62893H4C3.72386 4.62893 3.5 4.85279 3.5 5.12893V11.9929C3.5 12.2691 3.72386 12.4929 4 12.4929H10.864C11.1401 12.4929 11.364 12.2691 11.364 11.9929V8.75C11.364 8.33579 11.6998 8 12.114 8C12.5282 8 12.864 8.33579 12.864 8.75V11.9929C12.864 13.0975 11.9686 13.9929 10.864 13.9929H4C2.89543 13.9929 2 13.0975 2 11.9929V5.12893C2 4.02436 2.89543 3.12893 4 3.12893H7.25Z" fill="currentColor"> </path> </svg> </a> whose <code class="leafygreen-ui-1l06pbn"> inserted_id </code> attribute contains the <code class="leafygreen-ui-1l06pbn"> _id </code> of the newly inserted document. </p> </div> </div> </div> <div> <div aria-labelledby="_qdujo2abb" class="leafygreen-ui-38lglc" id="_3v7ndc6fb" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <p class="leafygreen-ui-1kp3ins"> Upon successful insert, the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/php-library/upcoming/reference/method/MongoDBCollection-insertOne/#mongodb-phpmethod-phpmethod.MongoDB-Collection--insertOne--" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> insertOne() </code> </span> </a> method returns an instance of <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/php-library/upcoming/reference/class/MongoDBInsertOneResult/#mongodb-phpclass-phpclass.MongoDB-InsertOneResult" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> MongoDB\\InsertOneResult </code> </span> </a> whose <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/php-library/upcoming/reference/method/MongoDBInsertOneResult-getInsertedId/#mongodb-phpmethod-phpmethod.MongoDB-InsertOneResult--getInsertedId--" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> getInsertedId() </code> </span> </a> method returns the <code class="leafygreen-ui-1l06pbn"> _id </code> of the newly inserted document. </p> </div> </div> </div> <div> <div aria-labelledby="_bjfv1cxlx" class="leafygreen-ui-38lglc" id="_mrgxeljsi" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://pymongo.readthedocs.io/en/stable/api/pymongo/collection.html#pymongo.collection.Collection.insert_one" rel="noopener noreferrer"> <span> <code class="leafygreen-ui-1l06pbn"> insert_one </code> </span> <svg alt="" aria-hidden="true" class="leafygreen-ui-1ie5kuq" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M13.823 2.4491C13.8201 2.30008 13.6999 2.17994 13.5509 2.17704L9.5062 2.09836C9.25654 2.09351 9.12821 2.39519 9.30482 2.5718L10.3856 3.65257L7.93433 6.10383C7.87964 6.15852 7.83047 6.21665 7.78683 6.27752L5.99909 8.06525C5.46457 8.59977 5.46457 9.4664 5.99909 10.0009C6.53361 10.5354 7.40023 10.5354 7.93475 10.0009L9.72249 8.21317C9.78336 8.16953 9.84148 8.12037 9.89618 8.06567L12.3474 5.61441L13.4282 6.69518C13.6048 6.87179 13.9065 6.74347 13.9016 6.4938L13.823 2.4491Z" fill="currentColor"> </path> <path d="M7.25 3.12893C7.66421 3.12893 8 3.46472 8 3.87893C8 4.29315 7.66421 4.62893 7.25 4.62893H4C3.72386 4.62893 3.5 4.85279 3.5 5.12893V11.9929C3.5 12.2691 3.72386 12.4929 4 12.4929H10.864C11.1401 12.4929 11.364 12.2691 11.364 11.9929V8.75C11.364 8.33579 11.6998 8 12.114 8C12.5282 8 12.864 8.33579 12.864 8.75V11.9929C12.864 13.0975 11.9686 13.9929 10.864 13.9929H4C2.89543 13.9929 2 13.0975 2 11.9929V5.12893C2 4.02436 2.89543 3.12893 4 3.12893H7.25Z" fill="currentColor"> </path> </svg> </a> returns an instance of <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://pymongo.readthedocs.io/en/stable/api/pymongo/results.html#pymongo.results.InsertOneResult" rel="noopener noreferrer"> <span> <code class="leafygreen-ui-1l06pbn"> pymongo.results.InsertOneResult </code> </span> <svg alt="" aria-hidden="true" class="leafygreen-ui-1ie5kuq" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M13.823 2.4491C13.8201 2.30008 13.6999 2.17994 13.5509 2.17704L9.5062 2.09836C9.25654 2.09351 9.12821 2.39519 9.30482 2.5718L10.3856 3.65257L7.93433 6.10383C7.87964 6.15852 7.83047 6.21665 7.78683 6.27752L5.99909 8.06525C5.46457 8.59977 5.46457 9.4664 5.99909 10.0009C6.53361 10.5354 7.40023 10.5354 7.93475 10.0009L9.72249 8.21317C9.78336 8.16953 9.84148 8.12037 9.89618 8.06567L12.3474 5.61441L13.4282 6.69518C13.6048 6.87179 13.9065 6.74347 13.9016 6.4938L13.823 2.4491Z" fill="currentColor"> </path> <path d="M7.25 3.12893C7.66421 3.12893 8 3.46472 8 3.87893C8 4.29315 7.66421 4.62893 7.25 4.62893H4C3.72386 4.62893 3.5 4.85279 3.5 5.12893V11.9929C3.5 12.2691 3.72386 12.4929 4 12.4929H10.864C11.1401 12.4929 11.364 12.2691 11.364 11.9929V8.75C11.364 8.33579 11.6998 8 12.114 8C12.5282 8 12.864 8.33579 12.864 8.75V11.9929C12.864 13.0975 11.9686 13.9929 10.864 13.9929H4C2.89543 13.9929 2 13.0975 2 11.9929V5.12893C2 4.02436 2.89543 3.12893 4 3.12893H7.25Z" fill="currentColor"> </path> </svg> </a> whose <code class="leafygreen-ui-1l06pbn"> inserted_id </code> field contains the <code class="leafygreen-ui-1l06pbn"> _id </code> of the newly inserted document. </p> </div> </div> </div> <div> <div aria-labelledby="_qb1mdxopm" class="leafygreen-ui-38lglc" id="_kfnkrfjw1" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <p class="leafygreen-ui-1kp3ins"> Upon successful insert, the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="http://api.mongodb.com/ruby/current/Mongo/Collection.html#insert_one-instance_method" target="_self"> <span> insert_one() </span> </a> method returns an instance of <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="http://api.mongodb.com/ruby/current/Mongo/Operation/Result.html" target="_self"> <span> Mongo::Operation::Result </span> </a> , whose <code class="leafygreen-ui-1l06pbn"> inserted_id </code> attribute contains the <code class="leafygreen-ui-1l06pbn"> _id </code> of the newly inserted document. </p> </div> </div> </div> <div> <div aria-labelledby="_qjc0pefea" class="leafygreen-ui-38lglc" id="_hon1gdx09" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <p class="leafygreen-ui-1kp3ins"> Upon successful insert, the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="http://mongodb.github.io/mongo-scala-driver/2.9/scaladoc/org/mongodb/scala/MongoCollection.html#MongoCollection.html#insertOne(document:TResult,options:org.mongodb.scala.model.InsertOneOptions):org.mongodb.scala.SingleObservable[org.mongodb.scala.Completed]" rel="noopener noreferrer"> <span> collection.insertOne() </span> <svg alt="" aria-hidden="true" class="leafygreen-ui-1ie5kuq" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M13.823 2.4491C13.8201 2.30008 13.6999 2.17994 13.5509 2.17704L9.5062 2.09836C9.25654 2.09351 9.12821 2.39519 9.30482 2.5718L10.3856 3.65257L7.93433 6.10383C7.87964 6.15852 7.83047 6.21665 7.78683 6.27752L5.99909 8.06525C5.46457 8.59977 5.46457 9.4664 5.99909 10.0009C6.53361 10.5354 7.40023 10.5354 7.93475 10.0009L9.72249 8.21317C9.78336 8.16953 9.84148 8.12037 9.89618 8.06567L12.3474 5.61441L13.4282 6.69518C13.6048 6.87179 13.9065 6.74347 13.9016 6.4938L13.823 2.4491Z" fill="currentColor"> </path> <path d="M7.25 3.12893C7.66421 3.12893 8 3.46472 8 3.87893C8 4.29315 7.66421 4.62893 7.25 4.62893H4C3.72386 4.62893 3.5 4.85279 3.5 5.12893V11.9929C3.5 12.2691 3.72386 12.4929 4 12.4929H10.864C11.1401 12.4929 11.364 12.2691 11.364 11.9929V8.75C11.364 8.33579 11.6998 8 12.114 8C12.5282 8 12.864 8.33579 12.864 8.75V11.9929C12.864 13.0975 11.9686 13.9929 10.864 13.9929H4C2.89543 13.9929 2 13.0975 2 11.9929V5.12893C2 4.02436 2.89543 3.12893 4 3.12893H7.25Z" fill="currentColor"> </path> </svg> </a> method returns an instance of <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="http://mongodb.github.io/mongo-scala-driver/2.9/scaladoc/org/mongodb/scala/MongoCollection.html#InsertOneResult" rel="noopener noreferrer"> <span> collection.insertOne().results(); </span> <svg alt="" aria-hidden="true" class="leafygreen-ui-1ie5kuq" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M13.823 2.4491C13.8201 2.30008 13.6999 2.17994 13.5509 2.17704L9.5062 2.09836C9.25654 2.09351 9.12821 2.39519 9.30482 2.5718L10.3856 3.65257L7.93433 6.10383C7.87964 6.15852 7.83047 6.21665 7.78683 6.27752L5.99909 8.06525C5.46457 8.59977 5.46457 9.4664 5.99909 10.0009C6.53361 10.5354 7.40023 10.5354 7.93475 10.0009L9.72249 8.21317C9.78336 8.16953 9.84148 8.12037 9.89618 8.06567L12.3474 5.61441L13.4282 6.69518C13.6048 6.87179 13.9065 6.74347 13.9016 6.4938L13.823 2.4491Z" fill="currentColor"> </path> <path d="M7.25 3.12893C7.66421 3.12893 8 3.46472 8 3.87893C8 4.29315 7.66421 4.62893 7.25 4.62893H4C3.72386 4.62893 3.5 4.85279 3.5 5.12893V11.9929C3.5 12.2691 3.72386 12.4929 4 12.4929H10.864C11.1401 12.4929 11.364 12.2691 11.364 11.9929V8.75C11.364 8.33579 11.6998 8 12.114 8C12.5282 8 12.864 8.33579 12.864 8.75V11.9929C12.864 13.0975 11.9686 13.9929 10.864 13.9929H4C2.89543 13.9929 2 13.0975 2 11.9929V5.12893C2 4.02436 2.89543 3.12893 4 3.12893H7.25Z" fill="currentColor"> </path> </svg> </a> whose <code class="leafygreen-ui-1l06pbn"> inserted_id </code> attribute contains the <code class="leafygreen-ui-1l06pbn"> _id </code> of the newly inserted document. </p> </div> </div> </div> </div> </div> <p class="leafygreen-ui-1kp3ins"> To retrieve the document that you just inserted, <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/document/#std-label-document-query-filter"> query the collection <!-- --> : </a> </p> <div aria-hidden="true"> </div> <div class="leafygreen-ui-f2qztv" data-lgid="lg-tabs"> <div class="leafygreen-ui-jp7pox" id="tabs-13"> <div aria-label="Tabs to describe usage of drivers" aria-orientation="horizontal" class="leafygreen-ui-m8p1vb lg-ui-tab-list-0000" data-lgid="lg-tabs-tab_list" role="tablist"> <button aria-controls="_hal3aypu2" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_lu1726oaf" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> MongoDB Shell </div> </button> <button aria-controls="_yya1okatk" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_2q0q5tmgv" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Compass </div> </button> <button aria-controls="_e1fue4lwp" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_t8nptc92b" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> C </div> </button> <button aria-controls="_ujeqhmpcr" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_ntiy5utr3" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> C# </div> </button> <button aria-controls="_5utsvz24i" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_p7f05wchm" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Go </div> </button> <button aria-controls="_zlizutgb8" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_siu2imag1" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Java (Async) </div> </button> <button aria-controls="_z98tizq8n" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_n3r3daxah" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Java (Sync) </div> </button> <button aria-controls="_b6o3g6kok" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_qbd6cwztv" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Kotlin (Coroutine) </div> </button> <button aria-controls="_vxiajanko" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_pkh3m8qey" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Motor </div> </button> <button aria-controls="_7l81hxo1v" aria-selected="true" class="leafygreen-ui-1l773z1" data-text="" id="_ecmd1i90f" name="" role="tab" tabindex="0"> <div class="leafygreen-ui-1nxuzmg"> Node.js </div> </button> <button aria-controls="_r8bu6xrqp" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_bng0tcz5a" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Perl </div> </button> <button aria-controls="_7w62xr2jv" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_8swd8831u" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> PHP </div> </button> <button aria-controls="_2hwy7oasa" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_cmfvb6w9x" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Python </div> </button> <button aria-controls="_w0gny1rg5" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_wltxq1gfx" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Ruby </div> </button> <button aria-controls="_dmnuxhi5m" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_p7zsunrr5" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Scala </div> </button> </div> <div class="leafygreen-ui-ov1ktg"> <div class="leafygreen-ui-1sg2lsz"> </div> </div> </div> <div class="lg-ui-tab-panels-0000" data-lgid="lg-tabs-tab_panels"> <div> <div aria-labelledby="_yyv7oo29d" class="leafygreen-ui-38lglc" id="_2ohwb3u9f" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.inventory.find( { item: \"canvas\" } )","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <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">inventory</span>.<span class="lg-highlight-title lg-highlight-function">find</span>( <!-- -->{ <span class="lg-highlight-attr">item</span>: <span class="lg-highlight-string">"canvas"</span> } )</td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-71-menu" aria-describedby="select-71-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-72" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:r7v:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":r7v:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r7v:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r7v:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_kaufmfals" class="leafygreen-ui-38lglc" id="_sbt8dbxty" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <div class="figure css-5vkxs0" style="width:auto"> <div class="gatsby-image-wrapper gatsby-image-wrapper-constrained leafygreen-ui-12xaq6r" data-gatsby-image-wrapper=""> <div style="max-width:751px;display:block"> <img alt="" aria-hidden="true" role="presentation" src="data:image/svg+xml;charset=utf-8,%3Csvg%20height='286'%20width='751'%20xmlns='http://www.w3.org/2000/svg'%20version='1.1'%3E%3C/svg%3E" style="max-width:100%;display:block;position:static"/> </div> <div aria-hidden="true" data-placeholder-image="" style="opacity:1;transition:opacity 500ms linear"> </div> <img alt="Query for matching documents in a collection" data-main-image="" decoding="async" height="286" loading="lazy" sizes="(min-width: 751px) 751px, 100vw" src="/docs/manual/static/8c23eb13f3df051f8ff03c9f3dce4a49/5fab3/compass-query-collection.webp" srcset="/docs/manual/static/8c23eb13f3df051f8ff03c9f3dce4a49/9cbba/compass-query-collection.webp 188w,/docs/manual/static/8c23eb13f3df051f8ff03c9f3dce4a49/a7862/compass-query-collection.webp 376w,/docs/manual/static/8c23eb13f3df051f8ff03c9f3dce4a49/5fab3/compass-query-collection.webp 751w" style="--border-color:#C1C7C6;opacity:0" width="751"/> <noscript> <img alt="Query for matching documents in a collection" data-gatsby-image-ssr="" data-main-image="" decoding="async" height="286" loading="lazy" sizes="(min-width: 751px) 751px, 100vw" src="/docs/manual/static/8c23eb13f3df051f8ff03c9f3dce4a49/5fab3/compass-query-collection.webp" srcset="/docs/manual/static/8c23eb13f3df051f8ff03c9f3dce4a49/9cbba/compass-query-collection.webp 188w,/docs/manual/static/8c23eb13f3df051f8ff03c9f3dce4a49/a7862/compass-query-collection.webp 376w,/docs/manual/static/8c23eb13f3df051f8ff03c9f3dce4a49/5fab3/compass-query-collection.webp 751w" style="--border-color:#C1C7C6;opacity:0" width="751"/> </noscript> <script type="module"> const t="undefined"!=typeof HTMLImageElement&&"loading"in HTMLImageElement.prototype;if(t){const t=document.querySelectorAll("img[data-main-image]");for(let e of t){e.dataset.src&&(e.setAttribute("src",e.dataset.src),e.removeAttribute("data-src")),e.dataset.srcset&&(e.setAttribute("srcset",e.dataset.srcset),e.removeAttribute("data-srcset"));const t=e.parentNode.querySelectorAll("source[data-srcset]");for(let e of t)e.setAttribute("srcset",e.dataset.srcset),e.removeAttribute("data-srcset");e.complete&&(e.style.opacity=1,e.parentNode.parentNode.querySelector("[data-placeholder-image]").style.opacity=0)}} </script> </div> </div> <p class="leafygreen-ui-1kp3ins"> Specify a filter in the MongoDB Compass query bar and click <span class="guilabel css-h15tq0"> Find </span> to execute the query. </p> <p class="leafygreen-ui-1kp3ins"> The above filter specifies that MongoDB Compass only return documents where the <code class="leafygreen-ui-1l06pbn"> item </code> field is equal to <code class="leafygreen-ui-1l06pbn"> canvas </code> . </p> <p class="leafygreen-ui-1kp3ins"> For more information on the MongoDB Compass Query Bar, see the Compass <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/compass/current/query/filter/#std-label-compass-query-bar" target="_self"> <span> Query Bar </span> </a> documentation. </p> </div> </div> </div> <div> <div aria-labelledby="_p6cxtmusj" class="leafygreen-ui-38lglc" id="_pozc5nagc" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"mongoc_collection_t *collection;\nbson_t *filter;\nmongoc_cursor_t *cursor;\n\ncollection = mongoc_database_get_collection (db, \"inventory\");\nfilter = BCON_NEW (\"item\", BCON_UTF8 (\"canvas\"));\ncursor = mongoc_collection_find_with_opts (collection, filter, NULL, NULL);","programmingLanguage":"C"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <pre class="leafygreen-ui-11itue3" 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">mongoc_collection_t *collection;</td></tr><tr class=""><td class="leafygreen-ui-7razhx">bson_t *filter;</td></tr><tr class=""><td class="leafygreen-ui-7razhx">mongoc_cursor_t *cursor;</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><div class="leafygreen-ui-ihxujy"></div></td></tr><tr class=""><td class="leafygreen-ui-7razhx">collection <!-- -->= <!-- -->mongoc_database_get_collection (db<!-- -->, <span class="lg-highlight-string">"inventory"</span>);</td></tr><tr class=""><td class="leafygreen-ui-7razhx">filter <!-- -->= <!-- --><span class="lg-highlight-variable lg-highlight-constant">BCON_NEW</span> (<!-- --><!-- --><span class="lg-highlight-string">"item"</span>, <span class="lg-highlight-variable lg-highlight-constant">BCON_UTF8</span> <!-- -->(<span class="lg-highlight-string">"canvas"</span>));</td></tr><tr class=""><td class="leafygreen-ui-7razhx">cursor <!-- -->= <!-- -->mongoc_collection_find_with_opts (collection, filter<!-- -->, <span class="lg-highlight-variable lg-highlight-constant">NULL</span>, <span class="lg-highlight-variable lg-highlight-constant">NULL</span>);</td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-74-menu" aria-describedby="select-74-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-75" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:r80:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":r80:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r80:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r80:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_twe4l4pfx" class="leafygreen-ui-38lglc" id="_ucxmaxs3z" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"var filter = Builders&lt;bsondocument&gt;.Filter.Eq(\"item\", \"canvas\");\nvar result = collection.Find(filter).ToList();","programmingLanguage":"C#"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <pre class="leafygreen-ui-11itue3" 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"><span class="lg-highlight-keyword">var</span> filter = <span class="lg-highlight-title lg-highlight-class">Builders</span>&lt;<span class="lg-highlight-title lg-highlight-class">BsonDocument</span>&gt;.<span class="lg-highlight-property">Filter</span>.<span class="lg-highlight-title lg-highlight-class">Eq</span>(<span class="lg-highlight-string">"item"</span>, <span class="lg-highlight-string">"canvas"</span>);</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-keyword">var</span> result = collection.<span class="lg-highlight-title lg-highlight-class">Find</span>(filter).<span class="lg-highlight-title lg-highlight-class">ToList</span>();</td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-77-menu" aria-describedby="select-77-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-78" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:r81:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":r81:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r81:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r81:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_t6zsedfvk" class="leafygreen-ui-38lglc" id="_9u24d74oh" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"\ncursor, err := coll.Find(\n\tcontext.TODO(),\n\tbson.D{{\"item\", \"canvas\"}},\n)\n","programmingLanguage":"Golang"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <pre class="leafygreen-ui-11itue3" 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">cursor<!-- -->, <!-- -->err := coll.<span class="lg-highlight-title lg-highlight-class">Find</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> context.<span class="lg-highlight-title lg-highlight-function">TODO</span>(),</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> bson.<span class="lg-highlight-property">D</span>{{<span class="lg-highlight-string">"item"</span>, <span class="lg-highlight-string">"canvas"</span>}},</td></tr><tr class=""><td class="leafygreen-ui-7razhx">)</td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-80-menu" aria-describedby="select-80-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-81" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:r82:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":r82:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r82:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r82:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_grnqgxs5i" class="leafygreen-ui-38lglc" id="_1wzrdh38u" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"FindPublisher&lt;document&gt; findPublisher = collection.find(eq(\"item\", \"canvas\"));","programmingLanguage":"Java"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <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"><span class="lg-highlight-title lg-highlight-class">FindPublisher</span>&lt;<span class="lg-highlight-title lg-highlight-class">Document</span>&gt; findPublisher = collection.<span class="lg-highlight-title lg-highlight-function">find</span>(<span class="lg-highlight-title lg-highlight-function">eq</span>(<span class="lg-highlight-string">"item"</span>, <span class="lg-highlight-string">"canvas"</span>));</td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-83-menu" aria-describedby="select-83-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-84" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:r83:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":r83:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r83:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r83:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_iewa0qfa8" class="leafygreen-ui-38lglc" id="_vvfw6j2rl" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"FindIterable&lt;document&gt; findIterable = collection.find(eq(\"item\", \"canvas\"));","programmingLanguage":"Java"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <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"><span class="lg-highlight-title lg-highlight-class">FindIterable</span>&lt;<span class="lg-highlight-title lg-highlight-class">Document</span>&gt; findIterable = collection.<span class="lg-highlight-title lg-highlight-function">find</span>(<span class="lg-highlight-title lg-highlight-function">eq</span>(<span class="lg-highlight-string">"item"</span>, <span class="lg-highlight-string">"canvas"</span>));</td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-86-menu" aria-describedby="select-86-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-87" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:r84:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":r84:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r84:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r84:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_348z981f3" class="leafygreen-ui-38lglc" id="_zg0iln9nj" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"val flowInsertOne = collection\n .find(eq(\"item\", \"canvas\"))\n .firstOrNull()","programmingLanguage":"Kotlin"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <pre class="leafygreen-ui-11itue3" 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">val flowInsertOne = collection</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> .<span class="lg-highlight-title lg-highlight-function">find</span>(<span class="lg-highlight-title lg-highlight-function">eq</span>(<span class="lg-highlight-string">"item"</span>, <span class="lg-highlight-string">"canvas"</span>))</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> .<span class="lg-highlight-title lg-highlight-function">firstOrNull</span>()</td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-89-menu" aria-describedby="select-89-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-90" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:r85:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":r85:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r85:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r85:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_0myjvgc6p" class="leafygreen-ui-38lglc" id="_8tzku5x8f" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"cursor = db.inventory.find({\"item\": \"canvas\"})","programmingLanguage":"Python"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <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">cursor = db.<span class="lg-highlight-property">inventory</span>.<span class="lg-highlight-title lg-highlight-function">find</span>({<span class="lg-highlight-string">"item"</span>: <span class="lg-highlight-string">"canvas"</span>})</td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-92-menu" aria-describedby="select-92-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-93" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:r86:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":r86:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r86:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r86:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_ji1vbt5cr" class="" id="_f1xqhwt21" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"const cursor = db.collection('inventory').find({ item: 'canvas' });","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <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"><span class="lg-highlight-keyword">const</span> cursor <!-- -->= <!-- -->db.<span class="lg-highlight-title lg-highlight-function">collection</span>(<span class="lg-highlight-string">'inventory'</span>).<span class="lg-highlight-title lg-highlight-function">find</span>(<!-- -->{ <span class="lg-highlight-attr">item</span>: <span class="lg-highlight-string">'canvas'</span> })<!-- -->;</td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-95-menu" aria-describedby="select-95-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-96" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:r87:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":r87:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r87:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r87:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_kit1k5bga" class="leafygreen-ui-38lglc" id="_o8o4svm5o" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"$cursor = $db-&gt;coll(\"inventory\")-&gt;find( { item =&gt; \"canvas\" } );","programmingLanguage":"Perl"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <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">$cursor<!-- --> <!-- -->= <!-- -->$db<!-- -->-<!-- -->&gt;<!-- --><!-- --><span class="lg-highlight-title lg-highlight-function">coll</span>(<span class="lg-highlight-string">"inventory"</span>)<!-- -->-<!-- -->&gt;<!-- --><!-- --><span class="lg-highlight-title lg-highlight-function">find</span>( <!-- -->{ <span class="lg-highlight-params lg-highlight-function">item</span><!-- --><span class="lg-highlight-function"> =&gt;</span> <span class="lg-highlight-string">"canvas"</span> } );</td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-98-menu" aria-describedby="select-98-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-99" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:r88:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":r88:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r88:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r88:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_9qju3129a" class="leafygreen-ui-38lglc" id="_dm86pkloi" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"$cursor = $db-&gt;inventory-&gt;find(['item' =&gt; 'canvas']);","programmingLanguage":"PHP"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <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">$cursor = $db-&gt;inventory-<!-- -->&gt;<span class="lg-highlight-title lg-highlight-function">find</span>([<span class="lg-highlight-string">'item'</span> =&gt; <span class="lg-highlight-string">'canvas'</span>]);</td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-101-menu" aria-describedby="select-101-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-102" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:r89:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":r89:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r89:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r89:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_dktq9rvi3" class="leafygreen-ui-38lglc" id="_3ezw5kfrh" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"cursor = db.inventory.find({\"item\": \"canvas\"})","programmingLanguage":"Python"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <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">cursor = db.<span class="lg-highlight-property">inventory</span>.<span class="lg-highlight-title lg-highlight-function">find</span>({<span class="lg-highlight-string">"item"</span>: <span class="lg-highlight-string">"canvas"</span>})</td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-104-menu" aria-describedby="select-104-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-105" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:r8a:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":r8a:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r8a:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r8a:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_mw20g9glp" class="leafygreen-ui-38lglc" id="_frb7gmffo" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"client[:inventory].find(item: 'canvas')","programmingLanguage":"Ruby"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <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">client<!-- -->[<!-- -->:inventory].<span class="lg-highlight-title lg-highlight-function">find</span>(<span class="lg-highlight-attr">item</span>: <span class="lg-highlight-string">'canvas'</span>)</td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-107-menu" aria-describedby="select-107-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-108" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:r8b:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":r8b:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r8b:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r8b:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_lwkpcoz0g" class="leafygreen-ui-38lglc" id="_eh2zajoit" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"val observable = collection.find(equal(\"item\", \"canvas\"))","programmingLanguage":"Scala"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <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">val observable = collection.<span class="lg-highlight-title lg-highlight-function">find</span>(<span class="lg-highlight-title lg-highlight-function">equal</span>(<span class="lg-highlight-string">"item"</span>, <span class="lg-highlight-string">"canvas"</span>))</td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-110-menu" aria-describedby="select-110-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-111" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:r8c:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":r8c:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r8c:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r8c:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> </div> </div> <span class="leafygreen-ui-1qnjd6d" id="std-label-write-op-insertMany"> </span> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Insert Multiple Documents <a class="headerlink leafygreen-ui-1kepx47" href="#insert-multiple-documents" 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="insert-multiple-documents"> </div> </a> </h2> <div aria-hidden="true"> </div> <div class="leafygreen-ui-f2qztv" data-lgid="lg-tabs"> <div class="leafygreen-ui-jp7pox" id="tabs-15"> <div aria-label="Tabs to describe usage of drivers" aria-orientation="horizontal" class="leafygreen-ui-m8p1vb lg-ui-tab-list-0000" data-lgid="lg-tabs-tab_list" role="tablist"> <button aria-controls="_4ifuh534i" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_kxxac1pw6" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> MongoDB Shell </div> </button> <button aria-controls="_4bobmvvem" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_k6nqvkpo3" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Compass </div> </button> <button aria-controls="_rzr7gklot" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_tf1ckzvhq" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> C </div> </button> <button aria-controls="_2osjfydw2" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_wo90p9dyd" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> C# </div> </button> <button aria-controls="_tmbb9m303" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_xkg9ea93o" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Go </div> </button> <button aria-controls="_dxjd8mad4" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_qnugzbotr" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Java (Async) </div> </button> <button aria-controls="_uywcrj2wl" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_uvlgcw8c3" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Java (Sync) </div> </button> <button aria-controls="_wuefm79i5" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_79y0k4qy5" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Kotlin (Coroutine) </div> </button> <button aria-controls="_shum43o1y" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_zk21if2l1" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Motor </div> </button> <button aria-controls="_sfoebjvpl" aria-selected="true" class="leafygreen-ui-1l773z1" data-text="" id="_8ndkxsmpj" name="" role="tab" tabindex="0"> <div class="leafygreen-ui-1nxuzmg"> Node.js </div> </button> <button aria-controls="_dp7rod86x" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_6tvf6rwcu" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Perl </div> </button> <button aria-controls="_qw27syr5z" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_dril71adl" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> PHP </div> </button> <button aria-controls="_8b9t8foqe" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_8qcez25gi" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Python </div> </button> <button aria-controls="_42o03tv5j" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_hfzedaf4g" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Ruby </div> </button> <button aria-controls="_tm3dj4kaw" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_8qfrx4hv7" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Scala </div> </button> </div> <div class="leafygreen-ui-ov1ktg"> <div class="leafygreen-ui-1sg2lsz"> </div> </div> </div> <div class="lg-ui-tab-panels-0000" data-lgid="lg-tabs-tab_panels"> <div> <div aria-labelledby="_vldhesa2y" class="leafygreen-ui-38lglc" id="_550apmr4s" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/db.collection.insertMany/#mongodb-method-db.collection.insertMany"> <code class="leafygreen-ui-1l06pbn"> db.collection.insertMany() </code> </a> can insert <em> multiple </em> <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/document/#std-label-bson-document-format"> documents </a> into a collection. Pass an array of documents to the method. </p> <p class="leafygreen-ui-1kp3ins"> The following example inserts three new documents into the <code class="leafygreen-ui-1l06pbn"> inventory </code> collection. If the documents do not specify an <code class="leafygreen-ui-1l06pbn"> _id </code> field, MongoDB adds the <code class="leafygreen-ui-1l06pbn"> _id </code> field with an ObjectId value to each document. See <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-write-op-insert-behavior" target="_self"> <span> Insert Behavior <!-- --> . </span> </a> </p> </div> </div> </div> <div> <div aria-labelledby="_oc5dizypz" class="leafygreen-ui-38lglc" id="_znbonihhq" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> </div> </div> </div> <div> <div aria-labelledby="_pchqt80br" class="leafygreen-ui-38lglc" id="_c5hfe83h2" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://mongoc.org/libmongoc/current/mongoc_bulk_operation_insert_with_opts.html" rel="noopener noreferrer"> <span> mongoc_bulk_operation_insert_with_opts </span> <svg alt="" aria-hidden="true" class="leafygreen-ui-1ie5kuq" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M13.823 2.4491C13.8201 2.30008 13.6999 2.17994 13.5509 2.17704L9.5062 2.09836C9.25654 2.09351 9.12821 2.39519 9.30482 2.5718L10.3856 3.65257L7.93433 6.10383C7.87964 6.15852 7.83047 6.21665 7.78683 6.27752L5.99909 8.06525C5.46457 8.59977 5.46457 9.4664 5.99909 10.0009C6.53361 10.5354 7.40023 10.5354 7.93475 10.0009L9.72249 8.21317C9.78336 8.16953 9.84148 8.12037 9.89618 8.06567L12.3474 5.61441L13.4282 6.69518C13.6048 6.87179 13.9065 6.74347 13.9016 6.4938L13.823 2.4491Z" fill="currentColor"> </path> <path d="M7.25 3.12893C7.66421 3.12893 8 3.46472 8 3.87893C8 4.29315 7.66421 4.62893 7.25 4.62893H4C3.72386 4.62893 3.5 4.85279 3.5 5.12893V11.9929C3.5 12.2691 3.72386 12.4929 4 12.4929H10.864C11.1401 12.4929 11.364 12.2691 11.364 11.9929V8.75C11.364 8.33579 11.6998 8 12.114 8C12.5282 8 12.864 8.33579 12.864 8.75V11.9929C12.864 13.0975 11.9686 13.9929 10.864 13.9929H4C2.89543 13.9929 2 13.0975 2 11.9929V5.12893C2 4.02436 2.89543 3.12893 4 3.12893H7.25Z" fill="currentColor"> </path> </svg> </a> inserts <em> multiple </em> <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/document/#std-label-bson-document-format"> documents </a> into a collection. You must pass an iterable of documents to the method. </p> <p class="leafygreen-ui-1kp3ins"> The following example inserts three new documents into the <code class="leafygreen-ui-1l06pbn"> inventory </code> collection. If the documents do not specify an <code class="leafygreen-ui-1l06pbn"> _id </code> field, the C driver adds the <code class="leafygreen-ui-1l06pbn"> _id </code> field with an ObjectId value to each document. See <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-write-op-insert-behavior" target="_self"> <span> Insert Behavior <!-- --> . </span> </a> </p> </div> </div> </div> <div> <div aria-labelledby="_h9w8pxvkw" class="leafygreen-ui-38lglc" id="_qkcwyebrf" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://mongodb.github.io/mongo-csharp-driver/2.10/apidocs/html/M_MongoDB_Driver_IMongoCollection_1_InsertMany.htm" rel="noopener noreferrer"> <span> IMongoCollection.InsertMany() </span> <svg alt="" aria-hidden="true" class="leafygreen-ui-1ie5kuq" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M13.823 2.4491C13.8201 2.30008 13.6999 2.17994 13.5509 2.17704L9.5062 2.09836C9.25654 2.09351 9.12821 2.39519 9.30482 2.5718L10.3856 3.65257L7.93433 6.10383C7.87964 6.15852 7.83047 6.21665 7.78683 6.27752L5.99909 8.06525C5.46457 8.59977 5.46457 9.4664 5.99909 10.0009C6.53361 10.5354 7.40023 10.5354 7.93475 10.0009L9.72249 8.21317C9.78336 8.16953 9.84148 8.12037 9.89618 8.06567L12.3474 5.61441L13.4282 6.69518C13.6048 6.87179 13.9065 6.74347 13.9016 6.4938L13.823 2.4491Z" fill="currentColor"> </path> <path d="M7.25 3.12893C7.66421 3.12893 8 3.46472 8 3.87893C8 4.29315 7.66421 4.62893 7.25 4.62893H4C3.72386 4.62893 3.5 4.85279 3.5 5.12893V11.9929C3.5 12.2691 3.72386 12.4929 4 12.4929H10.864C11.1401 12.4929 11.364 12.2691 11.364 11.9929V8.75C11.364 8.33579 11.6998 8 12.114 8C12.5282 8 12.864 8.33579 12.864 8.75V11.9929C12.864 13.0975 11.9686 13.9929 10.864 13.9929H4C2.89543 13.9929 2 13.0975 2 11.9929V5.12893C2 4.02436 2.89543 3.12893 4 3.12893H7.25Z" fill="currentColor"> </path> </svg> </a> can insert <em> multiple </em> <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/document/#std-label-bson-document-format"> documents </a> into a collection. Pass an enumerable collection of documents to the method. </p> <p class="leafygreen-ui-1kp3ins"> The following example inserts three new documents into the <code class="leafygreen-ui-1l06pbn"> inventory </code> collection. If the documents do not specify an <code class="leafygreen-ui-1l06pbn"> _id </code> field, the driver adds the <code class="leafygreen-ui-1l06pbn"> _id </code> field with an ObjectId value to each document. See <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-write-op-insert-behavior" target="_self"> <span> Insert Behavior <!-- --> . </span> </a> </p> </div> </div> </div> <div> <div aria-labelledby="_c64ixu299" class="leafygreen-ui-38lglc" id="_80wn2gncp" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://godoc.org/github.com/mongodb/mongo-go-driver/mongo#Collection.InsertMany" rel="noopener noreferrer"> <span> Collection.InsertMany </span> <svg alt="" aria-hidden="true" class="leafygreen-ui-1ie5kuq" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M13.823 2.4491C13.8201 2.30008 13.6999 2.17994 13.5509 2.17704L9.5062 2.09836C9.25654 2.09351 9.12821 2.39519 9.30482 2.5718L10.3856 3.65257L7.93433 6.10383C7.87964 6.15852 7.83047 6.21665 7.78683 6.27752L5.99909 8.06525C5.46457 8.59977 5.46457 9.4664 5.99909 10.0009C6.53361 10.5354 7.40023 10.5354 7.93475 10.0009L9.72249 8.21317C9.78336 8.16953 9.84148 8.12037 9.89618 8.06567L12.3474 5.61441L13.4282 6.69518C13.6048 6.87179 13.9065 6.74347 13.9016 6.4938L13.823 2.4491Z" fill="currentColor"> </path> <path d="M7.25 3.12893C7.66421 3.12893 8 3.46472 8 3.87893C8 4.29315 7.66421 4.62893 7.25 4.62893H4C3.72386 4.62893 3.5 4.85279 3.5 5.12893V11.9929C3.5 12.2691 3.72386 12.4929 4 12.4929H10.864C11.1401 12.4929 11.364 12.2691 11.364 11.9929V8.75C11.364 8.33579 11.6998 8 12.114 8C12.5282 8 12.864 8.33579 12.864 8.75V11.9929C12.864 13.0975 11.9686 13.9929 10.864 13.9929H4C2.89543 13.9929 2 13.0975 2 11.9929V5.12893C2 4.02436 2.89543 3.12893 4 3.12893H7.25Z" fill="currentColor"> </path> </svg> </a> can insert <em> multiple </em> <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/document/#std-label-bson-document-format"> documents </a> into a collection. </p> <p class="leafygreen-ui-1kp3ins"> The following example inserts three new documents into the <code class="leafygreen-ui-1l06pbn"> inventory </code> collection. If the documents do not specify an <code class="leafygreen-ui-1l06pbn"> _id </code> field, the driver adds the <code class="leafygreen-ui-1l06pbn"> _id </code> field with an ObjectId value to each document. See <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-write-op-insert-behavior" target="_self"> <span> Insert Behavior <!-- --> . </span> </a> </p> </div> </div> </div> <div> <div aria-labelledby="_lizfcvs3p" class="leafygreen-ui-38lglc" id="_dgr1jmepo" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="http://mongodb.github.io/mongo-java-driver-reactivestreams/1.6/javadoc/com/mongodb/reactivestreams/client/MongoCollection.html#insertMany(java.util.List)" rel="noopener noreferrer"> <span> com.mongodb.reactivestreams.client.MongoCollection.html.insertMany </span> <svg alt="" aria-hidden="true" class="leafygreen-ui-1ie5kuq" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M13.823 2.4491C13.8201 2.30008 13.6999 2.17994 13.5509 2.17704L9.5062 2.09836C9.25654 2.09351 9.12821 2.39519 9.30482 2.5718L10.3856 3.65257L7.93433 6.10383C7.87964 6.15852 7.83047 6.21665 7.78683 6.27752L5.99909 8.06525C5.46457 8.59977 5.46457 9.4664 5.99909 10.0009C6.53361 10.5354 7.40023 10.5354 7.93475 10.0009L9.72249 8.21317C9.78336 8.16953 9.84148 8.12037 9.89618 8.06567L12.3474 5.61441L13.4282 6.69518C13.6048 6.87179 13.9065 6.74347 13.9016 6.4938L13.823 2.4491Z" fill="currentColor"> </path> <path d="M7.25 3.12893C7.66421 3.12893 8 3.46472 8 3.87893C8 4.29315 7.66421 4.62893 7.25 4.62893H4C3.72386 4.62893 3.5 4.85279 3.5 5.12893V11.9929C3.5 12.2691 3.72386 12.4929 4 12.4929H10.864C11.1401 12.4929 11.364 12.2691 11.364 11.9929V8.75C11.364 8.33579 11.6998 8 12.114 8C12.5282 8 12.864 8.33579 12.864 8.75V11.9929C12.864 13.0975 11.9686 13.9929 10.864 13.9929H4C2.89543 13.9929 2 13.0975 2 11.9929V5.12893C2 4.02436 2.89543 3.12893 4 3.12893H7.25Z" fill="currentColor"> </path> </svg> </a> inserts the following documents with the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="http://mongodb.github.io/mongo-java-driver-reactivestreams/1.6/" rel="noopener noreferrer"> <span> Java Reactive Streams Driver </span> <svg alt="" aria-hidden="true" class="leafygreen-ui-1ie5kuq" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M13.823 2.4491C13.8201 2.30008 13.6999 2.17994 13.5509 2.17704L9.5062 2.09836C9.25654 2.09351 9.12821 2.39519 9.30482 2.5718L10.3856 3.65257L7.93433 6.10383C7.87964 6.15852 7.83047 6.21665 7.78683 6.27752L5.99909 8.06525C5.46457 8.59977 5.46457 9.4664 5.99909 10.0009C6.53361 10.5354 7.40023 10.5354 7.93475 10.0009L9.72249 8.21317C9.78336 8.16953 9.84148 8.12037 9.89618 8.06567L12.3474 5.61441L13.4282 6.69518C13.6048 6.87179 13.9065 6.74347 13.9016 6.4938L13.823 2.4491Z" fill="currentColor"> </path> <path d="M7.25 3.12893C7.66421 3.12893 8 3.46472 8 3.87893C8 4.29315 7.66421 4.62893 7.25 4.62893H4C3.72386 4.62893 3.5 4.85279 3.5 5.12893V11.9929C3.5 12.2691 3.72386 12.4929 4 12.4929H10.864C11.1401 12.4929 11.364 12.2691 11.364 11.9929V8.75C11.364 8.33579 11.6998 8 12.114 8C12.5282 8 12.864 8.33579 12.864 8.75V11.9929C12.864 13.0975 11.9686 13.9929 10.864 13.9929H4C2.89543 13.9929 2 13.0975 2 11.9929V5.12893C2 4.02436 2.89543 3.12893 4 3.12893H7.25Z" fill="currentColor"> </path> </svg> </a> : </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ item: \"journal\", qty: 25, tags: [\"blank\", \"red\"], size: { h: 14, w: 21, uom: \"cm\" } }\n{ item: \"mat\", qty: 85, tags: [\"gray\"], size: { h: 27.9, w: 35.5, uom: \"cm\" } }\n{ item: \"mousepad\", qty: 25, tags: [\"gel\", \"blue\"], size: { h: 19, w: 22.85, uom: \"cm\" } }","programmingLanguage":"JSON"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <pre class="leafygreen-ui-11itue3" 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">{ <span class="lg-highlight-attr">item</span>: <span class="lg-highlight-string">"journal"</span>, <span class="lg-highlight-attr">qty</span>: <span class="lg-highlight-number">25</span>, <span class="lg-highlight-attr">tags</span>: [<span class="lg-highlight-string">"blank"</span>, <span class="lg-highlight-string">"red"</span>], <span class="lg-highlight-attr">size</span>: { <span class="lg-highlight-attr">h</span>: <span class="lg-highlight-number">14</span>, <span class="lg-highlight-attr">w</span>: <span class="lg-highlight-number">21</span>, <span class="lg-highlight-attr">uom</span>: <span class="lg-highlight-string">"cm"</span> } }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-attr">item</span>: <span class="lg-highlight-string">"mat"</span>, <span class="lg-highlight-attr">qty</span>: <span class="lg-highlight-number">85</span>, <span class="lg-highlight-attr">tags</span>: [<span class="lg-highlight-string">"gray"</span>], <span class="lg-highlight-attr">size</span>: { <span class="lg-highlight-attr">h</span>: <span class="lg-highlight-number">27.9</span>, <span class="lg-highlight-attr">w</span>: <span class="lg-highlight-number">35.5</span>, <span class="lg-highlight-attr">uom</span>: <span class="lg-highlight-string">"cm"</span> } }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-attr">item</span>: <span class="lg-highlight-string">"mousepad"</span>, <span class="lg-highlight-attr">qty</span>: <span class="lg-highlight-number">25</span>, <span class="lg-highlight-attr">tags</span>: [<span class="lg-highlight-string">"gel"</span>, <span class="lg-highlight-string">"blue"</span>], <span class="lg-highlight-attr">size</span>: { <span class="lg-highlight-attr">h</span>: <span class="lg-highlight-number">19</span>, <span class="lg-highlight-attr">w</span>: <span class="lg-highlight-number">22.85</span>, <span class="lg-highlight-attr">uom</span>: <span class="lg-highlight-string">"cm"</span> } }</td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-113-menu" aria-describedby="select-113-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-114" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:r8d:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":r8d:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r8d:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r8d:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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 example inserts three new documents into the <code class="leafygreen-ui-1l06pbn"> inventory </code> collection. If the documents do not specify an <code class="leafygreen-ui-1l06pbn"> _id </code> field, the driver adds the <code class="leafygreen-ui-1l06pbn"> _id </code> field with an ObjectId value to each document. See <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-write-op-insert-behavior" target="_self"> <span> Insert Behavior <!-- --> . </span> </a> </p> </div> </div> </div> <div> <div aria-labelledby="_il83vuhk0" class="leafygreen-ui-38lglc" id="_cxrwhdfj7" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://mongodb.github.io/mongo-java-driver/3.4/javadoc/com/mongodb/client/MongoCollection.html#insertMany-java.util.List-" rel="noopener noreferrer"> <span> com.mongodb.client.MongoCollection.insertMany </span> <svg alt="" aria-hidden="true" class="leafygreen-ui-1ie5kuq" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M13.823 2.4491C13.8201 2.30008 13.6999 2.17994 13.5509 2.17704L9.5062 2.09836C9.25654 2.09351 9.12821 2.39519 9.30482 2.5718L10.3856 3.65257L7.93433 6.10383C7.87964 6.15852 7.83047 6.21665 7.78683 6.27752L5.99909 8.06525C5.46457 8.59977 5.46457 9.4664 5.99909 10.0009C6.53361 10.5354 7.40023 10.5354 7.93475 10.0009L9.72249 8.21317C9.78336 8.16953 9.84148 8.12037 9.89618 8.06567L12.3474 5.61441L13.4282 6.69518C13.6048 6.87179 13.9065 6.74347 13.9016 6.4938L13.823 2.4491Z" fill="currentColor"> </path> <path d="M7.25 3.12893C7.66421 3.12893 8 3.46472 8 3.87893C8 4.29315 7.66421 4.62893 7.25 4.62893H4C3.72386 4.62893 3.5 4.85279 3.5 5.12893V11.9929C3.5 12.2691 3.72386 12.4929 4 12.4929H10.864C11.1401 12.4929 11.364 12.2691 11.364 11.9929V8.75C11.364 8.33579 11.6998 8 12.114 8C12.5282 8 12.864 8.33579 12.864 8.75V11.9929C12.864 13.0975 11.9686 13.9929 10.864 13.9929H4C2.89543 13.9929 2 13.0975 2 11.9929V5.12893C2 4.02436 2.89543 3.12893 4 3.12893H7.25Z" fill="currentColor"> </path> </svg> </a> can insert <em> multiple </em> <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/document/#std-label-bson-document-format"> documents </a> into a collection. Pass a list of documents to the method. </p> <p class="leafygreen-ui-1kp3ins"> The following example inserts three new documents into the <code class="leafygreen-ui-1l06pbn"> inventory </code> collection. If the documents do not specify an <code class="leafygreen-ui-1l06pbn"> _id </code> field, the driver adds the <code class="leafygreen-ui-1l06pbn"> _id </code> field with an ObjectId value to each document. See <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-write-op-insert-behavior" target="_self"> <span> Insert Behavior <!-- --> . </span> </a> </p> </div> </div> </div> <div> <div aria-labelledby="_o17xuzy3m" class="leafygreen-ui-38lglc" id="_guhcehepe" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://mongodb.github.io/mongo-java-driver/4.11/apidocs/mongodb-driver-kotlin-coroutine/mongodb-driver-kotlin-coroutine/com.mongodb.kotlin.client.coroutine/-mongo-collection/insert-many.html" rel="noopener noreferrer"> <span> MongoCollection.insertMany </span> <svg alt="" aria-hidden="true" class="leafygreen-ui-1ie5kuq" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M13.823 2.4491C13.8201 2.30008 13.6999 2.17994 13.5509 2.17704L9.5062 2.09836C9.25654 2.09351 9.12821 2.39519 9.30482 2.5718L10.3856 3.65257L7.93433 6.10383C7.87964 6.15852 7.83047 6.21665 7.78683 6.27752L5.99909 8.06525C5.46457 8.59977 5.46457 9.4664 5.99909 10.0009C6.53361 10.5354 7.40023 10.5354 7.93475 10.0009L9.72249 8.21317C9.78336 8.16953 9.84148 8.12037 9.89618 8.06567L12.3474 5.61441L13.4282 6.69518C13.6048 6.87179 13.9065 6.74347 13.9016 6.4938L13.823 2.4491Z" fill="currentColor"> </path> <path d="M7.25 3.12893C7.66421 3.12893 8 3.46472 8 3.87893C8 4.29315 7.66421 4.62893 7.25 4.62893H4C3.72386 4.62893 3.5 4.85279 3.5 5.12893V11.9929C3.5 12.2691 3.72386 12.4929 4 12.4929H10.864C11.1401 12.4929 11.364 12.2691 11.364 11.9929V8.75C11.364 8.33579 11.6998 8 12.114 8C12.5282 8 12.864 8.33579 12.864 8.75V11.9929C12.864 13.0975 11.9686 13.9929 10.864 13.9929H4C2.89543 13.9929 2 13.0975 2 11.9929V5.12893C2 4.02436 2.89543 3.12893 4 3.12893H7.25Z" fill="currentColor"> </path> </svg> </a> inserts <em> multiple </em> <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/document/#std-label-bson-document-format"> documents </a> into a collection. Pass a list of documents as a parameter to the method. </p> <p class="leafygreen-ui-1kp3ins"> The following example inserts three new documents into the <code class="leafygreen-ui-1l06pbn"> inventory </code> collection. If the documents do not specify an <code class="leafygreen-ui-1l06pbn"> _id </code> field, the driver adds an ObjectId value to each document. See <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-write-op-insert-behavior" target="_self"> <span> Insert Behavior <!-- --> . </span> </a> </p> </div> </div> </div> <div> <div aria-labelledby="_3dzurmzj4" class="leafygreen-ui-38lglc" id="_i9cezqe32" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://motor.readthedocs.io/en/stable/api-asyncio/asyncio_motor_collection.html#motor.motor_asyncio.AsyncIOMotorCollection.insert_many" rel="noopener noreferrer"> <span> <code class="leafygreen-ui-1l06pbn"> motor.motor_asyncio.AsyncIOMotorCollection.insert_many </code> </span> <svg alt="" aria-hidden="true" class="leafygreen-ui-1ie5kuq" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M13.823 2.4491C13.8201 2.30008 13.6999 2.17994 13.5509 2.17704L9.5062 2.09836C9.25654 2.09351 9.12821 2.39519 9.30482 2.5718L10.3856 3.65257L7.93433 6.10383C7.87964 6.15852 7.83047 6.21665 7.78683 6.27752L5.99909 8.06525C5.46457 8.59977 5.46457 9.4664 5.99909 10.0009C6.53361 10.5354 7.40023 10.5354 7.93475 10.0009L9.72249 8.21317C9.78336 8.16953 9.84148 8.12037 9.89618 8.06567L12.3474 5.61441L13.4282 6.69518C13.6048 6.87179 13.9065 6.74347 13.9016 6.4938L13.823 2.4491Z" fill="currentColor"> </path> <path d="M7.25 3.12893C7.66421 3.12893 8 3.46472 8 3.87893C8 4.29315 7.66421 4.62893 7.25 4.62893H4C3.72386 4.62893 3.5 4.85279 3.5 5.12893V11.9929C3.5 12.2691 3.72386 12.4929 4 12.4929H10.864C11.1401 12.4929 11.364 12.2691 11.364 11.9929V8.75C11.364 8.33579 11.6998 8 12.114 8C12.5282 8 12.864 8.33579 12.864 8.75V11.9929C12.864 13.0975 11.9686 13.9929 10.864 13.9929H4C2.89543 13.9929 2 13.0975 2 11.9929V5.12893C2 4.02436 2.89543 3.12893 4 3.12893H7.25Z" fill="currentColor"> </path> </svg> </a> can insert <em> multiple </em> <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/document/#std-label-bson-document-format"> documents </a> into a collection. Pass an iterable of documents to the method. </p> <p class="leafygreen-ui-1kp3ins"> The following example inserts three new documents into the <code class="leafygreen-ui-1l06pbn"> inventory </code> collection. If the documents do not specify an <code class="leafygreen-ui-1l06pbn"> _id </code> field, the PyMongo driver adds the <code class="leafygreen-ui-1l06pbn"> _id </code> field with an ObjectId value to each document. See <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-write-op-insert-behavior" target="_self"> <span> Insert Behavior <!-- --> . </span> </a> </p> </div> </div> </div> <div> <div aria-labelledby="_4tnw5u9qp" class="" id="_thl5dt2wq" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="http://mongodb.github.io/node-mongodb-native/3.6/api/Collection.html#insertMany" rel="noopener noreferrer"> <span> Collection.insertMany() </span> <svg alt="" aria-hidden="true" class="leafygreen-ui-1ie5kuq" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M13.823 2.4491C13.8201 2.30008 13.6999 2.17994 13.5509 2.17704L9.5062 2.09836C9.25654 2.09351 9.12821 2.39519 9.30482 2.5718L10.3856 3.65257L7.93433 6.10383C7.87964 6.15852 7.83047 6.21665 7.78683 6.27752L5.99909 8.06525C5.46457 8.59977 5.46457 9.4664 5.99909 10.0009C6.53361 10.5354 7.40023 10.5354 7.93475 10.0009L9.72249 8.21317C9.78336 8.16953 9.84148 8.12037 9.89618 8.06567L12.3474 5.61441L13.4282 6.69518C13.6048 6.87179 13.9065 6.74347 13.9016 6.4938L13.823 2.4491Z" fill="currentColor"> </path> <path d="M7.25 3.12893C7.66421 3.12893 8 3.46472 8 3.87893C8 4.29315 7.66421 4.62893 7.25 4.62893H4C3.72386 4.62893 3.5 4.85279 3.5 5.12893V11.9929C3.5 12.2691 3.72386 12.4929 4 12.4929H10.864C11.1401 12.4929 11.364 12.2691 11.364 11.9929V8.75C11.364 8.33579 11.6998 8 12.114 8C12.5282 8 12.864 8.33579 12.864 8.75V11.9929C12.864 13.0975 11.9686 13.9929 10.864 13.9929H4C2.89543 13.9929 2 13.0975 2 11.9929V5.12893C2 4.02436 2.89543 3.12893 4 3.12893H7.25Z" fill="currentColor"> </path> </svg> </a> can insert <em> multiple </em> <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/document/#std-label-bson-document-format"> documents </a> into a collection. Pass an array of documents to the method. </p> <p class="leafygreen-ui-1kp3ins"> The following example inserts three new documents into the <code class="leafygreen-ui-1l06pbn"> inventory </code> collection. If the documents do not specify an <code class="leafygreen-ui-1l06pbn"> _id </code> field, the Node.js driver adds the <code class="leafygreen-ui-1l06pbn"> _id </code> field with an ObjectId value to each document. See <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-write-op-insert-behavior" target="_self"> <span> Insert Behavior <!-- --> . </span> </a> </p> </div> </div> </div> <div> <div aria-labelledby="_z1llgvv9m" class="leafygreen-ui-38lglc" id="_vz7wid5u2" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://metacpan.org/pod/MongoDB::Collection#insert_many" rel="noopener noreferrer"> <span> MongoDB::Collection::insert_many() </span> <svg alt="" aria-hidden="true" class="leafygreen-ui-1ie5kuq" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M13.823 2.4491C13.8201 2.30008 13.6999 2.17994 13.5509 2.17704L9.5062 2.09836C9.25654 2.09351 9.12821 2.39519 9.30482 2.5718L10.3856 3.65257L7.93433 6.10383C7.87964 6.15852 7.83047 6.21665 7.78683 6.27752L5.99909 8.06525C5.46457 8.59977 5.46457 9.4664 5.99909 10.0009C6.53361 10.5354 7.40023 10.5354 7.93475 10.0009L9.72249 8.21317C9.78336 8.16953 9.84148 8.12037 9.89618 8.06567L12.3474 5.61441L13.4282 6.69518C13.6048 6.87179 13.9065 6.74347 13.9016 6.4938L13.823 2.4491Z" fill="currentColor"> </path> <path d="M7.25 3.12893C7.66421 3.12893 8 3.46472 8 3.87893C8 4.29315 7.66421 4.62893 7.25 4.62893H4C3.72386 4.62893 3.5 4.85279 3.5 5.12893V11.9929C3.5 12.2691 3.72386 12.4929 4 12.4929H10.864C11.1401 12.4929 11.364 12.2691 11.364 11.9929V8.75C11.364 8.33579 11.6998 8 12.114 8C12.5282 8 12.864 8.33579 12.864 8.75V11.9929C12.864 13.0975 11.9686 13.9929 10.864 13.9929H4C2.89543 13.9929 2 13.0975 2 11.9929V5.12893C2 4.02436 2.89543 3.12893 4 3.12893H7.25Z" fill="currentColor"> </path> </svg> </a> can insert <em> multiple </em> <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/document/#std-label-bson-document-format"> documents </a> into a collection. Pass an array reference of documents to the method. </p> <p class="leafygreen-ui-1kp3ins"> The following example inserts three new documents into the <code class="leafygreen-ui-1l06pbn"> inventory </code> collection. If the documents do not specify an <code class="leafygreen-ui-1l06pbn"> _id </code> field, the Perl driver adds the <code class="leafygreen-ui-1l06pbn"> _id </code> field with an ObjectId value to each document. See <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-write-op-insert-behavior" target="_self"> <span> Insert Behavior <!-- --> . </span> </a> </p> </div> </div> </div> <div> <div aria-labelledby="_wqdd3keqx" class="leafygreen-ui-38lglc" id="_7a5cl9ubg" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/php-library/upcoming/reference/method/MongoDBCollection-insertMany/#mongodb-phpmethod-phpmethod.MongoDB-Collection--insertMany--" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> MongoDB\\Collection::insertMany() </code> </span> </a> can insert <em> multiple </em> <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/document/#std-label-bson-document-format"> documents </a> into a collection. Pass an array of documents to the method. </p> <p class="leafygreen-ui-1kp3ins"> The following example inserts three new documents into the <code class="leafygreen-ui-1l06pbn"> inventory </code> collection. If the documents do not specify an <code class="leafygreen-ui-1l06pbn"> _id </code> field, the PHP driver adds the <code class="leafygreen-ui-1l06pbn"> _id </code> field with an ObjectId value to each document. See <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-write-op-insert-behavior" target="_self"> <span> Insert Behavior <!-- --> . </span> </a> </p> </div> </div> </div> <div> <div aria-labelledby="_z482j7w4l" class="leafygreen-ui-38lglc" id="_clnd0o96f" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://pymongo.readthedocs.io/en/stable/api/pymongo/collection.html#pymongo.collection.Collection.insert_many" rel="noopener noreferrer"> <span> <code class="leafygreen-ui-1l06pbn"> pymongo.collection.Collection.insert_many </code> </span> <svg alt="" aria-hidden="true" class="leafygreen-ui-1ie5kuq" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M13.823 2.4491C13.8201 2.30008 13.6999 2.17994 13.5509 2.17704L9.5062 2.09836C9.25654 2.09351 9.12821 2.39519 9.30482 2.5718L10.3856 3.65257L7.93433 6.10383C7.87964 6.15852 7.83047 6.21665 7.78683 6.27752L5.99909 8.06525C5.46457 8.59977 5.46457 9.4664 5.99909 10.0009C6.53361 10.5354 7.40023 10.5354 7.93475 10.0009L9.72249 8.21317C9.78336 8.16953 9.84148 8.12037 9.89618 8.06567L12.3474 5.61441L13.4282 6.69518C13.6048 6.87179 13.9065 6.74347 13.9016 6.4938L13.823 2.4491Z" fill="currentColor"> </path> <path d="M7.25 3.12893C7.66421 3.12893 8 3.46472 8 3.87893C8 4.29315 7.66421 4.62893 7.25 4.62893H4C3.72386 4.62893 3.5 4.85279 3.5 5.12893V11.9929C3.5 12.2691 3.72386 12.4929 4 12.4929H10.864C11.1401 12.4929 11.364 12.2691 11.364 11.9929V8.75C11.364 8.33579 11.6998 8 12.114 8C12.5282 8 12.864 8.33579 12.864 8.75V11.9929C12.864 13.0975 11.9686 13.9929 10.864 13.9929H4C2.89543 13.9929 2 13.0975 2 11.9929V5.12893C2 4.02436 2.89543 3.12893 4 3.12893H7.25Z" fill="currentColor"> </path> </svg> </a> can insert <em> multiple </em> <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/document/#std-label-bson-document-format"> documents </a> into a collection. Pass an iterable of documents to the method. </p> <p class="leafygreen-ui-1kp3ins"> The following example inserts three new documents into the <code class="leafygreen-ui-1l06pbn"> inventory </code> collection. If the documents do not specify an <code class="leafygreen-ui-1l06pbn"> _id </code> field, the PyMongo driver adds the <code class="leafygreen-ui-1l06pbn"> _id </code> field with an ObjectId value to each document. See <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-write-op-insert-behavior" target="_self"> <span> Insert Behavior <!-- --> . </span> </a> </p> </div> </div> </div> <div> <div aria-labelledby="_bgo8v83ps" class="leafygreen-ui-38lglc" id="_wexp94ud6" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="http://api.mongodb.com/ruby/current/Mongo/Collection.html#insert_many-instance_method" target="_self"> <span> Mongo::Collection#insert_many() </span> </a> can insert <em> multiple </em> <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/document/#std-label-bson-document-format"> documents </a> into a collection. Pass an array of documents to the method. </p> <p class="leafygreen-ui-1kp3ins"> The following example inserts three new documents into the <code class="leafygreen-ui-1l06pbn"> inventory </code> collection. If the documents do not specify an <code class="leafygreen-ui-1l06pbn"> _id </code> field, the Ruby driver adds the <code class="leafygreen-ui-1l06pbn"> _id </code> field with an ObjectId value to each document. See <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-write-op-insert-behavior" target="_self"> <span> Insert Behavior <!-- --> . </span> </a> </p> </div> </div> </div> <div> <div aria-labelledby="_cfsbbvp1o" class="leafygreen-ui-38lglc" id="_axo487tik" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="http://mongodb.github.io/mongo-scala-driver/2.9/scaladoc/org/mongodb/scala/MongoCollection.html#insertMany(documents:Seq[_&lt;:TResult],options:org.mongodb.scala.model.InsertManyOptions):org.mongodb.scala.SingleObservable[org.mongodb.scala.Completed]" rel="noopener noreferrer"> <span> collection.insertMany() </span> <svg alt="" aria-hidden="true" class="leafygreen-ui-1ie5kuq" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M13.823 2.4491C13.8201 2.30008 13.6999 2.17994 13.5509 2.17704L9.5062 2.09836C9.25654 2.09351 9.12821 2.39519 9.30482 2.5718L10.3856 3.65257L7.93433 6.10383C7.87964 6.15852 7.83047 6.21665 7.78683 6.27752L5.99909 8.06525C5.46457 8.59977 5.46457 9.4664 5.99909 10.0009C6.53361 10.5354 7.40023 10.5354 7.93475 10.0009L9.72249 8.21317C9.78336 8.16953 9.84148 8.12037 9.89618 8.06567L12.3474 5.61441L13.4282 6.69518C13.6048 6.87179 13.9065 6.74347 13.9016 6.4938L13.823 2.4491Z" fill="currentColor"> </path> <path d="M7.25 3.12893C7.66421 3.12893 8 3.46472 8 3.87893C8 4.29315 7.66421 4.62893 7.25 4.62893H4C3.72386 4.62893 3.5 4.85279 3.5 5.12893V11.9929C3.5 12.2691 3.72386 12.4929 4 12.4929H10.864C11.1401 12.4929 11.364 12.2691 11.364 11.9929V8.75C11.364 8.33579 11.6998 8 12.114 8C12.5282 8 12.864 8.33579 12.864 8.75V11.9929C12.864 13.0975 11.9686 13.9929 10.864 13.9929H4C2.89543 13.9929 2 13.0975 2 11.9929V5.12893C2 4.02436 2.89543 3.12893 4 3.12893H7.25Z" fill="currentColor"> </path> </svg> </a> can insert <em> multiple </em> <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/document/#std-label-bson-document-format"> documents </a> into a collection. </p> <p class="leafygreen-ui-1kp3ins"> The following example inserts three new documents into the <code class="leafygreen-ui-1l06pbn"> inventory </code> collection. If the documents do not specify an <code class="leafygreen-ui-1l06pbn"> _id </code> field, the Scala driver adds the <code class="leafygreen-ui-1l06pbn"> _id </code> field with an ObjectId value to each document. See <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-write-op-insert-behavior" target="_self"> <span> Insert Behavior <!-- --> . </span> </a> </p> </div> </div> </div> </div> </div> <div aria-hidden="true"> </div> <div class="leafygreen-ui-f2qztv" data-lgid="lg-tabs"> <div class="leafygreen-ui-jp7pox" id="tabs-16"> <div aria-label="Tabs to describe usage of drivers" aria-orientation="horizontal" class="leafygreen-ui-m8p1vb lg-ui-tab-list-0000" data-lgid="lg-tabs-tab_list" role="tablist"> <button aria-controls="_gsdvc9sl2" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_ipo2cu2m8" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> MongoDB Shell </div> </button> <button aria-controls="_sansjo4cg" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_ju1as4pg9" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Compass </div> </button> <button aria-controls="_3cozcr1gk" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_pnfzkmygq" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> C </div> </button> <button aria-controls="_npemjgsau" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_002t5rzia" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> C# </div> </button> <button aria-controls="_42pbyvnay" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_pp6ld7n7n" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Go </div> </button> <button aria-controls="_zk4buf0k5" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_7jgpi52v5" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Java (Async) </div> </button> <button aria-controls="_ik8vvfv45" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_a2i32010m" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Java (Sync) </div> </button> <button aria-controls="_261ar6tyq" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_dgnq9xez7" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Kotlin (Coroutine) </div> </button> <button aria-controls="_k5m8nq5cs" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_c16w2haor" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Motor </div> </button> <button aria-controls="_nn0gs4dv2" aria-selected="true" class="leafygreen-ui-1l773z1" data-text="" id="_fe0ppgiy8" name="" role="tab" tabindex="0"> <div class="leafygreen-ui-1nxuzmg"> Node.js </div> </button> <button aria-controls="_u42x0qrfb" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_zxszqx7ao" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Perl </div> </button> <button aria-controls="_2bue1kvzl" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_jdcay1gp7" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> PHP </div> </button> <button aria-controls="_babz9ktd5" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_kozrcugda" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Python </div> </button> <button aria-controls="_1uv7lojv0" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_e8htttujf" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Ruby </div> </button> <button aria-controls="_2n1idyl0t" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_6caj9try2" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Scala </div> </button> </div> <div class="leafygreen-ui-ov1ktg"> <div class="leafygreen-ui-1sg2lsz"> </div> </div> </div> <div class="lg-ui-tab-panels-0000" data-lgid="lg-tabs-tab_panels"> <div> <div aria-labelledby="_060kk00ce" class="leafygreen-ui-38lglc" id="_4bznom1a9" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.inventory.insertMany([\n { item: \"journal\", qty: 25, tags: [\"blank\", \"red\"], size: { h: 14, w: 21, uom: \"cm\" } },\n { item: \"mat\", qty: 85, tags: [\"gray\"], size: { h: 27.9, w: 35.5, uom: \"cm\" } },\n { item: \"mousepad\", qty: 25, tags: [\"gel\", \"blue\"], size: { h: 19, w: 22.85, uom: \"cm\" } }\n])","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <pre class="leafygreen-ui-11itue3" 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">inventory</span>.<span class="lg-highlight-title lg-highlight-function">insertMany</span>(<!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">item</span>: <span class="lg-highlight-string">"journal"</span>, <span class="lg-highlight-attr">qty</span>: <span class="lg-highlight-number">25</span>, <span class="lg-highlight-attr">tags</span>: <!-- -->[<span class="lg-highlight-string">"blank"</span>, <span class="lg-highlight-string">"red"</span>]<!-- -->, <span class="lg-highlight-attr">size</span>: <!-- -->{ <span class="lg-highlight-attr">h</span>: <span class="lg-highlight-number">14</span>, <span class="lg-highlight-attr">w</span>: <span class="lg-highlight-number">21</span>, <span class="lg-highlight-attr">uom</span>: <span class="lg-highlight-string">"cm"</span> } }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">item</span>: <span class="lg-highlight-string">"mat"</span>, <span class="lg-highlight-attr">qty</span>: <span class="lg-highlight-number">85</span>, <span class="lg-highlight-attr">tags</span>: <!-- -->[<span class="lg-highlight-string">"gray"</span>]<!-- -->, <span class="lg-highlight-attr">size</span>: <!-- -->{ <span class="lg-highlight-attr">h</span>: <span class="lg-highlight-number">27.9</span>, <span class="lg-highlight-attr">w</span>: <span class="lg-highlight-number">35.5</span>, <span class="lg-highlight-attr">uom</span>: <span class="lg-highlight-string">"cm"</span> } }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">item</span>: <span class="lg-highlight-string">"mousepad"</span>, <span class="lg-highlight-attr">qty</span>: <span class="lg-highlight-number">25</span>, <span class="lg-highlight-attr">tags</span>: <!-- -->[<span class="lg-highlight-string">"gel"</span>, <span class="lg-highlight-string">"blue"</span>]<!-- -->, <span class="lg-highlight-attr">size</span>: <!-- -->{ <span class="lg-highlight-attr">h</span>: <span class="lg-highlight-number">19</span>, <span class="lg-highlight-attr">w</span>: <span class="lg-highlight-number">22.85</span>, <span class="lg-highlight-attr">uom</span>: <span class="lg-highlight-string">"cm"</span> } }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">])</td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-116-menu" aria-describedby="select-116-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-117" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:r8e:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":r8e:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r8e:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r8e:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_xi330n1zo" class="leafygreen-ui-38lglc" id="_qx301oc3w" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"[\n { \"item\": \"canvas\", \"qty\": 100, \"size\": { \"h\": 28, \"w\": 35.5, \"uom\": \"cm\" }, \"status\": \"A\" },\n { \"item\": \"journal\", \"qty\": 25, \"size\": { \"h\": 14, \"w\": 21, \"uom\": \"cm\" }, \"status\": \"A\" },\n { \"item\": \"mat\", \"qty\": 85, \"size\": { \"h\": 27.9, \"w\": 35.5, \"uom\": \"cm\" }, \"status\": \"A\" },\n { \"item\": \"mousepad\", \"qty\": 25, \"size\": { \"h\": 19, \"w\": 22.85, \"uom\": \"cm\" }, \"status\": \"P\" },\n { \"item\": \"notebook\", \"qty\": 50, \"size\": { \"h\": 8.5, \"w\": 11, \"uom\": \"in\" }, \"status\": \"P\" },\n { \"item\": \"paper\", \"qty\": 100, \"size\": { \"h\": 8.5, \"w\": 11, \"uom\": \"in\" }, \"status\": \"D\" },\n { \"item\": \"planner\", \"qty\": 75, \"size\": { \"h\": 22.85, \"w\": 30, \"uom\": \"cm\" }, \"status\": \"D\" },\n { \"item\": \"postcard\", \"qty\": 45, \"size\": { \"h\": 10, \"w\": 15.25, \"uom\": \"cm\" }, \"status\": \"A\" },\n { \"item\": \"sketchbook\", \"qty\": 80, \"size\": { \"h\": 14, \"w\": 21, \"uom\": \"cm\" }, \"status\": \"A\" },\n { \"item\": \"sketch pad\", \"qty\": 95, \"size\": { \"h\": 22.85, \"w\": 30.5, \"uom\": \"cm\" }, \"status\": \"A\" }\n]","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <pre class="leafygreen-ui-11itue3" 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">[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"item"</span>: <span class="lg-highlight-string">"canvas"</span>, <span class="lg-highlight-string">"qty"</span>: <span class="lg-highlight-number">100</span>, <span class="lg-highlight-string">"size"</span>: <!-- -->{ <span class="lg-highlight-string">"h"</span>: <span class="lg-highlight-number">28</span>, <span class="lg-highlight-string">"w"</span>: <span class="lg-highlight-number">35.5</span>, <span class="lg-highlight-string">"uom"</span>: <span class="lg-highlight-string">"cm"</span> }<!-- -->, <span class="lg-highlight-string">"status"</span>: <span class="lg-highlight-string">"A"</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"item"</span>: <span class="lg-highlight-string">"journal"</span>, <span class="lg-highlight-string">"qty"</span>: <span class="lg-highlight-number">25</span>, <span class="lg-highlight-string">"size"</span>: <!-- -->{ <span class="lg-highlight-string">"h"</span>: <span class="lg-highlight-number">14</span>, <span class="lg-highlight-string">"w"</span>: <span class="lg-highlight-number">21</span>, <span class="lg-highlight-string">"uom"</span>: <span class="lg-highlight-string">"cm"</span> }<!-- -->, <span class="lg-highlight-string">"status"</span>: <span class="lg-highlight-string">"A"</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"item"</span>: <span class="lg-highlight-string">"mat"</span>, <span class="lg-highlight-string">"qty"</span>: <span class="lg-highlight-number">85</span>, <span class="lg-highlight-string">"size"</span>: <!-- -->{ <span class="lg-highlight-string">"h"</span>: <span class="lg-highlight-number">27.9</span>, <span class="lg-highlight-string">"w"</span>: <span class="lg-highlight-number">35.5</span>, <span class="lg-highlight-string">"uom"</span>: <span class="lg-highlight-string">"cm"</span> }<!-- -->, <span class="lg-highlight-string">"status"</span>: <span class="lg-highlight-string">"A"</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"item"</span>: <span class="lg-highlight-string">"mousepad"</span>, <span class="lg-highlight-string">"qty"</span>: <span class="lg-highlight-number">25</span>, <span class="lg-highlight-string">"size"</span>: <!-- -->{ <span class="lg-highlight-string">"h"</span>: <span class="lg-highlight-number">19</span>, <span class="lg-highlight-string">"w"</span>: <span class="lg-highlight-number">22.85</span>, <span class="lg-highlight-string">"uom"</span>: <span class="lg-highlight-string">"cm"</span> }<!-- -->, <span class="lg-highlight-string">"status"</span>: <span class="lg-highlight-string">"P"</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"item"</span>: <span class="lg-highlight-string">"notebook"</span>, <span class="lg-highlight-string">"qty"</span>: <span class="lg-highlight-number">50</span>, <span class="lg-highlight-string">"size"</span>: <!-- -->{ <span class="lg-highlight-string">"h"</span>: <span class="lg-highlight-number">8.5</span>, <span class="lg-highlight-string">"w"</span>: <span class="lg-highlight-number">11</span>, <span class="lg-highlight-string">"uom"</span>: <span class="lg-highlight-string">"in"</span> }<!-- -->, <span class="lg-highlight-string">"status"</span>: <span class="lg-highlight-string">"P"</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"item"</span>: <span class="lg-highlight-string">"paper"</span>, <span class="lg-highlight-string">"qty"</span>: <span class="lg-highlight-number">100</span>, <span class="lg-highlight-string">"size"</span>: <!-- -->{ <span class="lg-highlight-string">"h"</span>: <span class="lg-highlight-number">8.5</span>, <span class="lg-highlight-string">"w"</span>: <span class="lg-highlight-number">11</span>, <span class="lg-highlight-string">"uom"</span>: <span class="lg-highlight-string">"in"</span> }<!-- -->, <span class="lg-highlight-string">"status"</span>: <span class="lg-highlight-string">"D"</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"item"</span>: <span class="lg-highlight-string">"planner"</span>, <span class="lg-highlight-string">"qty"</span>: <span class="lg-highlight-number">75</span>, <span class="lg-highlight-string">"size"</span>: <!-- -->{ <span class="lg-highlight-string">"h"</span>: <span class="lg-highlight-number">22.85</span>, <span class="lg-highlight-string">"w"</span>: <span class="lg-highlight-number">30</span>, <span class="lg-highlight-string">"uom"</span>: <span class="lg-highlight-string">"cm"</span> }<!-- -->, <span class="lg-highlight-string">"status"</span>: <span class="lg-highlight-string">"D"</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"item"</span>: <span class="lg-highlight-string">"postcard"</span>, <span class="lg-highlight-string">"qty"</span>: <span class="lg-highlight-number">45</span>, <span class="lg-highlight-string">"size"</span>: <!-- -->{ <span class="lg-highlight-string">"h"</span>: <span class="lg-highlight-number">10</span>, <span class="lg-highlight-string">"w"</span>: <span class="lg-highlight-number">15.25</span>, <span class="lg-highlight-string">"uom"</span>: <span class="lg-highlight-string">"cm"</span> }<!-- -->, <span class="lg-highlight-string">"status"</span>: <span class="lg-highlight-string">"A"</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"item"</span>: <span class="lg-highlight-string">"sketchbook"</span>, <span class="lg-highlight-string">"qty"</span>: <span class="lg-highlight-number">80</span>, <span class="lg-highlight-string">"size"</span>: <!-- -->{ <span class="lg-highlight-string">"h"</span>: <span class="lg-highlight-number">14</span>, <span class="lg-highlight-string">"w"</span>: <span class="lg-highlight-number">21</span>, <span class="lg-highlight-string">"uom"</span>: <span class="lg-highlight-string">"cm"</span> }<!-- -->, <span class="lg-highlight-string">"status"</span>: <span class="lg-highlight-string">"A"</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"item"</span>: <span class="lg-highlight-string">"sketch pad"</span>, <span class="lg-highlight-string">"qty"</span>: <span class="lg-highlight-number">95</span>, <span class="lg-highlight-string">"size"</span>: <!-- -->{ <span class="lg-highlight-string">"h"</span>: <span class="lg-highlight-number">22.85</span>, <span class="lg-highlight-string">"w"</span>: <span class="lg-highlight-number">30.5</span>, <span class="lg-highlight-string">"uom"</span>: <span class="lg-highlight-string">"cm"</span> }<!-- -->, <span class="lg-highlight-string">"status"</span>: <span class="lg-highlight-string">"A"</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">]</td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-119-menu" aria-describedby="select-119-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-120" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:r8f:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":r8f:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r8f:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r8f:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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"> For instructions on inserting documents using <!-- --> MongoDB Compass <!-- --> , see <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-write-op-insert" target="_self"> <span> Insert Documents <!-- --> . </span> </a> </p> </div> </div> </div> <div> <div aria-labelledby="_mcaoyaqqw" class="leafygreen-ui-38lglc" id="_mezffv6wm" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"mongoc_collection_t *collection;\nmongoc_bulk_operation_t *bulk;\nbson_t *doc;\nbool r;\nbson_error_t error;\nbson_t reply;\n\ncollection = mongoc_database_get_collection (db, \"inventory\");\nbulk = mongoc_collection_create_bulk_operation_with_opts (collection, NULL);\ndoc = BCON_NEW (\n \"item\", BCON_UTF8 (\"journal\"),\n \"qty\", BCON_INT64 (25),\n \"tags\", \"[\",\n BCON_UTF8 (\"blank\"), BCON_UTF8 (\"red\"),\n \"]\",\n \"size\", \"{\",\n \"h\", BCON_DOUBLE (14),\n \"w\", BCON_DOUBLE (21),\n \"uom\", BCON_UTF8 (\"cm\"),\n \"}\");\n\nr = mongoc_bulk_operation_insert_with_opts (bulk, doc, NULL, &amp;error);\nbson_destroy (doc);\nif (!r) {\n MONGOC_ERROR (\"%s\\n\", error.message);\n goto done;\n}\n\ndoc = BCON_NEW (\n \"item\", BCON_UTF8 (\"mat\"),\n \"qty\", BCON_INT64 (85),\n \"tags\", \"[\",\n BCON_UTF8 (\"gray\"),\n \"]\",\n \"size\", \"{\",\n \"h\", BCON_DOUBLE (27.9),\n \"w\", BCON_DOUBLE (35.5),\n \"uom\", BCON_UTF8 (\"cm\"),\n \"}\");\n\nr = mongoc_bulk_operation_insert_with_opts (bulk, doc, NULL, &amp;error);\nbson_destroy (doc);\nif (!r) {\n MONGOC_ERROR (\"%s\\n\", error.message);\n goto done;\n}\n\ndoc = BCON_NEW (\n \"item\", BCON_UTF8 (\"mousepad\"),\n \"qty\", BCON_INT64 (25),\n \"tags\", \"[\",\n BCON_UTF8 (\"gel\"), BCON_UTF8 (\"blue\"),\n \"]\",\n \"size\", \"{\",\n \"h\", BCON_DOUBLE (19),\n \"w\", BCON_DOUBLE (22.85),\n \"uom\", BCON_UTF8 (\"cm\"),\n \"}\");\n\nr = mongoc_bulk_operation_insert_with_opts (bulk, doc, NULL, &amp;error);\nbson_destroy (doc);\nif (!r) {\n MONGOC_ERROR (\"%s\\n\", error.message);\n goto done;\n}\n\n/* \"reply\" is initialized on success or error */\nr = (bool) mongoc_bulk_operation_execute (bulk, &amp;reply, &amp;error);\nif (!r) {\n MONGOC_ERROR (\"%s\\n\", error.message);\n}","programmingLanguage":"C"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <pre class="leafygreen-ui-11itue3" 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">mongoc_collection_t *collection;</td></tr><tr class=""><td class="leafygreen-ui-7razhx">mongoc_bulk_operation_t *bulk;</td></tr><tr class=""><td class="leafygreen-ui-7razhx">bson_t *doc;</td></tr><tr class=""><td class="leafygreen-ui-7razhx">bool r;</td></tr><tr class=""><td class="leafygreen-ui-7razhx">bson_error_t error;</td></tr><tr class=""><td class="leafygreen-ui-7razhx">bson_t reply;</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><div class="leafygreen-ui-ihxujy"></div></td></tr><tr class=""><td class="leafygreen-ui-7razhx">collection <!-- -->= <!-- -->mongoc_database_get_collection (db<!-- -->, <span class="lg-highlight-string">"inventory"</span>);</td></tr><tr class=""><td class="leafygreen-ui-7razhx">bulk <!-- -->= <!-- -->mongoc_collection_create_bulk_operation_with_opts (collection<!-- -->, <span class="lg-highlight-variable lg-highlight-constant">NULL</span>);</td></tr><tr class=""><td class="leafygreen-ui-7razhx">doc <!-- -->= <!-- --><span class="lg-highlight-variable lg-highlight-constant">BCON_NEW</span> (</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"item"</span>, <!-- --><span class="lg-highlight-variable lg-highlight-constant">BCON_UTF8</span> (<!-- --><span class="lg-highlight-string">"journal"</span>),</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"qty"</span>, <!-- --><span class="lg-highlight-variable lg-highlight-constant">BCON_INT64</span> (<!-- --><span class="lg-highlight-number">25</span>),</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"tags"</span>, <span class="lg-highlight-string">"["</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- --><span class="lg-highlight-variable lg-highlight-constant">BCON_UTF8</span> (<!-- --><!-- --><span class="lg-highlight-string">"blank"</span>)<!-- -->, <span class="lg-highlight-variable lg-highlight-constant">BCON_UTF8</span> (<span class="lg-highlight-string">"red"</span>),</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"]"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"size"</span>, <span class="lg-highlight-string">"{"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"h"</span>, <!-- --><span class="lg-highlight-variable lg-highlight-constant">BCON_DOUBLE</span> (<!-- --><span class="lg-highlight-number">14</span>),</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"w"</span>, <!-- --><span class="lg-highlight-variable lg-highlight-constant">BCON_DOUBLE</span> (<!-- --><span class="lg-highlight-number">21</span>),</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"uom"</span>, <!-- --><span class="lg-highlight-variable lg-highlight-constant">BCON_UTF8</span> (<!-- --><span class="lg-highlight-string">"cm"</span>),</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"}"</span>)<!-- -->;</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><div class="leafygreen-ui-ihxujy"></div></td></tr><tr class=""><td class="leafygreen-ui-7razhx">r <!-- -->= <!-- -->mongoc_bulk_operation_insert_with_opts (bulk<!-- -->, doc, <span class="lg-highlight-variable lg-highlight-constant">NULL</span>, &amp;error);</td></tr><tr class=""><td class="leafygreen-ui-7razhx">bson_destroy <!-- -->(<!-- -->doc);</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-keyword">if</span> <!-- -->(<!-- -->!r) {</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- --><span class="lg-highlight-variable lg-highlight-constant">MONGOC_ERROR</span> (<span class="lg-highlight-string">"%s</span><!-- --><span class="lg-highlight-string">\n</span><span class="lg-highlight-string">"</span>, error.<span class="lg-highlight-property">message</span>);</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> goto done;</td></tr><tr class=""><td class="leafygreen-ui-7razhx">}</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><div class="leafygreen-ui-ihxujy"></div></td></tr><tr class=""><td class="leafygreen-ui-7razhx">doc <!-- -->= <!-- --><span class="lg-highlight-variable lg-highlight-constant">BCON_NEW</span> (</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"item"</span>, <!-- --><span class="lg-highlight-variable lg-highlight-constant">BCON_UTF8</span> (<!-- --><span class="lg-highlight-string">"mat"</span>),</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"qty"</span>, <!-- --><span class="lg-highlight-variable lg-highlight-constant">BCON_INT64</span> (<!-- --><span class="lg-highlight-number">85</span>),</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"tags"</span>, <span class="lg-highlight-string">"["</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- --><span class="lg-highlight-variable lg-highlight-constant">BCON_UTF8</span> (<!-- --><span class="lg-highlight-string">"gray"</span>),</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"]"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"size"</span>, <span class="lg-highlight-string">"{"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"h"</span>, <!-- --><span class="lg-highlight-variable lg-highlight-constant">BCON_DOUBLE</span> (<!-- --><span class="lg-highlight-number">27.9</span>),</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"w"</span>, <!-- --><span class="lg-highlight-variable lg-highlight-constant">BCON_DOUBLE</span> (<!-- --><span class="lg-highlight-number">35.5</span>),</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"uom"</span>, <!-- --><span class="lg-highlight-variable lg-highlight-constant">BCON_UTF8</span> (<!-- --><span class="lg-highlight-string">"cm"</span>),</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"}"</span>)<!-- -->;</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><div class="leafygreen-ui-ihxujy"></div></td></tr><tr class=""><td class="leafygreen-ui-7razhx">r <!-- -->= <!-- -->mongoc_bulk_operation_insert_with_opts (bulk<!-- -->, doc, <span class="lg-highlight-variable lg-highlight-constant">NULL</span>, &amp;error);</td></tr><tr class=""><td class="leafygreen-ui-7razhx">bson_destroy <!-- -->(<!-- -->doc);</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-keyword">if</span> <!-- -->(<!-- -->!r) {</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- --><span class="lg-highlight-variable lg-highlight-constant">MONGOC_ERROR</span> (<span class="lg-highlight-string">"%s</span><!-- --><span class="lg-highlight-string">\n</span><span class="lg-highlight-string">"</span>, error.<span class="lg-highlight-property">message</span>);</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> goto done;</td></tr><tr class=""><td class="leafygreen-ui-7razhx">}</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><div class="leafygreen-ui-ihxujy"></div></td></tr><tr class=""><td class="leafygreen-ui-7razhx">doc <!-- -->= <!-- --><span class="lg-highlight-variable lg-highlight-constant">BCON_NEW</span> (</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"item"</span>, <!-- --><span class="lg-highlight-variable lg-highlight-constant">BCON_UTF8</span> (<!-- --><span class="lg-highlight-string">"mousepad"</span>),</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"qty"</span>, <!-- --><span class="lg-highlight-variable lg-highlight-constant">BCON_INT64</span> (<!-- --><span class="lg-highlight-number">25</span>),</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"tags"</span>, <span class="lg-highlight-string">"["</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- --><span class="lg-highlight-variable lg-highlight-constant">BCON_UTF8</span> (<!-- --><!-- --><span class="lg-highlight-string">"gel"</span>)<!-- -->, <span class="lg-highlight-variable lg-highlight-constant">BCON_UTF8</span> (<span class="lg-highlight-string">"blue"</span>),</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"]"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"size"</span>, <span class="lg-highlight-string">"{"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"h"</span>, <!-- --><span class="lg-highlight-variable lg-highlight-constant">BCON_DOUBLE</span> (<!-- --><span class="lg-highlight-number">19</span>),</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"w"</span>, <!-- --><span class="lg-highlight-variable lg-highlight-constant">BCON_DOUBLE</span> (<!-- --><span class="lg-highlight-number">22.85</span>),</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"uom"</span>, <!-- --><span class="lg-highlight-variable lg-highlight-constant">BCON_UTF8</span> (<!-- --><span class="lg-highlight-string">"cm"</span>),</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"}"</span>)<!-- -->;</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><div class="leafygreen-ui-ihxujy"></div></td></tr><tr class=""><td class="leafygreen-ui-7razhx">r <!-- -->= <!-- -->mongoc_bulk_operation_insert_with_opts (bulk<!-- -->, doc, <span class="lg-highlight-variable lg-highlight-constant">NULL</span>, &amp;error);</td></tr><tr class=""><td class="leafygreen-ui-7razhx">bson_destroy <!-- -->(<!-- -->doc);</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-keyword">if</span> <!-- -->(<!-- -->!r) {</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- --><span class="lg-highlight-variable lg-highlight-constant">MONGOC_ERROR</span> (<span class="lg-highlight-string">"%s</span><!-- --><span class="lg-highlight-string">\n</span><span class="lg-highlight-string">"</span>, error.<span class="lg-highlight-property">message</span>);</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> goto done;</td></tr><tr class=""><td class="leafygreen-ui-7razhx">}</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><div class="leafygreen-ui-ihxujy"></div></td></tr><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-comment">/* "reply"</span><span class="lg-highlight-comment"> is initialized on </span><span class="lg-highlight-comment">success or error */</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx">r <!-- -->= <!-- -->(bool) mongoc_bulk_operation_execute (<!-- -->bulk<!-- -->, <!-- -->&amp;reply, &amp;error);</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-keyword">if</span> <!-- -->(<!-- -->!r) {</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- --><span class="lg-highlight-variable lg-highlight-constant">MONGOC_ERROR</span> (<span class="lg-highlight-string">"%s</span><!-- --><span class="lg-highlight-string">\n</span><span class="lg-highlight-string">"</span>, error.<span class="lg-highlight-property">message</span>);</td></tr><tr class=""><td class="leafygreen-ui-7razhx">}</td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-122-menu" aria-describedby="select-122-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-123" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:r8g:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":r8g:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r8g:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r8g:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_nihb3dbuc" class="leafygreen-ui-38lglc" id="_tkpdhy6il" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"var documents = new BsonDocument[]\n{\n new BsonDocument\n {\n { \"item\", \"journal\" },\n { \"qty\", 25 },\n { \"tags\", new BsonArray { \"blank\", \"red\" } },\n { \"size\", new BsonDocument { { \"h\", 14 }, { \"w\", 21 }, { \"uom\", \"cm\"} } }\n },\n new BsonDocument\n {\n { \"item\", \"mat\" },\n { \"qty\", 85 },\n { \"tags\", new BsonArray { \"gray\" } },\n { \"size\", new BsonDocument { { \"h\", 27.9 }, { \"w\", 35.5 }, { \"uom\", \"cm\"} } }\n },\n new BsonDocument\n {\n { \"item\", \"mousepad\" },\n { \"qty\", 25 },\n { \"tags\", new BsonArray { \"gel\", \"blue\" } },\n { \"size\", new BsonDocument { { \"h\", 19 }, { \"w\", 22.85 }, { \"uom\", \"cm\"} } }\n },\n};\ncollection.InsertMany(documents);","programmingLanguage":"C#"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <pre class="leafygreen-ui-11itue3" 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"><span class="lg-highlight-keyword">var</span> documents = <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">BsonDocument</span>[]</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">BsonDocument</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> {</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> { <span class="lg-highlight-string">"item"</span>, <span class="lg-highlight-string">"journal"</span> },</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> { <span class="lg-highlight-string">"qty"</span>, <span class="lg-highlight-number">25</span> },</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> { <span class="lg-highlight-string">"tags"</span>, <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">BsonArray</span> { <span class="lg-highlight-string">"blank"</span>, <span class="lg-highlight-string">"red"</span> } },</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> { <span class="lg-highlight-string">"size"</span>, <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">BsonDocument</span> { { <span class="lg-highlight-string">"h"</span>, <span class="lg-highlight-number">14</span> }, { <span class="lg-highlight-string">"w"</span>, <span class="lg-highlight-number">21</span> }, { <span class="lg-highlight-string">"uom"</span>, <span class="lg-highlight-string">"cm"</span>} } }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> },</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">BsonDocument</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> {</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> { <span class="lg-highlight-string">"item"</span>, <span class="lg-highlight-string">"mat"</span> },</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> { <span class="lg-highlight-string">"qty"</span>, <span class="lg-highlight-number">85</span> },</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> { <span class="lg-highlight-string">"tags"</span>, <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">BsonArray</span> { <span class="lg-highlight-string">"gray"</span> } },</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> { <span class="lg-highlight-string">"size"</span>, <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">BsonDocument</span> { { <span class="lg-highlight-string">"h"</span>, <span class="lg-highlight-number">27.9</span> }, { <span class="lg-highlight-string">"w"</span>, <span class="lg-highlight-number">35.5</span> }, { <span class="lg-highlight-string">"uom"</span>, <span class="lg-highlight-string">"cm"</span>} } }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> },</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">BsonDocument</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> {</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> { <span class="lg-highlight-string">"item"</span>, <span class="lg-highlight-string">"mousepad"</span> },</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> { <span class="lg-highlight-string">"qty"</span>, <span class="lg-highlight-number">25</span> },</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> { <span class="lg-highlight-string">"tags"</span>, <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">BsonArray</span> { <span class="lg-highlight-string">"gel"</span>, <span class="lg-highlight-string">"blue"</span> } },</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> { <span class="lg-highlight-string">"size"</span>, <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">BsonDocument</span> { { <span class="lg-highlight-string">"h"</span>, <span class="lg-highlight-number">19</span> }, { <span class="lg-highlight-string">"w"</span>, <span class="lg-highlight-number">22.85</span> }, { <span class="lg-highlight-string">"uom"</span>, <span class="lg-highlight-string">"cm"</span>} } }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> },</td></tr><tr class=""><td class="leafygreen-ui-7razhx">};</td></tr><tr class=""><td class="leafygreen-ui-7razhx">collection.<span class="lg-highlight-title lg-highlight-class">InsertMany</span>(documents);</td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-125-menu" aria-describedby="select-125-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-126" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:r8h:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":r8h:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r8h:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r8h:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_1j1gal2zj" class="leafygreen-ui-38lglc" id="_41nr6g6tv" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"\nresult, err := coll.InsertMany(\n\tcontext.TODO(),\n\t[]interface{}{\n\t\tbson.D{\n\t\t\t{\"item\", \"journal\"},\n\t\t\t{\"qty\", int32(25)},\n\t\t\t{\"tags\", bson.A{\"blank\", \"red\"}},\n\t\t\t{\"size\", bson.D{\n\t\t\t\t{\"h\", 14},\n\t\t\t\t{\"w\", 21},\n\t\t\t\t{\"uom\", \"cm\"},\n\t\t\t}},\n\t\t},\n\t\tbson.D{\n\t\t\t{\"item\", \"mat\"},\n\t\t\t{\"qty\", int32(25)},\n\t\t\t{\"tags\", bson.A{\"gray\"}},\n\t\t\t{\"size\", bson.D{\n\t\t\t\t{\"h\", 27.9},\n\t\t\t\t{\"w\", 35.5},\n\t\t\t\t{\"uom\", \"cm\"},\n\t\t\t}},\n\t\t},\n\t\tbson.D{\n\t\t\t{\"item\", \"mousepad\"},\n\t\t\t{\"qty\", 25},\n\t\t\t{\"tags\", bson.A{\"gel\", \"blue\"}},\n\t\t\t{\"size\", bson.D{\n\t\t\t\t{\"h\", 19},\n\t\t\t\t{\"w\", 22.85},\n\t\t\t\t{\"uom\", \"cm\"},\n\t\t\t}},\n\t\t},\n\t})\n","programmingLanguage":"Golang"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <pre class="leafygreen-ui-11itue3" 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">result<!-- -->, <!-- -->err := coll.<span class="lg-highlight-title lg-highlight-class">InsertMany</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> context.<span class="lg-highlight-title lg-highlight-function">TODO</span>(),</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> []interface{}{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> bson.<span class="lg-highlight-property">D</span>{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> {<span class="lg-highlight-string">"item"</span>, <span class="lg-highlight-string">"journal"</span>},</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> {<span class="lg-highlight-string">"qty"</span>, <span class="lg-highlight-title lg-highlight-function">int32</span>(<span class="lg-highlight-number">25</span>)},</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> {<span class="lg-highlight-string">"tags"</span>, bson.<span class="lg-highlight-property">A</span>{<span class="lg-highlight-string">"blank"</span>, <span class="lg-highlight-string">"red"</span>}},</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> {<span class="lg-highlight-string">"size"</span>, bson.<span class="lg-highlight-property">D</span>{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> {<span class="lg-highlight-string">"h"</span>, <span class="lg-highlight-number">14</span>},</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> {<span class="lg-highlight-string">"w"</span>, <span class="lg-highlight-number">21</span>},</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> {<span class="lg-highlight-string">"uom"</span>, <span class="lg-highlight-string">"cm"</span>},</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }},</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> },</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> bson.<span class="lg-highlight-property">D</span>{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> {<span class="lg-highlight-string">"item"</span>, <span class="lg-highlight-string">"mat"</span>},</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> {<span class="lg-highlight-string">"qty"</span>, <span class="lg-highlight-title lg-highlight-function">int32</span>(<span class="lg-highlight-number">25</span>)},</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> {<span class="lg-highlight-string">"tags"</span>, bson.<span class="lg-highlight-property">A</span>{<span class="lg-highlight-string">"gray"</span>}},</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> {<span class="lg-highlight-string">"size"</span>, bson.<span class="lg-highlight-property">D</span>{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> {<span class="lg-highlight-string">"h"</span>, <span class="lg-highlight-number">27.9</span>},</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> {<span class="lg-highlight-string">"w"</span>, <span class="lg-highlight-number">35.5</span>},</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> {<span class="lg-highlight-string">"uom"</span>, <span class="lg-highlight-string">"cm"</span>},</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }},</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> },</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> bson.<span class="lg-highlight-property">D</span>{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> {<span class="lg-highlight-string">"item"</span>, <span class="lg-highlight-string">"mousepad"</span>},</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> {<span class="lg-highlight-string">"qty"</span>, <span class="lg-highlight-number">25</span>},</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> {<span class="lg-highlight-string">"tags"</span>, bson.<span class="lg-highlight-property">A</span>{<span class="lg-highlight-string">"gel"</span>, <span class="lg-highlight-string">"blue"</span>}},</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> {<span class="lg-highlight-string">"size"</span>, bson.<span class="lg-highlight-property">D</span>{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> {<span class="lg-highlight-string">"h"</span>, <span class="lg-highlight-number">19</span>},</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> {<span class="lg-highlight-string">"w"</span>, <span class="lg-highlight-number">22.85</span>},</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> {<span class="lg-highlight-string">"uom"</span>, <span class="lg-highlight-string">"cm"</span>},</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }},</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> },</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> })</td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-128-menu" aria-describedby="select-128-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-129" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:r8i:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":r8i:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r8i:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r8i:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_sqjjwb0rl" class="leafygreen-ui-38lglc" id="_l0ti4wv0b" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"Document journal = new Document(\"item\", \"journal\")\n .append(\"qty\", 25)\n .append(\"tags\", asList(\"blank\", \"red\"));\n\nDocument journalSize = new Document(\"h\", 14)\n .append(\"w\", 21)\n .append(\"uom\", \"cm\");\njournal.put(\"size\", journalSize);\n\nDocument mat = new Document(\"item\", \"mat\")\n .append(\"qty\", 85)\n .append(\"tags\", singletonList(\"gray\"));\n\nDocument matSize = new Document(\"h\", 27.9)\n .append(\"w\", 35.5)\n .append(\"uom\", \"cm\");\nmat.put(\"size\", matSize);\n\nDocument mousePad = new Document(\"item\", \"mousePad\")\n .append(\"qty\", 25)\n .append(\"tags\", asList(\"gel\", \"blue\"));\n\nDocument mousePadSize = new Document(\"h\", 19)\n .append(\"w\", 22.85)\n .append(\"uom\", \"cm\");\nmousePad.put(\"size\", mousePadSize);\n\nPublisher&lt;success&gt; insertManyPublisher = collection.insertMany(asList(journal, mat, mousePad));","programmingLanguage":"Java"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <pre class="leafygreen-ui-11itue3" 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"><span class="lg-highlight-title lg-highlight-class">Document</span> journal = <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">Document</span>(<span class="lg-highlight-string">"item"</span>, <span class="lg-highlight-string">"journal"</span>)</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> .<span class="lg-highlight-title lg-highlight-function">append</span>(<span class="lg-highlight-string">"qty"</span>, <span class="lg-highlight-number">25</span>)</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> .<span class="lg-highlight-title lg-highlight-function">append</span>(<span class="lg-highlight-string">"tags"</span>, <span class="lg-highlight-title lg-highlight-function">asList</span>(<span class="lg-highlight-string">"blank"</span>, <span class="lg-highlight-string">"red"</span>));</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><div class="leafygreen-ui-ihxujy"></div></td></tr><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-title lg-highlight-class">Document</span> journalSize = <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">Document</span>(<span class="lg-highlight-string">"h"</span>, <span class="lg-highlight-number">14</span>)</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> .<span class="lg-highlight-title lg-highlight-function">append</span>(<span class="lg-highlight-string">"w"</span>, <span class="lg-highlight-number">21</span>)</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> .<span class="lg-highlight-title lg-highlight-function">append</span>(<span class="lg-highlight-string">"uom"</span>, <span class="lg-highlight-string">"cm"</span>);</td></tr><tr class=""><td class="leafygreen-ui-7razhx">journal.<span class="lg-highlight-title lg-highlight-function">put</span>(<span class="lg-highlight-string">"size"</span>, journalSize);</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><div class="leafygreen-ui-ihxujy"></div></td></tr><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-title lg-highlight-class">Document</span> mat = <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">Document</span>(<span class="lg-highlight-string">"item"</span>, <span class="lg-highlight-string">"mat"</span>)</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> .<span class="lg-highlight-title lg-highlight-function">append</span>(<span class="lg-highlight-string">"qty"</span>, <span class="lg-highlight-number">85</span>)</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> .<span class="lg-highlight-title lg-highlight-function">append</span>(<span class="lg-highlight-string">"tags"</span>, <span class="lg-highlight-title lg-highlight-function">singletonList</span>(<span class="lg-highlight-string">"gray"</span>));</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><div class="leafygreen-ui-ihxujy"></div></td></tr><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-title lg-highlight-class">Document</span> matSize = <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">Document</span>(<span class="lg-highlight-string">"h"</span>, <span class="lg-highlight-number">27.9</span>)</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> .<span class="lg-highlight-title lg-highlight-function">append</span>(<span class="lg-highlight-string">"w"</span>, <span class="lg-highlight-number">35.5</span>)</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> .<span class="lg-highlight-title lg-highlight-function">append</span>(<span class="lg-highlight-string">"uom"</span>, <span class="lg-highlight-string">"cm"</span>);</td></tr><tr class=""><td class="leafygreen-ui-7razhx">mat.<span class="lg-highlight-title lg-highlight-function">put</span>(<span class="lg-highlight-string">"size"</span>, matSize);</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><div class="leafygreen-ui-ihxujy"></div></td></tr><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-title lg-highlight-class">Document</span> mousePad = <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">Document</span>(<span class="lg-highlight-string">"item"</span>, <span class="lg-highlight-string">"mousePad"</span>)</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> .<span class="lg-highlight-title lg-highlight-function">append</span>(<span class="lg-highlight-string">"qty"</span>, <span class="lg-highlight-number">25</span>)</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> .<span class="lg-highlight-title lg-highlight-function">append</span>(<span class="lg-highlight-string">"tags"</span>, <span class="lg-highlight-title lg-highlight-function">asList</span>(<span class="lg-highlight-string">"gel"</span>, <span class="lg-highlight-string">"blue"</span>));</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><div class="leafygreen-ui-ihxujy"></div></td></tr><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-title lg-highlight-class">Document</span> mousePadSize = <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">Document</span>(<span class="lg-highlight-string">"h"</span>, <span class="lg-highlight-number">19</span>)</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> .<span class="lg-highlight-title lg-highlight-function">append</span>(<span class="lg-highlight-string">"w"</span>, <span class="lg-highlight-number">22.85</span>)</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> .<span class="lg-highlight-title lg-highlight-function">append</span>(<span class="lg-highlight-string">"uom"</span>, <span class="lg-highlight-string">"cm"</span>);</td></tr><tr class=""><td class="leafygreen-ui-7razhx">mousePad.<span class="lg-highlight-title lg-highlight-function">put</span>(<span class="lg-highlight-string">"size"</span>, mousePadSize);</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><div class="leafygreen-ui-ihxujy"></div></td></tr><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-title lg-highlight-class">Publisher</span>&lt;<span class="lg-highlight-title lg-highlight-class">Success</span>&gt; insertManyPublisher = collection.<span class="lg-highlight-title lg-highlight-function">insertMany</span>(<span class="lg-highlight-title lg-highlight-function">asList</span>(journal, mat, mousePad));</td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-131-menu" aria-describedby="select-131-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-132" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:r8j:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":r8j:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r8j:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r8j:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_hqw7u2dtz" class="leafygreen-ui-38lglc" id="_m8lfo6aic" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"Document journal = new Document(\"item\", \"journal\")\n .append(\"qty\", 25)\n .append(\"tags\", asList(\"blank\", \"red\"));\n\nDocument journalSize = new Document(\"h\", 14)\n .append(\"w\", 21)\n .append(\"uom\", \"cm\");\njournal.put(\"size\", journalSize);\n\nDocument mat = new Document(\"item\", \"mat\")\n .append(\"qty\", 85)\n .append(\"tags\", singletonList(\"gray\"));\n\nDocument matSize = new Document(\"h\", 27.9)\n .append(\"w\", 35.5)\n .append(\"uom\", \"cm\");\nmat.put(\"size\", matSize);\n\nDocument mousePad = new Document(\"item\", \"mousePad\")\n .append(\"qty\", 25)\n .append(\"tags\", asList(\"gel\", \"blue\"));\n\nDocument mousePadSize = new Document(\"h\", 19)\n .append(\"w\", 22.85)\n .append(\"uom\", \"cm\");\nmousePad.put(\"size\", mousePadSize);\n\ncollection.insertMany(asList(journal, mat, mousePad));","programmingLanguage":"Java"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <pre class="leafygreen-ui-11itue3" 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"><span class="lg-highlight-title lg-highlight-class">Document</span> journal = <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">Document</span>(<span class="lg-highlight-string">"item"</span>, <span class="lg-highlight-string">"journal"</span>)</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> .<span class="lg-highlight-title lg-highlight-function">append</span>(<span class="lg-highlight-string">"qty"</span>, <span class="lg-highlight-number">25</span>)</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> .<span class="lg-highlight-title lg-highlight-function">append</span>(<span class="lg-highlight-string">"tags"</span>, <span class="lg-highlight-title lg-highlight-function">asList</span>(<span class="lg-highlight-string">"blank"</span>, <span class="lg-highlight-string">"red"</span>));</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><div class="leafygreen-ui-ihxujy"></div></td></tr><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-title lg-highlight-class">Document</span> journalSize = <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">Document</span>(<span class="lg-highlight-string">"h"</span>, <span class="lg-highlight-number">14</span>)</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> .<span class="lg-highlight-title lg-highlight-function">append</span>(<span class="lg-highlight-string">"w"</span>, <span class="lg-highlight-number">21</span>)</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> .<span class="lg-highlight-title lg-highlight-function">append</span>(<span class="lg-highlight-string">"uom"</span>, <span class="lg-highlight-string">"cm"</span>);</td></tr><tr class=""><td class="leafygreen-ui-7razhx">journal.<span class="lg-highlight-title lg-highlight-function">put</span>(<span class="lg-highlight-string">"size"</span>, journalSize);</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><div class="leafygreen-ui-ihxujy"></div></td></tr><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-title lg-highlight-class">Document</span> mat = <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">Document</span>(<span class="lg-highlight-string">"item"</span>, <span class="lg-highlight-string">"mat"</span>)</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> .<span class="lg-highlight-title lg-highlight-function">append</span>(<span class="lg-highlight-string">"qty"</span>, <span class="lg-highlight-number">85</span>)</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> .<span class="lg-highlight-title lg-highlight-function">append</span>(<span class="lg-highlight-string">"tags"</span>, <span class="lg-highlight-title lg-highlight-function">singletonList</span>(<span class="lg-highlight-string">"gray"</span>));</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><div class="leafygreen-ui-ihxujy"></div></td></tr><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-title lg-highlight-class">Document</span> matSize = <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">Document</span>(<span class="lg-highlight-string">"h"</span>, <span class="lg-highlight-number">27.9</span>)</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> .<span class="lg-highlight-title lg-highlight-function">append</span>(<span class="lg-highlight-string">"w"</span>, <span class="lg-highlight-number">35.5</span>)</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> .<span class="lg-highlight-title lg-highlight-function">append</span>(<span class="lg-highlight-string">"uom"</span>, <span class="lg-highlight-string">"cm"</span>);</td></tr><tr class=""><td class="leafygreen-ui-7razhx">mat.<span class="lg-highlight-title lg-highlight-function">put</span>(<span class="lg-highlight-string">"size"</span>, matSize);</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><div class="leafygreen-ui-ihxujy"></div></td></tr><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-title lg-highlight-class">Document</span> mousePad = <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">Document</span>(<span class="lg-highlight-string">"item"</span>, <span class="lg-highlight-string">"mousePad"</span>)</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> .<span class="lg-highlight-title lg-highlight-function">append</span>(<span class="lg-highlight-string">"qty"</span>, <span class="lg-highlight-number">25</span>)</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> .<span class="lg-highlight-title lg-highlight-function">append</span>(<span class="lg-highlight-string">"tags"</span>, <span class="lg-highlight-title lg-highlight-function">asList</span>(<span class="lg-highlight-string">"gel"</span>, <span class="lg-highlight-string">"blue"</span>));</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><div class="leafygreen-ui-ihxujy"></div></td></tr><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-title lg-highlight-class">Document</span> mousePadSize = <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">Document</span>(<span class="lg-highlight-string">"h"</span>, <span class="lg-highlight-number">19</span>)</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> .<span class="lg-highlight-title lg-highlight-function">append</span>(<span class="lg-highlight-string">"w"</span>, <span class="lg-highlight-number">22.85</span>)</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> .<span class="lg-highlight-title lg-highlight-function">append</span>(<span class="lg-highlight-string">"uom"</span>, <span class="lg-highlight-string">"cm"</span>);</td></tr><tr class=""><td class="leafygreen-ui-7razhx">mousePad.<span class="lg-highlight-title lg-highlight-function">put</span>(<span class="lg-highlight-string">"size"</span>, mousePadSize);</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><div class="leafygreen-ui-ihxujy"></div></td></tr><tr class=""><td class="leafygreen-ui-7razhx">collection.<span class="lg-highlight-title lg-highlight-function">insertMany</span>(<span class="lg-highlight-title lg-highlight-function">asList</span>(journal, mat, mousePad));</td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-134-menu" aria-describedby="select-134-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-135" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:r8k:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":r8k:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r8k:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r8k:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_9jvj8pjv1" class="leafygreen-ui-38lglc" id="_3j2958b0i" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"results = collection.insertMany(\nlistOf(\n Document(\"item\", \"journal\")\n .append(\"qty\", 25)\n .append(\"tags\", listOf(\"blank\", \"red\"))\n .append(\"size\", Document(\"h\", 14)\n .append(\"w\", 21)\n .append(\"uom\", \"cm\")\n ),\n Document(\"item\", \"mat\")\n .append(\"qty\", 25)\n .append(\"tags\", listOf(\"gray\"))\n .append(\"size\", Document(\"h\", 27.9)\n .append(\"w\", 35.5)\n .append(\"uom\", \"cm\")\n ),\n Document(\"item\", \"mousepad\")\n .append(\"qty\", 25)\n .append(\"tags\", listOf(\"gel\", \"blue\"))\n .append(\"size\", Document(\"h\", 19)\n .append(\"w\", 22.85)\n .append(\"uom\", \"cm\")\n )\n)\n","programmingLanguage":"Kotlin"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <pre class="leafygreen-ui-11itue3" 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">results = collection.<span class="lg-highlight-title lg-highlight-function">insertMany</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-title lg-highlight-function">listOf</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-title lg-highlight-class">Document</span>(<span class="lg-highlight-string">"item"</span>, <span class="lg-highlight-string">"journal"</span>)</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> .<span class="lg-highlight-title lg-highlight-function">append</span>(<span class="lg-highlight-string">"qty"</span>, <span class="lg-highlight-number">25</span>)</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> .<span class="lg-highlight-title lg-highlight-function">append</span>(<span class="lg-highlight-string">"tags"</span>, <span class="lg-highlight-title lg-highlight-function">listOf</span>(<span class="lg-highlight-string">"blank"</span>, <span class="lg-highlight-string">"red"</span>))</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> .<span class="lg-highlight-title lg-highlight-function">append</span>(<span class="lg-highlight-string">"size"</span>, <span class="lg-highlight-title lg-highlight-class">Document</span>(<span class="lg-highlight-string">"h"</span>, <span class="lg-highlight-number">14</span>)</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> .<span class="lg-highlight-title lg-highlight-function">append</span>(<span class="lg-highlight-string">"w"</span>, <span class="lg-highlight-number">21</span>)</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> .<span class="lg-highlight-title lg-highlight-function">append</span>(<span class="lg-highlight-string">"uom"</span>, <span class="lg-highlight-string">"cm"</span>)</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> ),</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-title lg-highlight-class">Document</span>(<span class="lg-highlight-string">"item"</span>, <span class="lg-highlight-string">"mat"</span>)</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> .<span class="lg-highlight-title lg-highlight-function">append</span>(<span class="lg-highlight-string">"qty"</span>, <span class="lg-highlight-number">25</span>)</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> .<span class="lg-highlight-title lg-highlight-function">append</span>(<span class="lg-highlight-string">"tags"</span>, <span class="lg-highlight-title lg-highlight-function">listOf</span>(<span class="lg-highlight-string">"gray"</span>))</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> .<span class="lg-highlight-title lg-highlight-function">append</span>(<span class="lg-highlight-string">"size"</span>, <span class="lg-highlight-title lg-highlight-class">Document</span>(<span class="lg-highlight-string">"h"</span>, <span class="lg-highlight-number">27.9</span>)</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> .<span class="lg-highlight-title lg-highlight-function">append</span>(<span class="lg-highlight-string">"w"</span>, <span class="lg-highlight-number">35.5</span>)</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> .<span class="lg-highlight-title lg-highlight-function">append</span>(<span class="lg-highlight-string">"uom"</span>, <span class="lg-highlight-string">"cm"</span>)</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> ),</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-title lg-highlight-class">Document</span>(<span class="lg-highlight-string">"item"</span>, <span class="lg-highlight-string">"mousepad"</span>)</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> .<span class="lg-highlight-title lg-highlight-function">append</span>(<span class="lg-highlight-string">"qty"</span>, <span class="lg-highlight-number">25</span>)</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> .<span class="lg-highlight-title lg-highlight-function">append</span>(<span class="lg-highlight-string">"tags"</span>, <span class="lg-highlight-title lg-highlight-function">listOf</span>(<span class="lg-highlight-string">"gel"</span>, <span class="lg-highlight-string">"blue"</span>))</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> .<span class="lg-highlight-title lg-highlight-function">append</span>(<span class="lg-highlight-string">"size"</span>, <span class="lg-highlight-title lg-highlight-class">Document</span>(<span class="lg-highlight-string">"h"</span>, <span class="lg-highlight-number">19</span>)</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> .<span class="lg-highlight-title lg-highlight-function">append</span>(<span class="lg-highlight-string">"w"</span>, <span class="lg-highlight-number">22.85</span>)</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> .<span class="lg-highlight-title lg-highlight-function">append</span>(<span class="lg-highlight-string">"uom"</span>, <span class="lg-highlight-string">"cm"</span>)</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> )</td></tr><tr class=""><td class="leafygreen-ui-7razhx">)</td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-137-menu" aria-describedby="select-137-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-138" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:r8l:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":r8l:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r8l:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r8l:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_03l236b34" class="leafygreen-ui-38lglc" id="_hzm6mswyg" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"await db.inventory.insert_many(\n [\n {\n \"item\": \"journal\",\n \"qty\": 25,\n \"tags\": [\"blank\", \"red\"],\n \"size\": {\"h\": 14, \"w\": 21, \"uom\": \"cm\"},\n },\n {\n \"item\": \"mat\",\n \"qty\": 85,\n \"tags\": [\"gray\"],\n \"size\": {\"h\": 27.9, \"w\": 35.5, \"uom\": \"cm\"},\n },\n {\n \"item\": \"mousepad\",\n \"qty\": 25,\n \"tags\": [\"gel\", \"blue\"],\n \"size\": {\"h\": 19, \"w\": 22.85, \"uom\": \"cm\"},\n },\n ]\n)","programmingLanguage":"Python"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <pre class="leafygreen-ui-11itue3" 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"><span class="lg-highlight-keyword">await</span> db.<span class="lg-highlight-property">inventory</span>.<span class="lg-highlight-title lg-highlight-function">insert_many</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> [</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> {</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"item"</span>: <span class="lg-highlight-string">"journal"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"qty"</span>: <span class="lg-highlight-number">25</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"tags"</span>: [<span class="lg-highlight-string">"blank"</span>, <span class="lg-highlight-string">"red"</span>],</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"size"</span>: {<span class="lg-highlight-string">"h"</span>: <span class="lg-highlight-number">14</span>, <span class="lg-highlight-string">"w"</span>: <span class="lg-highlight-number">21</span>, <span class="lg-highlight-string">"uom"</span>: <span class="lg-highlight-string">"cm"</span>},</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> },</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> {</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"item"</span>: <span class="lg-highlight-string">"mat"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"qty"</span>: <span class="lg-highlight-number">85</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"tags"</span>: [<span class="lg-highlight-string">"gray"</span>],</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"size"</span>: {<span class="lg-highlight-string">"h"</span>: <span class="lg-highlight-number">27.9</span>, <span class="lg-highlight-string">"w"</span>: <span class="lg-highlight-number">35.5</span>, <span class="lg-highlight-string">"uom"</span>: <span class="lg-highlight-string">"cm"</span>},</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> },</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> {</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"item"</span>: <span class="lg-highlight-string">"mousepad"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"qty"</span>: <span class="lg-highlight-number">25</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"tags"</span>: [<span class="lg-highlight-string">"gel"</span>, <span class="lg-highlight-string">"blue"</span>],</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"size"</span>: {<span class="lg-highlight-string">"h"</span>: <span class="lg-highlight-number">19</span>, <span class="lg-highlight-string">"w"</span>: <span class="lg-highlight-number">22.85</span>, <span class="lg-highlight-string">"uom"</span>: <span class="lg-highlight-string">"cm"</span>},</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> },</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> ]</td></tr><tr class=""><td class="leafygreen-ui-7razhx">)</td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-140-menu" aria-describedby="select-140-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-141" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:r8m:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":r8m:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r8m:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r8m:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_teaygud2q" class="" id="_xkp9wf4uo" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"await db.collection('inventory').insertMany([\n {\n item: 'journal',\n qty: 25,\n tags: ['blank', 'red'],\n size: { h: 14, w: 21, uom: 'cm' }\n },\n {\n item: 'mat',\n qty: 85,\n tags: ['gray'],\n size: { h: 27.9, w: 35.5, uom: 'cm' }\n },\n {\n item: 'mousepad',\n qty: 25,\n tags: ['gel', 'blue'],\n size: { h: 19, w: 22.85, uom: 'cm' }\n }\n]);","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <pre class="leafygreen-ui-11itue3" 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"><span class="lg-highlight-keyword">await</span> db.<span class="lg-highlight-title lg-highlight-function">collection</span>(<span class="lg-highlight-string">'inventory'</span>).<span class="lg-highlight-title lg-highlight-function">insertMany</span>(<!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">item</span>: <span class="lg-highlight-string">'journal'</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">qty</span>: <span class="lg-highlight-number">25</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">tags</span>: <!-- -->[<span class="lg-highlight-string">'blank'</span>, <span class="lg-highlight-string">'red'</span>]<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">size</span>: <!-- -->{ <span class="lg-highlight-attr">h</span>: <span class="lg-highlight-number">14</span>, <span class="lg-highlight-attr">w</span>: <span class="lg-highlight-number">21</span>, <span class="lg-highlight-attr">uom</span>: <span class="lg-highlight-string">'cm'</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">item</span>: <span class="lg-highlight-string">'mat'</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">qty</span>: <span class="lg-highlight-number">85</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">tags</span>: <!-- -->[<span class="lg-highlight-string">'gray'</span>]<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">size</span>: <!-- -->{ <span class="lg-highlight-attr">h</span>: <span class="lg-highlight-number">27.9</span>, <span class="lg-highlight-attr">w</span>: <span class="lg-highlight-number">35.5</span>, <span class="lg-highlight-attr">uom</span>: <span class="lg-highlight-string">'cm'</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">item</span>: <span class="lg-highlight-string">'mousepad'</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">qty</span>: <span class="lg-highlight-number">25</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">tags</span>: <!-- -->[<span class="lg-highlight-string">'gel'</span>, <span class="lg-highlight-string">'blue'</span>]<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">size</span>: <!-- -->{ <span class="lg-highlight-attr">h</span>: <span class="lg-highlight-number">19</span>, <span class="lg-highlight-attr">w</span>: <span class="lg-highlight-number">22.85</span>, <span class="lg-highlight-attr">uom</span>: <span class="lg-highlight-string">'cm'</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">])<!-- -->;</td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-143-menu" aria-describedby="select-143-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-144" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:r8n:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":r8n:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r8n:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r8n:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_xf2aedb84" class="leafygreen-ui-38lglc" id="_qpqm1bdny" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"$db-&gt;coll(\"inventory\")-&gt;insert_many(\n [\n {\n item =&gt; \"journal\",\n qty =&gt; 25,\n tags =&gt; [ \"blank\", \"red\" ],\n size =&gt; { h =&gt; 14, w =&gt; 21, uom =&gt; \"cm\" }\n },\n {\n item =&gt; \"mat\",\n qty =&gt; 85,\n tags =&gt; [\"gray\"],\n size =&gt; { h =&gt; 27.9, w =&gt; 35.5, uom =&gt; \"cm\" }\n },\n {\n item =&gt; \"mousepad\",\n qty =&gt; 25,\n tags =&gt; [ \"gel\", \"blue\" ],\n size =&gt; { h =&gt; 19, w =&gt; 22.85, uom =&gt; \"cm\" }\n }\n ]\n);","programmingLanguage":"Perl"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <pre class="leafygreen-ui-11itue3" 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<!-- -->-<!-- -->&gt;<!-- --><!-- --><span class="lg-highlight-title lg-highlight-function">coll</span>(<span class="lg-highlight-string">"inventory"</span>)<!-- -->-<!-- -->&gt;<!-- --><!-- --><span class="lg-highlight-title lg-highlight-function">insert_many</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-params lg-highlight-function">item</span><span class="lg-highlight-function"> =&gt;</span> <span class="lg-highlight-string">"journal"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-params lg-highlight-function">qty</span><span class="lg-highlight-function"> =&gt;</span> <span class="lg-highlight-number">25</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-params lg-highlight-function">tags</span><!-- --><span class="lg-highlight-function"> =&gt;</span> <!-- -->[ <span class="lg-highlight-string">"blank"</span>, <span class="lg-highlight-string">"red"</span> ],</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-params lg-highlight-function">size</span><!-- --><span class="lg-highlight-function"> =&gt;</span> { <span class="lg-highlight-params lg-highlight-function">h</span><span class="lg-highlight-function"> =&gt;</span> <span class="lg-highlight-number">14</span>, <span class="lg-highlight-params lg-highlight-function">w</span><span class="lg-highlight-function"> =&gt;</span> <span class="lg-highlight-number">21</span>, <span class="lg-highlight-params lg-highlight-function">uom</span><span class="lg-highlight-function"> =&gt;</span> <span class="lg-highlight-string">"cm"</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-params lg-highlight-function">item</span><span class="lg-highlight-function"> =&gt;</span> <span class="lg-highlight-string">"mat"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-params lg-highlight-function">qty</span><span class="lg-highlight-function"> =&gt;</span> <span class="lg-highlight-number">85</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-params lg-highlight-function">tags</span><!-- --><span class="lg-highlight-function"> =&gt;</span> <!-- -->[<span class="lg-highlight-string">"gray"</span>],</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-params lg-highlight-function">size</span><!-- --><span class="lg-highlight-function"> =&gt;</span> { <span class="lg-highlight-params lg-highlight-function">h</span><span class="lg-highlight-function"> =&gt;</span> <span class="lg-highlight-number">27.9</span>, <span class="lg-highlight-params lg-highlight-function">w</span><span class="lg-highlight-function"> =&gt;</span> <span class="lg-highlight-number">35.5</span>, <span class="lg-highlight-params lg-highlight-function">uom</span><span class="lg-highlight-function"> =&gt;</span> <span class="lg-highlight-string">"cm"</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-params lg-highlight-function">item</span><span class="lg-highlight-function"> =&gt;</span> <span class="lg-highlight-string">"mousepad"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-params lg-highlight-function">qty</span><span class="lg-highlight-function"> =&gt;</span> <span class="lg-highlight-number">25</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-params lg-highlight-function">tags</span><!-- --><span class="lg-highlight-function"> =&gt;</span> <!-- -->[ <span class="lg-highlight-string">"gel"</span>, <span class="lg-highlight-string">"blue"</span> ],</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-params lg-highlight-function">size</span><!-- --><span class="lg-highlight-function"> =&gt;</span> { <span class="lg-highlight-params lg-highlight-function">h</span><span class="lg-highlight-function"> =&gt;</span> <span class="lg-highlight-number">19</span>, <span class="lg-highlight-params lg-highlight-function">w</span><span class="lg-highlight-function"> =&gt;</span> <span class="lg-highlight-number">22.85</span>, <span class="lg-highlight-params lg-highlight-function">uom</span><span class="lg-highlight-function"> =&gt;</span> <span class="lg-highlight-string">"cm"</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> ]</td></tr><tr class=""><td class="leafygreen-ui-7razhx">)<!-- -->;</td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-146-menu" aria-describedby="select-146-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-147" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:r8o:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":r8o:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r8o:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r8o:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_u5l7tj0ge" class="leafygreen-ui-38lglc" id="_k07qxjz12" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"$insertManyResult = $db-&gt;inventory-&gt;insertMany([\n [\n 'item' =&gt; 'journal',\n 'qty' =&gt; 25,\n 'tags' =&gt; ['blank', 'red'],\n 'size' =&gt; ['h' =&gt; 14, 'w' =&gt; 21, 'uom' =&gt; 'cm'],\n ],\n [\n 'item' =&gt; 'mat',\n 'qty' =&gt; 85,\n 'tags' =&gt; ['gray'],\n 'size' =&gt; ['h' =&gt; 27.9, 'w' =&gt; 35.5, 'uom' =&gt; 'cm'],\n ],\n [\n 'item' =&gt; 'mousepad',\n 'qty' =&gt; 25,\n 'tags' =&gt; ['gel', 'blue'],\n 'size' =&gt; ['h' =&gt; 19, 'w' =&gt; 22.85, 'uom' =&gt; 'cm'],\n ],\n]);","programmingLanguage":"PHP"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <pre class="leafygreen-ui-11itue3" 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">$insertManyResult = $db-&gt;inventory-&gt;<span class="lg-highlight-title lg-highlight-function">insertMany</span>([</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> [</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">'item'</span> =&gt; <span class="lg-highlight-string">'journal'</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">'qty'</span> =&gt; <span class="lg-highlight-number">25</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">'tags'</span> =&gt; [<span class="lg-highlight-string">'blank'</span>, <span class="lg-highlight-string">'red'</span>],</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">'size'</span> =&gt; [<span class="lg-highlight-string">'h'</span> =&gt; <span class="lg-highlight-number">14</span>, <span class="lg-highlight-string">'w'</span> =&gt; <span class="lg-highlight-number">21</span>, <span class="lg-highlight-string">'uom'</span> =&gt; <span class="lg-highlight-string">'cm'</span>],</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> ],</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> [</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">'item'</span> =&gt; <span class="lg-highlight-string">'mat'</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">'qty'</span> =&gt; <span class="lg-highlight-number">85</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">'tags'</span> =&gt; [<span class="lg-highlight-string">'gray'</span>],</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">'size'</span> =&gt; [<span class="lg-highlight-string">'h'</span> =&gt; <span class="lg-highlight-number">27.9</span>, <span class="lg-highlight-string">'w'</span> =&gt; <span class="lg-highlight-number">35.5</span>, <span class="lg-highlight-string">'uom'</span> =&gt; <span class="lg-highlight-string">'cm'</span>],</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> ],</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> [</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">'item'</span> =&gt; <span class="lg-highlight-string">'mousepad'</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">'qty'</span> =&gt; <span class="lg-highlight-number">25</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">'tags'</span> =&gt; [<span class="lg-highlight-string">'gel'</span>, <span class="lg-highlight-string">'blue'</span>],</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">'size'</span> =&gt; [<span class="lg-highlight-string">'h'</span> =&gt; <span class="lg-highlight-number">19</span>, <span class="lg-highlight-string">'w'</span> =&gt; <span class="lg-highlight-number">22.85</span>, <span class="lg-highlight-string">'uom'</span> =&gt; <span class="lg-highlight-string">'cm'</span>],</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> ],</td></tr><tr class=""><td class="leafygreen-ui-7razhx">])<!-- -->;</td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-149-menu" aria-describedby="select-149-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-150" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:r8p:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":r8p:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r8p:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r8p:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_p0jf92t2h" class="leafygreen-ui-38lglc" id="_h710b3zdm" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.inventory.insert_many(\n [\n {\n \"item\": \"journal\",\n \"qty\": 25,\n \"tags\": [\"blank\", \"red\"],\n \"size\": {\"h\": 14, \"w\": 21, \"uom\": \"cm\"},\n },\n {\n \"item\": \"mat\",\n \"qty\": 85,\n \"tags\": [\"gray\"],\n \"size\": {\"h\": 27.9, \"w\": 35.5, \"uom\": \"cm\"},\n },\n {\n \"item\": \"mousepad\",\n \"qty\": 25,\n \"tags\": [\"gel\", \"blue\"],\n \"size\": {\"h\": 19, \"w\": 22.85, \"uom\": \"cm\"},\n },\n ]\n)","programmingLanguage":"Python"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <pre class="leafygreen-ui-11itue3" 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">inventory</span>.<span class="lg-highlight-title lg-highlight-function">insert_many</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> [</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> {</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"item"</span>: <span class="lg-highlight-string">"journal"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"qty"</span>: <span class="lg-highlight-number">25</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"tags"</span>: [<span class="lg-highlight-string">"blank"</span>, <span class="lg-highlight-string">"red"</span>],</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"size"</span>: {<span class="lg-highlight-string">"h"</span>: <span class="lg-highlight-number">14</span>, <span class="lg-highlight-string">"w"</span>: <span class="lg-highlight-number">21</span>, <span class="lg-highlight-string">"uom"</span>: <span class="lg-highlight-string">"cm"</span>},</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> },</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> {</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"item"</span>: <span class="lg-highlight-string">"mat"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"qty"</span>: <span class="lg-highlight-number">85</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"tags"</span>: [<span class="lg-highlight-string">"gray"</span>],</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"size"</span>: {<span class="lg-highlight-string">"h"</span>: <span class="lg-highlight-number">27.9</span>, <span class="lg-highlight-string">"w"</span>: <span class="lg-highlight-number">35.5</span>, <span class="lg-highlight-string">"uom"</span>: <span class="lg-highlight-string">"cm"</span>},</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> },</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> {</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"item"</span>: <span class="lg-highlight-string">"mousepad"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"qty"</span>: <span class="lg-highlight-number">25</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"tags"</span>: [<span class="lg-highlight-string">"gel"</span>, <span class="lg-highlight-string">"blue"</span>],</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"size"</span>: {<span class="lg-highlight-string">"h"</span>: <span class="lg-highlight-number">19</span>, <span class="lg-highlight-string">"w"</span>: <span class="lg-highlight-number">22.85</span>, <span class="lg-highlight-string">"uom"</span>: <span class="lg-highlight-string">"cm"</span>},</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> },</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> ]</td></tr><tr class=""><td class="leafygreen-ui-7razhx">)</td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-152-menu" aria-describedby="select-152-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-153" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:r8q:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":r8q:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r8q:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r8q:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_1jfn45zh7" class="leafygreen-ui-38lglc" id="_12x4hbfrs" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"client[:inventory].insert_many([{ item: 'journal',\n qty: 25,\n tags: ['blank', 'red'],\n size: { h: 14, w: 21, uom: 'cm' }\n },\n { item: 'mat',\n qty: 85,\n tags: ['gray'],\n size: { h: 27.9, w: 35.5, uom: 'cm' }\n },\n { item: 'mousepad',\n qty: 25,\n tags: ['gel', 'blue'],\n size: { h: 19, w: 22.85, uom: 'cm' }\n }\n ])","programmingLanguage":"Ruby"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <pre class="leafygreen-ui-11itue3" 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">client<!-- -->[<!-- -->:inventory].<span class="lg-highlight-title lg-highlight-function">insert_many</span>(<!-- -->[<!-- -->{ <span class="lg-highlight-attr">item</span>: <span class="lg-highlight-string">'journal'</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">qty</span>: <span class="lg-highlight-number">25</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">tags</span>: <!-- -->[<span class="lg-highlight-string">'blank'</span>, <span class="lg-highlight-string">'red'</span>]<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">size</span>: <!-- -->{ <span class="lg-highlight-attr">h</span>: <span class="lg-highlight-number">14</span>, <span class="lg-highlight-attr">w</span>: <span class="lg-highlight-number">21</span>, <span class="lg-highlight-attr">uom</span>: <span class="lg-highlight-string">'cm'</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">item</span>: <span class="lg-highlight-string">'mat'</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">qty</span>: <span class="lg-highlight-number">85</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">tags</span>: <!-- -->[<span class="lg-highlight-string">'gray'</span>]<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">size</span>: <!-- -->{ <span class="lg-highlight-attr">h</span>: <span class="lg-highlight-number">27.9</span>, <span class="lg-highlight-attr">w</span>: <span class="lg-highlight-number">35.5</span>, <span class="lg-highlight-attr">uom</span>: <span class="lg-highlight-string">'cm'</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">item</span>: <span class="lg-highlight-string">'mousepad'</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">qty</span>: <span class="lg-highlight-number">25</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">tags</span>: <!-- -->[<span class="lg-highlight-string">'gel'</span>, <span class="lg-highlight-string">'blue'</span>]<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">size</span>: <!-- -->{ <span class="lg-highlight-attr">h</span>: <span class="lg-highlight-number">19</span>, <span class="lg-highlight-attr">w</span>: <span class="lg-highlight-number">22.85</span>, <span class="lg-highlight-attr">uom</span>: <span class="lg-highlight-string">'cm'</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> ])</td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-155-menu" aria-describedby="select-155-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-156" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:r8r:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":r8r:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r8r:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r8r:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_1gtjjqbuz" class="leafygreen-ui-38lglc" id="_wnbbb2bk3" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"collection.insertMany(Seq(\n Document(\"item\" -&gt; \"journal\", \"qty\" -&gt; 25, \"tags\" -&gt; Seq(\"blank\", \"red\"), \"size\" -&gt; Document(\"h\" -&gt; 14, \"w\" -&gt; 21, \"uom\" -&gt; \"cm\")),\n Document(\"item\" -&gt; \"mat\", \"qty\" -&gt; 85, \"tags\" -&gt; Seq(\"gray\"), \"size\" -&gt; Document(\"h\" -&gt; 27.9, \"w\" -&gt; 35.5, \"uom\" -&gt; \"cm\")),\n Document(\"item\" -&gt; \"mousepad\", \"qty\" -&gt; 25, \"tags\" -&gt; Seq(\"gel\", \"blue\"), \"size\" -&gt; Document(\"h\" -&gt; 19, \"w\" -&gt; 22.85, \"uom\" -&gt; \"cm\"))\n)).execute()","programmingLanguage":"Scala"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <pre class="leafygreen-ui-11itue3" 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">collection.<span class="lg-highlight-title lg-highlight-function">insertMany</span>(<span class="lg-highlight-title lg-highlight-class">Seq</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-title lg-highlight-class">Document</span>(<span class="lg-highlight-string">"item"</span> -&gt; <span class="lg-highlight-string">"journal"</span>, <span class="lg-highlight-string">"qty"</span> -&gt; <span class="lg-highlight-number">25</span>, <span class="lg-highlight-string">"tags"</span> -&gt; <span class="lg-highlight-title lg-highlight-class">Seq</span>(<span class="lg-highlight-string">"blank"</span>, <span class="lg-highlight-string">"red"</span>), <span class="lg-highlight-string">"size"</span> -&gt; <span class="lg-highlight-title lg-highlight-class">Document</span>(<span class="lg-highlight-string">"h"</span> -&gt; <span class="lg-highlight-number">14</span>, <span class="lg-highlight-string">"w"</span> -&gt; <span class="lg-highlight-number">21</span>, <span class="lg-highlight-string">"uom"</span> -&gt; <span class="lg-highlight-string">"cm"</span>)),</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-title lg-highlight-class">Document</span>(<span class="lg-highlight-string">"item"</span> -&gt; <span class="lg-highlight-string">"mat"</span>, <span class="lg-highlight-string">"qty"</span> -&gt; <span class="lg-highlight-number">85</span>, <span class="lg-highlight-string">"tags"</span> -&gt; <span class="lg-highlight-title lg-highlight-class">Seq</span>(<span class="lg-highlight-string">"gray"</span>), <span class="lg-highlight-string">"size"</span> -&gt; <span class="lg-highlight-title lg-highlight-class">Document</span>(<span class="lg-highlight-string">"h"</span> -&gt; <span class="lg-highlight-number">27.9</span>, <span class="lg-highlight-string">"w"</span> -&gt; <span class="lg-highlight-number">35.5</span>, <span class="lg-highlight-string">"uom"</span> -&gt; <span class="lg-highlight-string">"cm"</span>)),</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-title lg-highlight-class">Document</span>(<span class="lg-highlight-string">"item"</span> -&gt; <span class="lg-highlight-string">"mousepad"</span>, <span class="lg-highlight-string">"qty"</span> -&gt; <span class="lg-highlight-number">25</span>, <span class="lg-highlight-string">"tags"</span> -&gt; <span class="lg-highlight-title lg-highlight-class">Seq</span>(<span class="lg-highlight-string">"gel"</span>, <span class="lg-highlight-string">"blue"</span>), <span class="lg-highlight-string">"size"</span> -&gt; <span class="lg-highlight-title lg-highlight-class">Document</span>(<span class="lg-highlight-string">"h"</span> -&gt; <span class="lg-highlight-number">19</span>, <span class="lg-highlight-string">"w"</span> -&gt; <span class="lg-highlight-number">22.85</span>, <span class="lg-highlight-string">"uom"</span> -&gt; <span class="lg-highlight-string">"cm"</span>))</td></tr><tr class=""><td class="leafygreen-ui-7razhx">)).<span class="lg-highlight-title lg-highlight-function">execute</span>()</td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-158-menu" aria-describedby="select-158-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-159" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:r8s:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":r8s:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r8s:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r8s:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> </div> </div> <div aria-hidden="true"> </div> <div class="leafygreen-ui-f2qztv" data-lgid="lg-tabs"> <div class="leafygreen-ui-jp7pox" id="tabs-17"> <div aria-label="Tabs to describe usage of drivers" aria-orientation="horizontal" class="leafygreen-ui-m8p1vb lg-ui-tab-list-0000" data-lgid="lg-tabs-tab_list" role="tablist"> <button aria-controls="_nn5ug5kwo" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_ttkl47la5" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> MongoDB Shell </div> </button> <button aria-controls="_bgqdmr4xi" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_puee3n0im" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> C </div> </button> <button aria-controls="_pnmhy8rpc" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_c8ge2f84d" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> C# </div> </button> <button aria-controls="_nk1vgzvmz" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_ny5ziegy2" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Go </div> </button> <button aria-controls="_88s2ufxul" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_gq1bq1k0l" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Java (Async) </div> </button> <button aria-controls="_p2xqa9zwq" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_17tzfqyaa" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Java (Sync) </div> </button> <button aria-controls="_7x453jxmo" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_7fcjukre3" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Kotlin (Coroutine) </div> </button> <button aria-controls="_4ylx7k8aq" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_cme9ols9a" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Motor </div> </button> <button aria-controls="_ztbwfi1k2" aria-selected="true" class="leafygreen-ui-1l773z1" data-text="" id="_ep9efup2q" name="" role="tab" tabindex="0"> <div class="leafygreen-ui-1nxuzmg"> Node.js </div> </button> <button aria-controls="_zoaai31wo" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_dwikvtju8" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Perl </div> </button> <button aria-controls="_x0s1gd3g2" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_saleglmm2" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> PHP </div> </button> <button aria-controls="_tn1126d5w" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_ko8gihxmx" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Python </div> </button> <button aria-controls="_kyrhzth0q" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_0crxjl8aa" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Ruby </div> </button> <button aria-controls="_2s15hgylz" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_fbp20zzbs" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Scala </div> </button> </div> <div class="leafygreen-ui-ov1ktg"> <div class="leafygreen-ui-1sg2lsz"> </div> </div> </div> <div class="lg-ui-tab-panels-0000" data-lgid="lg-tabs-tab_panels"> <div> <div aria-labelledby="_qs62ofyy5" class="leafygreen-ui-38lglc" id="_xtc4c7f9d" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/db.collection.insertMany/#mongodb-method-db.collection.insertMany"> <code class="leafygreen-ui-1l06pbn"> insertMany() </code> </a> returns a document that includes the newly inserted documents <code class="leafygreen-ui-1l06pbn"> _id </code> field values. See the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/db.collection.insertMany/#std-label-insertMany-examples"> reference </a> for an example. </p> <p class="leafygreen-ui-1kp3ins"> To retrieve the inserted documents, <a class="leafygreen-ui-tqgtui" href="/docs/manual/tutorial/query-documents/#std-label-read-operations-query-document"> query the collection <!-- --> : </a> </p> </div> </div> </div> <div> <div aria-labelledby="_47rad8a5l" class="leafygreen-ui-38lglc" id="_m53ejcc5n" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://mongoc.org/libmongoc/current/mongoc_bulk_operation_insert_with_opts.html" rel="noopener noreferrer"> <span> mongoc_bulk_operation_insert_with_opts </span> <svg alt="" aria-hidden="true" class="leafygreen-ui-1ie5kuq" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M13.823 2.4491C13.8201 2.30008 13.6999 2.17994 13.5509 2.17704L9.5062 2.09836C9.25654 2.09351 9.12821 2.39519 9.30482 2.5718L10.3856 3.65257L7.93433 6.10383C7.87964 6.15852 7.83047 6.21665 7.78683 6.27752L5.99909 8.06525C5.46457 8.59977 5.46457 9.4664 5.99909 10.0009C6.53361 10.5354 7.40023 10.5354 7.93475 10.0009L9.72249 8.21317C9.78336 8.16953 9.84148 8.12037 9.89618 8.06567L12.3474 5.61441L13.4282 6.69518C13.6048 6.87179 13.9065 6.74347 13.9016 6.4938L13.823 2.4491Z" fill="currentColor"> </path> <path d="M7.25 3.12893C7.66421 3.12893 8 3.46472 8 3.87893C8 4.29315 7.66421 4.62893 7.25 4.62893H4C3.72386 4.62893 3.5 4.85279 3.5 5.12893V11.9929C3.5 12.2691 3.72386 12.4929 4 12.4929H10.864C11.1401 12.4929 11.364 12.2691 11.364 11.9929V8.75C11.364 8.33579 11.6998 8 12.114 8C12.5282 8 12.864 8.33579 12.864 8.75V11.9929C12.864 13.0975 11.9686 13.9929 10.864 13.9929H4C2.89543 13.9929 2 13.0975 2 11.9929V5.12893C2 4.02436 2.89543 3.12893 4 3.12893H7.25Z" fill="currentColor"> </path> </svg> </a> returns <code class="leafygreen-ui-1l06pbn"> true </code> on success, or <code class="leafygreen-ui-1l06pbn"> false </code> if passed invalid arguments. </p> <p class="leafygreen-ui-1kp3ins"> To retrieve the inserted documents, use <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://mongoc.org/libmongoc/current/mongoc_collection_find_with_opts.html" rel="noopener noreferrer"> <span> mongoc_collection_find_with_opts </span> <svg alt="" aria-hidden="true" class="leafygreen-ui-1ie5kuq" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M13.823 2.4491C13.8201 2.30008 13.6999 2.17994 13.5509 2.17704L9.5062 2.09836C9.25654 2.09351 9.12821 2.39519 9.30482 2.5718L10.3856 3.65257L7.93433 6.10383C7.87964 6.15852 7.83047 6.21665 7.78683 6.27752L5.99909 8.06525C5.46457 8.59977 5.46457 9.4664 5.99909 10.0009C6.53361 10.5354 7.40023 10.5354 7.93475 10.0009L9.72249 8.21317C9.78336 8.16953 9.84148 8.12037 9.89618 8.06567L12.3474 5.61441L13.4282 6.69518C13.6048 6.87179 13.9065 6.74347 13.9016 6.4938L13.823 2.4491Z" fill="currentColor"> </path> <path d="M7.25 3.12893C7.66421 3.12893 8 3.46472 8 3.87893C8 4.29315 7.66421 4.62893 7.25 4.62893H4C3.72386 4.62893 3.5 4.85279 3.5 5.12893V11.9929C3.5 12.2691 3.72386 12.4929 4 12.4929H10.864C11.1401 12.4929 11.364 12.2691 11.364 11.9929V8.75C11.364 8.33579 11.6998 8 12.114 8C12.5282 8 12.864 8.33579 12.864 8.75V11.9929C12.864 13.0975 11.9686 13.9929 10.864 13.9929H4C2.89543 13.9929 2 13.0975 2 11.9929V5.12893C2 4.02436 2.89543 3.12893 4 3.12893H7.25Z" fill="currentColor"> </path> </svg> </a> to <a class="leafygreen-ui-tqgtui" href="/docs/manual/tutorial/query-documents/#std-label-read-operations-query-document"> query the collection <!-- --> : </a> </p> </div> </div> </div> <div> <div aria-labelledby="_he1uvwlz8" class="leafygreen-ui-38lglc" id="_gtx4wtyeg" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <p class="leafygreen-ui-1kp3ins"> To retrieve the inserted documents, <a class="leafygreen-ui-tqgtui" href="/docs/manual/tutorial/query-documents/#std-label-read-operations-query-document"> query the collection <!-- --> : </a> </p> </div> </div> </div> <div> <div aria-labelledby="_ivwvmg965" class="leafygreen-ui-38lglc" id="_li58a204s" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <p class="leafygreen-ui-1kp3ins"> To retrieve the inserted documents, <a class="leafygreen-ui-tqgtui" href="/docs/manual/tutorial/query-documents/#std-label-read-operations-query-document"> query the collection <!-- --> : </a> </p> </div> </div> </div> <div> <div aria-labelledby="_arwhy3fnv" class="leafygreen-ui-38lglc" id="_el4oay78i" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="http://mongodb.github.io/mongo-java-driver-reactivestreams/1.6/javadoc/com/mongodb/reactivestreams/client/MongoCollection.html#insertMany(java.util.List)" rel="noopener noreferrer"> <span> com.mongodb.reactivestreams.client.MongoCollection.html.insertMany </span> <svg alt="" aria-hidden="true" class="leafygreen-ui-1ie5kuq" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M13.823 2.4491C13.8201 2.30008 13.6999 2.17994 13.5509 2.17704L9.5062 2.09836C9.25654 2.09351 9.12821 2.39519 9.30482 2.5718L10.3856 3.65257L7.93433 6.10383C7.87964 6.15852 7.83047 6.21665 7.78683 6.27752L5.99909 8.06525C5.46457 8.59977 5.46457 9.4664 5.99909 10.0009C6.53361 10.5354 7.40023 10.5354 7.93475 10.0009L9.72249 8.21317C9.78336 8.16953 9.84148 8.12037 9.89618 8.06567L12.3474 5.61441L13.4282 6.69518C13.6048 6.87179 13.9065 6.74347 13.9016 6.4938L13.823 2.4491Z" fill="currentColor"> </path> <path d="M7.25 3.12893C7.66421 3.12893 8 3.46472 8 3.87893C8 4.29315 7.66421 4.62893 7.25 4.62893H4C3.72386 4.62893 3.5 4.85279 3.5 5.12893V11.9929C3.5 12.2691 3.72386 12.4929 4 12.4929H10.864C11.1401 12.4929 11.364 12.2691 11.364 11.9929V8.75C11.364 8.33579 11.6998 8 12.114 8C12.5282 8 12.864 8.33579 12.864 8.75V11.9929C12.864 13.0975 11.9686 13.9929 10.864 13.9929H4C2.89543 13.9929 2 13.0975 2 11.9929V5.12893C2 4.02436 2.89543 3.12893 4 3.12893H7.25Z" fill="currentColor"> </path> </svg> </a> returns a <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="http://www.reactive-streams.org/reactive-streams-1.0.1-javadoc/org/reactivestreams/Publisher.html" rel="noopener noreferrer"> <span> Publisher </span> <svg alt="" aria-hidden="true" class="leafygreen-ui-1ie5kuq" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M13.823 2.4491C13.8201 2.30008 13.6999 2.17994 13.5509 2.17704L9.5062 2.09836C9.25654 2.09351 9.12821 2.39519 9.30482 2.5718L10.3856 3.65257L7.93433 6.10383C7.87964 6.15852 7.83047 6.21665 7.78683 6.27752L5.99909 8.06525C5.46457 8.59977 5.46457 9.4664 5.99909 10.0009C6.53361 10.5354 7.40023 10.5354 7.93475 10.0009L9.72249 8.21317C9.78336 8.16953 9.84148 8.12037 9.89618 8.06567L12.3474 5.61441L13.4282 6.69518C13.6048 6.87179 13.9065 6.74347 13.9016 6.4938L13.823 2.4491Z" fill="currentColor"> </path> <path d="M7.25 3.12893C7.66421 3.12893 8 3.46472 8 3.87893C8 4.29315 7.66421 4.62893 7.25 4.62893H4C3.72386 4.62893 3.5 4.85279 3.5 5.12893V11.9929C3.5 12.2691 3.72386 12.4929 4 12.4929H10.864C11.1401 12.4929 11.364 12.2691 11.364 11.9929V8.75C11.364 8.33579 11.6998 8 12.114 8C12.5282 8 12.864 8.33579 12.864 8.75V11.9929C12.864 13.0975 11.9686 13.9929 10.864 13.9929H4C2.89543 13.9929 2 13.0975 2 11.9929V5.12893C2 4.02436 2.89543 3.12893 4 3.12893H7.25Z" fill="currentColor"> </path> </svg> </a> object. The <code class="leafygreen-ui-1l06pbn"> Publisher </code> inserts the document into a collection when subscribers request data. </p> <p class="leafygreen-ui-1kp3ins"> To retrieve the inserted documents, <a class="leafygreen-ui-tqgtui" href="/docs/manual/tutorial/query-documents/#std-label-read-operations-query-document"> query the collection <!-- --> : </a> </p> </div> </div> </div> <div> <div aria-labelledby="_2qpan9x25" class="leafygreen-ui-38lglc" id="_trj1pwo4c" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <p class="leafygreen-ui-1kp3ins"> To retrieve the inserted documents, <a class="leafygreen-ui-tqgtui" href="/docs/manual/tutorial/query-documents/#std-label-read-operations-query-document"> query the collection <!-- --> : </a> </p> </div> </div> </div> <div> <div aria-labelledby="_amrqq0lle" class="leafygreen-ui-38lglc" id="_87jr4fp7b" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://mongodb.github.io/mongo-java-driver/4.11/apidocs/mongodb-driver-kotlin-coroutine/mongodb-driver-kotlin-coroutine/com.mongodb.kotlin.client.coroutine/-mongo-collection/insert-many.html" rel="noopener noreferrer"> <span> MongoCollection.insertMany() </span> <svg alt="" aria-hidden="true" class="leafygreen-ui-1ie5kuq" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M13.823 2.4491C13.8201 2.30008 13.6999 2.17994 13.5509 2.17704L9.5062 2.09836C9.25654 2.09351 9.12821 2.39519 9.30482 2.5718L10.3856 3.65257L7.93433 6.10383C7.87964 6.15852 7.83047 6.21665 7.78683 6.27752L5.99909 8.06525C5.46457 8.59977 5.46457 9.4664 5.99909 10.0009C6.53361 10.5354 7.40023 10.5354 7.93475 10.0009L9.72249 8.21317C9.78336 8.16953 9.84148 8.12037 9.89618 8.06567L12.3474 5.61441L13.4282 6.69518C13.6048 6.87179 13.9065 6.74347 13.9016 6.4938L13.823 2.4491Z" fill="currentColor"> </path> <path d="M7.25 3.12893C7.66421 3.12893 8 3.46472 8 3.87893C8 4.29315 7.66421 4.62893 7.25 4.62893H4C3.72386 4.62893 3.5 4.85279 3.5 5.12893V11.9929C3.5 12.2691 3.72386 12.4929 4 12.4929H10.864C11.1401 12.4929 11.364 12.2691 11.364 11.9929V8.75C11.364 8.33579 11.6998 8 12.114 8C12.5282 8 12.864 8.33579 12.864 8.75V11.9929C12.864 13.0975 11.9686 13.9929 10.864 13.9929H4C2.89543 13.9929 2 13.0975 2 11.9929V5.12893C2 4.02436 2.89543 3.12893 4 3.12893H7.25Z" fill="currentColor"> </path> </svg> </a> returns an <code class="leafygreen-ui-1l06pbn"> InsertManyResult </code> instance. The <code class="leafygreen-ui-1l06pbn"> insertedIds </code> field of <code class="leafygreen-ui-1l06pbn"> InsertManyResult </code> contains the <code class="leafygreen-ui-1l06pbn"> _id </code> values of the inserted documents. </p> <p class="leafygreen-ui-1kp3ins"> To retrieve the inserted documents, <a class="leafygreen-ui-tqgtui" href="/docs/manual/tutorial/query-documents/#std-label-read-operations-query-document"> query the collection <!-- --> : </a> </p> </div> </div> </div> <div> <div aria-labelledby="_y7flyemtj" class="leafygreen-ui-38lglc" id="_lgg473o4o" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://motor.readthedocs.io/en/stable/api-asyncio/asyncio_motor_collection.html#motor.motor_asyncio.AsyncIOMotorCollection.insert_many" rel="noopener noreferrer"> <span> <code class="leafygreen-ui-1l06pbn"> insert_many </code> </span> <svg alt="" aria-hidden="true" class="leafygreen-ui-1ie5kuq" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M13.823 2.4491C13.8201 2.30008 13.6999 2.17994 13.5509 2.17704L9.5062 2.09836C9.25654 2.09351 9.12821 2.39519 9.30482 2.5718L10.3856 3.65257L7.93433 6.10383C7.87964 6.15852 7.83047 6.21665 7.78683 6.27752L5.99909 8.06525C5.46457 8.59977 5.46457 9.4664 5.99909 10.0009C6.53361 10.5354 7.40023 10.5354 7.93475 10.0009L9.72249 8.21317C9.78336 8.16953 9.84148 8.12037 9.89618 8.06567L12.3474 5.61441L13.4282 6.69518C13.6048 6.87179 13.9065 6.74347 13.9016 6.4938L13.823 2.4491Z" fill="currentColor"> </path> <path d="M7.25 3.12893C7.66421 3.12893 8 3.46472 8 3.87893C8 4.29315 7.66421 4.62893 7.25 4.62893H4C3.72386 4.62893 3.5 4.85279 3.5 5.12893V11.9929C3.5 12.2691 3.72386 12.4929 4 12.4929H10.864C11.1401 12.4929 11.364 12.2691 11.364 11.9929V8.75C11.364 8.33579 11.6998 8 12.114 8C12.5282 8 12.864 8.33579 12.864 8.75V11.9929C12.864 13.0975 11.9686 13.9929 10.864 13.9929H4C2.89543 13.9929 2 13.0975 2 11.9929V5.12893C2 4.02436 2.89543 3.12893 4 3.12893H7.25Z" fill="currentColor"> </path> </svg> </a> returns an instance of <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://pymongo.readthedocs.io/en/stable/api/pymongo/results.html#pymongo.results.InsertManyResult" rel="noopener noreferrer"> <span> <code class="leafygreen-ui-1l06pbn"> pymongo.results.InsertManyResult </code> </span> <svg alt="" aria-hidden="true" class="leafygreen-ui-1ie5kuq" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M13.823 2.4491C13.8201 2.30008 13.6999 2.17994 13.5509 2.17704L9.5062 2.09836C9.25654 2.09351 9.12821 2.39519 9.30482 2.5718L10.3856 3.65257L7.93433 6.10383C7.87964 6.15852 7.83047 6.21665 7.78683 6.27752L5.99909 8.06525C5.46457 8.59977 5.46457 9.4664 5.99909 10.0009C6.53361 10.5354 7.40023 10.5354 7.93475 10.0009L9.72249 8.21317C9.78336 8.16953 9.84148 8.12037 9.89618 8.06567L12.3474 5.61441L13.4282 6.69518C13.6048 6.87179 13.9065 6.74347 13.9016 6.4938L13.823 2.4491Z" fill="currentColor"> </path> <path d="M7.25 3.12893C7.66421 3.12893 8 3.46472 8 3.87893C8 4.29315 7.66421 4.62893 7.25 4.62893H4C3.72386 4.62893 3.5 4.85279 3.5 5.12893V11.9929C3.5 12.2691 3.72386 12.4929 4 12.4929H10.864C11.1401 12.4929 11.364 12.2691 11.364 11.9929V8.75C11.364 8.33579 11.6998 8 12.114 8C12.5282 8 12.864 8.33579 12.864 8.75V11.9929C12.864 13.0975 11.9686 13.9929 10.864 13.9929H4C2.89543 13.9929 2 13.0975 2 11.9929V5.12893C2 4.02436 2.89543 3.12893 4 3.12893H7.25Z" fill="currentColor"> </path> </svg> </a> whose <code class="leafygreen-ui-1l06pbn"> inserted_ids </code> field is a list containing the <code class="leafygreen-ui-1l06pbn"> _id </code> of each newly inserted document. </p> <p class="leafygreen-ui-1kp3ins"> To retrieve the inserted documents, <a class="leafygreen-ui-tqgtui" href="/docs/manual/tutorial/query-documents/#std-label-read-operations-query-document"> query the collection <!-- --> : </a> </p> </div> </div> </div> <div> <div aria-labelledby="_xn31cexwx" class="" id="_r6o40zb7u" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="http://mongodb.github.io/node-mongodb-native/3.6/api/Collection.html#insertMany" rel="noopener noreferrer"> <span> insertMany() </span> <svg alt="" aria-hidden="true" class="leafygreen-ui-1ie5kuq" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M13.823 2.4491C13.8201 2.30008 13.6999 2.17994 13.5509 2.17704L9.5062 2.09836C9.25654 2.09351 9.12821 2.39519 9.30482 2.5718L10.3856 3.65257L7.93433 6.10383C7.87964 6.15852 7.83047 6.21665 7.78683 6.27752L5.99909 8.06525C5.46457 8.59977 5.46457 9.4664 5.99909 10.0009C6.53361 10.5354 7.40023 10.5354 7.93475 10.0009L9.72249 8.21317C9.78336 8.16953 9.84148 8.12037 9.89618 8.06567L12.3474 5.61441L13.4282 6.69518C13.6048 6.87179 13.9065 6.74347 13.9016 6.4938L13.823 2.4491Z" fill="currentColor"> </path> <path d="M7.25 3.12893C7.66421 3.12893 8 3.46472 8 3.87893C8 4.29315 7.66421 4.62893 7.25 4.62893H4C3.72386 4.62893 3.5 4.85279 3.5 5.12893V11.9929C3.5 12.2691 3.72386 12.4929 4 12.4929H10.864C11.1401 12.4929 11.364 12.2691 11.364 11.9929V8.75C11.364 8.33579 11.6998 8 12.114 8C12.5282 8 12.864 8.33579 12.864 8.75V11.9929C12.864 13.0975 11.9686 13.9929 10.864 13.9929H4C2.89543 13.9929 2 13.0975 2 11.9929V5.12893C2 4.02436 2.89543 3.12893 4 3.12893H7.25Z" fill="currentColor"> </path> </svg> </a> returns a promise that provides a <code class="leafygreen-ui-1l06pbn"> result </code> . The <code class="leafygreen-ui-1l06pbn"> result.insertedIds </code> field contains an array with the <code class="leafygreen-ui-1l06pbn"> _id </code> of each newly inserted document. </p> <p class="leafygreen-ui-1kp3ins"> To retrieve the inserted documents, <a class="leafygreen-ui-tqgtui" href="/docs/manual/tutorial/query-documents/#std-label-read-operations-query-document"> query the collection <!-- --> : </a> </p> </div> </div> </div> <div> <div aria-labelledby="_lg1k7yrff" class="leafygreen-ui-38lglc" id="_5pxzitovn" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <p class="leafygreen-ui-1kp3ins"> Upon successful insert, the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://metacpan.org/pod/MongoDB::Collection#insert_many" rel="noopener noreferrer"> <span> insert_many() </span> <svg alt="" aria-hidden="true" class="leafygreen-ui-1ie5kuq" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M13.823 2.4491C13.8201 2.30008 13.6999 2.17994 13.5509 2.17704L9.5062 2.09836C9.25654 2.09351 9.12821 2.39519 9.30482 2.5718L10.3856 3.65257L7.93433 6.10383C7.87964 6.15852 7.83047 6.21665 7.78683 6.27752L5.99909 8.06525C5.46457 8.59977 5.46457 9.4664 5.99909 10.0009C6.53361 10.5354 7.40023 10.5354 7.93475 10.0009L9.72249 8.21317C9.78336 8.16953 9.84148 8.12037 9.89618 8.06567L12.3474 5.61441L13.4282 6.69518C13.6048 6.87179 13.9065 6.74347 13.9016 6.4938L13.823 2.4491Z" fill="currentColor"> </path> <path d="M7.25 3.12893C7.66421 3.12893 8 3.46472 8 3.87893C8 4.29315 7.66421 4.62893 7.25 4.62893H4C3.72386 4.62893 3.5 4.85279 3.5 5.12893V11.9929C3.5 12.2691 3.72386 12.4929 4 12.4929H10.864C11.1401 12.4929 11.364 12.2691 11.364 11.9929V8.75C11.364 8.33579 11.6998 8 12.114 8C12.5282 8 12.864 8.33579 12.864 8.75V11.9929C12.864 13.0975 11.9686 13.9929 10.864 13.9929H4C2.89543 13.9929 2 13.0975 2 11.9929V5.12893C2 4.02436 2.89543 3.12893 4 3.12893H7.25Z" fill="currentColor"> </path> </svg> </a> method returns an instance of <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://metacpan.org/pod/MongoDB::InsertManyResult" rel="noopener noreferrer"> <span> MongoDB::InsertManyResult </span> <svg alt="" aria-hidden="true" class="leafygreen-ui-1ie5kuq" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M13.823 2.4491C13.8201 2.30008 13.6999 2.17994 13.5509 2.17704L9.5062 2.09836C9.25654 2.09351 9.12821 2.39519 9.30482 2.5718L10.3856 3.65257L7.93433 6.10383C7.87964 6.15852 7.83047 6.21665 7.78683 6.27752L5.99909 8.06525C5.46457 8.59977 5.46457 9.4664 5.99909 10.0009C6.53361 10.5354 7.40023 10.5354 7.93475 10.0009L9.72249 8.21317C9.78336 8.16953 9.84148 8.12037 9.89618 8.06567L12.3474 5.61441L13.4282 6.69518C13.6048 6.87179 13.9065 6.74347 13.9016 6.4938L13.823 2.4491Z" fill="currentColor"> </path> <path d="M7.25 3.12893C7.66421 3.12893 8 3.46472 8 3.87893C8 4.29315 7.66421 4.62893 7.25 4.62893H4C3.72386 4.62893 3.5 4.85279 3.5 5.12893V11.9929C3.5 12.2691 3.72386 12.4929 4 12.4929H10.864C11.1401 12.4929 11.364 12.2691 11.364 11.9929V8.75C11.364 8.33579 11.6998 8 12.114 8C12.5282 8 12.864 8.33579 12.864 8.75V11.9929C12.864 13.0975 11.9686 13.9929 10.864 13.9929H4C2.89543 13.9929 2 13.0975 2 11.9929V5.12893C2 4.02436 2.89543 3.12893 4 3.12893H7.25Z" fill="currentColor"> </path> </svg> </a> whose <code class="leafygreen-ui-1l06pbn"> inserted_ids </code> attribute is a list containing the <code class="leafygreen-ui-1l06pbn"> _id </code> of each newly inserted document. </p> <p class="leafygreen-ui-1kp3ins"> To retrieve the inserted documents, <a class="leafygreen-ui-tqgtui" href="/docs/manual/tutorial/query-documents/#std-label-read-operations-query-document"> query the collection <!-- --> : </a> </p> </div> </div> </div> <div> <div aria-labelledby="_nbfo6vc1n" class="leafygreen-ui-38lglc" id="_6vli3843e" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <p class="leafygreen-ui-1kp3ins"> Upon successful insert, the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/php-library/upcoming/reference/method/MongoDBCollection-insertMany/#mongodb-phpmethod-phpmethod.MongoDB-Collection--insertMany--" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> insertMany() </code> </span> </a> method returns an instance of <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/php-library/upcoming/reference/class/MongoDBInsertManyResult/#mongodb-phpclass-phpclass.MongoDB-InsertManyResult" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> MongoDB\\InsertManyResult </code> </span> </a> whose <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/php-library/upcoming/reference/method/MongoDBInsertManyResult-getInsertedIds/#mongodb-phpmethod-phpmethod.MongoDB-InsertManyResult--getInsertedIds--" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> getInsertedIds() </code> </span> </a> method returns the <code class="leafygreen-ui-1l06pbn"> _id </code> of each newly inserted document. </p> <p class="leafygreen-ui-1kp3ins"> To retrieve the inserted documents, <a class="leafygreen-ui-tqgtui" href="/docs/manual/tutorial/query-documents/#std-label-read-operations-query-document"> query the collection <!-- --> : </a> </p> </div> </div> </div> <div> <div aria-labelledby="_kof92xjjp" class="leafygreen-ui-38lglc" id="_ha7kza357" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://pymongo.readthedocs.io/en/stable/api/pymongo/collection.html#pymongo.collection.Collection.insert_many" rel="noopener noreferrer"> <span> <code class="leafygreen-ui-1l06pbn"> insert_many </code> </span> <svg alt="" aria-hidden="true" class="leafygreen-ui-1ie5kuq" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M13.823 2.4491C13.8201 2.30008 13.6999 2.17994 13.5509 2.17704L9.5062 2.09836C9.25654 2.09351 9.12821 2.39519 9.30482 2.5718L10.3856 3.65257L7.93433 6.10383C7.87964 6.15852 7.83047 6.21665 7.78683 6.27752L5.99909 8.06525C5.46457 8.59977 5.46457 9.4664 5.99909 10.0009C6.53361 10.5354 7.40023 10.5354 7.93475 10.0009L9.72249 8.21317C9.78336 8.16953 9.84148 8.12037 9.89618 8.06567L12.3474 5.61441L13.4282 6.69518C13.6048 6.87179 13.9065 6.74347 13.9016 6.4938L13.823 2.4491Z" fill="currentColor"> </path> <path d="M7.25 3.12893C7.66421 3.12893 8 3.46472 8 3.87893C8 4.29315 7.66421 4.62893 7.25 4.62893H4C3.72386 4.62893 3.5 4.85279 3.5 5.12893V11.9929C3.5 12.2691 3.72386 12.4929 4 12.4929H10.864C11.1401 12.4929 11.364 12.2691 11.364 11.9929V8.75C11.364 8.33579 11.6998 8 12.114 8C12.5282 8 12.864 8.33579 12.864 8.75V11.9929C12.864 13.0975 11.9686 13.9929 10.864 13.9929H4C2.89543 13.9929 2 13.0975 2 11.9929V5.12893C2 4.02436 2.89543 3.12893 4 3.12893H7.25Z" fill="currentColor"> </path> </svg> </a> returns an instance of <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://pymongo.readthedocs.io/en/stable/api/pymongo/results.html#pymongo.results.InsertManyResult" rel="noopener noreferrer"> <span> <code class="leafygreen-ui-1l06pbn"> pymongo.results.InsertManyResult </code> </span> <svg alt="" aria-hidden="true" class="leafygreen-ui-1ie5kuq" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M13.823 2.4491C13.8201 2.30008 13.6999 2.17994 13.5509 2.17704L9.5062 2.09836C9.25654 2.09351 9.12821 2.39519 9.30482 2.5718L10.3856 3.65257L7.93433 6.10383C7.87964 6.15852 7.83047 6.21665 7.78683 6.27752L5.99909 8.06525C5.46457 8.59977 5.46457 9.4664 5.99909 10.0009C6.53361 10.5354 7.40023 10.5354 7.93475 10.0009L9.72249 8.21317C9.78336 8.16953 9.84148 8.12037 9.89618 8.06567L12.3474 5.61441L13.4282 6.69518C13.6048 6.87179 13.9065 6.74347 13.9016 6.4938L13.823 2.4491Z" fill="currentColor"> </path> <path d="M7.25 3.12893C7.66421 3.12893 8 3.46472 8 3.87893C8 4.29315 7.66421 4.62893 7.25 4.62893H4C3.72386 4.62893 3.5 4.85279 3.5 5.12893V11.9929C3.5 12.2691 3.72386 12.4929 4 12.4929H10.864C11.1401 12.4929 11.364 12.2691 11.364 11.9929V8.75C11.364 8.33579 11.6998 8 12.114 8C12.5282 8 12.864 8.33579 12.864 8.75V11.9929C12.864 13.0975 11.9686 13.9929 10.864 13.9929H4C2.89543 13.9929 2 13.0975 2 11.9929V5.12893C2 4.02436 2.89543 3.12893 4 3.12893H7.25Z" fill="currentColor"> </path> </svg> </a> whose <code class="leafygreen-ui-1l06pbn"> inserted_ids </code> field is a list containing the <code class="leafygreen-ui-1l06pbn"> _id </code> of each newly inserted document. </p> <p class="leafygreen-ui-1kp3ins"> To retrieve the inserted documents, <a class="leafygreen-ui-tqgtui" href="/docs/manual/tutorial/query-documents/#std-label-read-operations-query-document"> query the collection <!-- --> : </a> </p> </div> </div> </div> <div> <div aria-labelledby="_klakhy5mj" class="leafygreen-ui-38lglc" id="_zhwm3do6p" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <p class="leafygreen-ui-1kp3ins"> Upon successful insert, the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="http://api.mongodb.com/ruby/current/Mongo/Collection.html#insert_many" target="_self"> <span> insert_many() </span> </a> method returns an instance of <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="http://api.mongodb.com/ruby/current/Mongo/BulkWrite/Result.html" target="_self"> <span> Mongo::BulkWrite::Result </span> </a> whose <code class="leafygreen-ui-1l06pbn"> inserted_ids </code> attribute is a list containing the <code class="leafygreen-ui-1l06pbn"> _id </code> of each newly inserted document. </p> <p class="leafygreen-ui-1kp3ins"> To retrieve the inserted documents, <a class="leafygreen-ui-tqgtui" href="/docs/manual/tutorial/query-documents/#std-label-read-operations-query-document"> query the collection <!-- --> : </a> </p> </div> </div> </div> <div> <div aria-labelledby="_d4oilpwca" class="leafygreen-ui-38lglc" id="_m022zsy96" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <p class="leafygreen-ui-1kp3ins"> Upon successful insert, the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="http://mongodb.github.io/mongo-scala-driver/2.9/scaladoc/org/mongodb/scala/MongoCollection.html#insertMany(documents:Seq[_&lt;:TResult],options:org.mongodb.scala.model.InsertManyOptions):org.mongodb.scala.SingleObservable[org.mongodb.scala.Completed]" rel="noopener noreferrer"> <span> insertMany() </span> <svg alt="" aria-hidden="true" class="leafygreen-ui-1ie5kuq" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M13.823 2.4491C13.8201 2.30008 13.6999 2.17994 13.5509 2.17704L9.5062 2.09836C9.25654 2.09351 9.12821 2.39519 9.30482 2.5718L10.3856 3.65257L7.93433 6.10383C7.87964 6.15852 7.83047 6.21665 7.78683 6.27752L5.99909 8.06525C5.46457 8.59977 5.46457 9.4664 5.99909 10.0009C6.53361 10.5354 7.40023 10.5354 7.93475 10.0009L9.72249 8.21317C9.78336 8.16953 9.84148 8.12037 9.89618 8.06567L12.3474 5.61441L13.4282 6.69518C13.6048 6.87179 13.9065 6.74347 13.9016 6.4938L13.823 2.4491Z" fill="currentColor"> </path> <path d="M7.25 3.12893C7.66421 3.12893 8 3.46472 8 3.87893C8 4.29315 7.66421 4.62893 7.25 4.62893H4C3.72386 4.62893 3.5 4.85279 3.5 5.12893V11.9929C3.5 12.2691 3.72386 12.4929 4 12.4929H10.864C11.1401 12.4929 11.364 12.2691 11.364 11.9929V8.75C11.364 8.33579 11.6998 8 12.114 8C12.5282 8 12.864 8.33579 12.864 8.75V11.9929C12.864 13.0975 11.9686 13.9929 10.864 13.9929H4C2.89543 13.9929 2 13.0975 2 11.9929V5.12893C2 4.02436 2.89543 3.12893 4 3.12893H7.25Z" fill="currentColor"> </path> </svg> </a> method returns an <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="http://mongodb.github.io/mongo-scala-driver/2.1/reference/observables/" rel="noopener noreferrer"> <span> Observable </span> <svg alt="" aria-hidden="true" class="leafygreen-ui-1ie5kuq" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M13.823 2.4491C13.8201 2.30008 13.6999 2.17994 13.5509 2.17704L9.5062 2.09836C9.25654 2.09351 9.12821 2.39519 9.30482 2.5718L10.3856 3.65257L7.93433 6.10383C7.87964 6.15852 7.83047 6.21665 7.78683 6.27752L5.99909 8.06525C5.46457 8.59977 5.46457 9.4664 5.99909 10.0009C6.53361 10.5354 7.40023 10.5354 7.93475 10.0009L9.72249 8.21317C9.78336 8.16953 9.84148 8.12037 9.89618 8.06567L12.3474 5.61441L13.4282 6.69518C13.6048 6.87179 13.9065 6.74347 13.9016 6.4938L13.823 2.4491Z" fill="currentColor"> </path> <path d="M7.25 3.12893C7.66421 3.12893 8 3.46472 8 3.87893C8 4.29315 7.66421 4.62893 7.25 4.62893H4C3.72386 4.62893 3.5 4.85279 3.5 5.12893V11.9929C3.5 12.2691 3.72386 12.4929 4 12.4929H10.864C11.1401 12.4929 11.364 12.2691 11.364 11.9929V8.75C11.364 8.33579 11.6998 8 12.114 8C12.5282 8 12.864 8.33579 12.864 8.75V11.9929C12.864 13.0975 11.9686 13.9929 10.864 13.9929H4C2.89543 13.9929 2 13.0975 2 11.9929V5.12893C2 4.02436 2.89543 3.12893 4 3.12893H7.25Z" fill="currentColor"> </path> </svg> </a> with a type parameter indicating when the operation has completed or with either a <code class="leafygreen-ui-1l06pbn"> com.mongodb.DuplicateKeyException </code> or <code class="leafygreen-ui-1l06pbn"> com.mongodb.MongoException </code> . </p> <p class="leafygreen-ui-1kp3ins"> To retrieve the inserted documents, <a class="leafygreen-ui-tqgtui" href="/docs/manual/tutorial/query-documents/#std-label-read-operations-query-document"> query the collection <!-- --> : </a> </p> </div> </div> </div> </div> </div> <div aria-hidden="true"> </div> <div class="leafygreen-ui-f2qztv" data-lgid="lg-tabs"> <div class="leafygreen-ui-jp7pox" id="tabs-18"> <div aria-label="Tabs to describe usage of drivers" aria-orientation="horizontal" class="leafygreen-ui-m8p1vb lg-ui-tab-list-0000" data-lgid="lg-tabs-tab_list" role="tablist"> <button aria-controls="_c5nldtfkc" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_7ff4k897s" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> MongoDB Shell </div> </button> <button aria-controls="_vwv6d7a1h" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_35qnluads" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Compass </div> </button> <button aria-controls="_dj55mxusz" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_w9rjc9tgx" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> C </div> </button> <button aria-controls="_md24sug4s" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_vvkx9kja8" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> C# </div> </button> <button aria-controls="_wzhvewulu" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_sxym80kql" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Go </div> </button> <button aria-controls="_4jhs917hu" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_zwwl8lo46" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Java (Async) </div> </button> <button aria-controls="_e3pwvurr8" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_vn7ikuo12" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Java (Sync) </div> </button> <button aria-controls="_2gs91nna7" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_uk920vuc4" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Kotlin (Coroutine) </div> </button> <button aria-controls="_ztc7dem0b" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_ag3w99cbc" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Motor </div> </button> <button aria-controls="_u01ns2jzg" aria-selected="true" class="leafygreen-ui-1l773z1" data-text="" id="_7dl4y3eai" name="" role="tab" tabindex="0"> <div class="leafygreen-ui-1nxuzmg"> Node.js </div> </button> <button aria-controls="_jyoqgdqjp" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_auiza8ww9" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Perl </div> </button> <button aria-controls="_njqqki1oi" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_od76eu10e" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> PHP </div> </button> <button aria-controls="_2t6l5agg4" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_sn3wo782z" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Python </div> </button> <button aria-controls="_o4wrqgt45" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_ninpxq352" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Ruby </div> </button> <button aria-controls="_3lxz9ov8s" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_i6egcclgp" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Scala </div> </button> </div> <div class="leafygreen-ui-ov1ktg"> <div class="leafygreen-ui-1sg2lsz"> </div> </div> </div> <div class="lg-ui-tab-panels-0000" data-lgid="lg-tabs-tab_panels"> <div> <div aria-labelledby="_kqyfv4cxq" class="leafygreen-ui-38lglc" id="_njn049yr2" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.inventory.find( {} )","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <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">inventory</span>.<span class="lg-highlight-title lg-highlight-function">find</span>( <!-- -->{<!-- -->} )</td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-161-menu" aria-describedby="select-161-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-162" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:r8t:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":r8t:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r8t:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r8t:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_51e97qd7d" class="leafygreen-ui-38lglc" id="_9mn9s2kk2" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <div class="figure css-5vkxs0" style="width:auto"> <div class="gatsby-image-wrapper gatsby-image-wrapper-constrained leafygreen-ui-12xaq6r" data-gatsby-image-wrapper=""> <div style="max-width:769px;display:block"> <img alt="" aria-hidden="true" role="presentation" src="data:image/svg+xml;charset=utf-8,%3Csvg%20height='728'%20width='769'%20xmlns='http://www.w3.org/2000/svg'%20version='1.1'%3E%3C/svg%3E" style="max-width:100%;display:block;position:static"/> </div> <div aria-hidden="true" data-placeholder-image="" style="opacity:1;transition:opacity 500ms linear"> </div> <img alt="Compass select all documents in collection" data-main-image="" decoding="async" height="728" loading="lazy" sizes="(min-width: 769px) 769px, 100vw" src="/docs/manual/static/10de84553f26db9bb923b4f40930d1f9/34491/compass-select-all.webp" srcset="/docs/manual/static/10de84553f26db9bb923b4f40930d1f9/70727/compass-select-all.webp 192w,/docs/manual/static/10de84553f26db9bb923b4f40930d1f9/b61b5/compass-select-all.webp 385w,/docs/manual/static/10de84553f26db9bb923b4f40930d1f9/34491/compass-select-all.webp 769w" style="--border-color:#C1C7C6;opacity:0" width="769"/> <noscript> <img alt="Compass select all documents in collection" data-gatsby-image-ssr="" data-main-image="" decoding="async" height="728" loading="lazy" sizes="(min-width: 769px) 769px, 100vw" src="/docs/manual/static/10de84553f26db9bb923b4f40930d1f9/34491/compass-select-all.webp" srcset="/docs/manual/static/10de84553f26db9bb923b4f40930d1f9/70727/compass-select-all.webp 192w,/docs/manual/static/10de84553f26db9bb923b4f40930d1f9/b61b5/compass-select-all.webp 385w,/docs/manual/static/10de84553f26db9bb923b4f40930d1f9/34491/compass-select-all.webp 769w" style="--border-color:#C1C7C6;opacity:0" width="769"/> </noscript> <script type="module"> const t="undefined"!=typeof HTMLImageElement&&"loading"in HTMLImageElement.prototype;if(t){const t=document.querySelectorAll("img[data-main-image]");for(let e of t){e.dataset.src&&(e.setAttribute("src",e.dataset.src),e.removeAttribute("data-src")),e.dataset.srcset&&(e.setAttribute("srcset",e.dataset.srcset),e.removeAttribute("data-srcset"));const t=e.parentNode.querySelectorAll("source[data-srcset]");for(let e of t)e.setAttribute("srcset",e.dataset.srcset),e.removeAttribute("data-srcset");e.complete&&(e.style.opacity=1,e.parentNode.parentNode.querySelector("[data-placeholder-image]").style.opacity=0)}} </script> </div> </div> </div> </div> </div> <div> <div aria-labelledby="_0uxo4ks2o" class="leafygreen-ui-38lglc" id="_03t9y9ofp" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"mongoc_collection_t *collection;\nbson_t *filter;\nmongoc_cursor_t *cursor;\n\ncollection = mongoc_database_get_collection (db, \"inventory\");\nfilter = BCON_NEW (NULL);\ncursor = mongoc_collection_find_with_opts (collection, filter, NULL, NULL);","programmingLanguage":"C"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <pre class="leafygreen-ui-11itue3" 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">mongoc_collection_t *collection;</td></tr><tr class=""><td class="leafygreen-ui-7razhx">bson_t *filter;</td></tr><tr class=""><td class="leafygreen-ui-7razhx">mongoc_cursor_t *cursor;</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><div class="leafygreen-ui-ihxujy"></div></td></tr><tr class=""><td class="leafygreen-ui-7razhx">collection <!-- -->= <!-- -->mongoc_database_get_collection (db<!-- -->, <span class="lg-highlight-string">"inventory"</span>);</td></tr><tr class=""><td class="leafygreen-ui-7razhx">filter <!-- -->= <!-- --><span class="lg-highlight-variable lg-highlight-constant">BCON_NEW</span> (<!-- --><span class="lg-highlight-variable lg-highlight-constant">NULL</span>);</td></tr><tr class=""><td class="leafygreen-ui-7razhx">cursor <!-- -->= <!-- -->mongoc_collection_find_with_opts (collection, filter<!-- -->, <span class="lg-highlight-variable lg-highlight-constant">NULL</span>, <span class="lg-highlight-variable lg-highlight-constant">NULL</span>);</td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-164-menu" aria-describedby="select-164-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-165" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:r8u:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":r8u:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r8u:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r8u:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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"> Be sure to also clean up any open resources by calling the following methods, as appropriate: </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="http://mongoc.org/libbson/current/bson_destroy.html" rel="noopener noreferrer"> <span> bson_destroy </span> <svg alt="" aria-hidden="true" class="leafygreen-ui-1ie5kuq" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M13.823 2.4491C13.8201 2.30008 13.6999 2.17994 13.5509 2.17704L9.5062 2.09836C9.25654 2.09351 9.12821 2.39519 9.30482 2.5718L10.3856 3.65257L7.93433 6.10383C7.87964 6.15852 7.83047 6.21665 7.78683 6.27752L5.99909 8.06525C5.46457 8.59977 5.46457 9.4664 5.99909 10.0009C6.53361 10.5354 7.40023 10.5354 7.93475 10.0009L9.72249 8.21317C9.78336 8.16953 9.84148 8.12037 9.89618 8.06567L12.3474 5.61441L13.4282 6.69518C13.6048 6.87179 13.9065 6.74347 13.9016 6.4938L13.823 2.4491Z" fill="currentColor"> </path> <path d="M7.25 3.12893C7.66421 3.12893 8 3.46472 8 3.87893C8 4.29315 7.66421 4.62893 7.25 4.62893H4C3.72386 4.62893 3.5 4.85279 3.5 5.12893V11.9929C3.5 12.2691 3.72386 12.4929 4 12.4929H10.864C11.1401 12.4929 11.364 12.2691 11.364 11.9929V8.75C11.364 8.33579 11.6998 8 12.114 8C12.5282 8 12.864 8.33579 12.864 8.75V11.9929C12.864 13.0975 11.9686 13.9929 10.864 13.9929H4C2.89543 13.9929 2 13.0975 2 11.9929V5.12893C2 4.02436 2.89543 3.12893 4 3.12893H7.25Z" fill="currentColor"> </path> </svg> </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://mongoc.org/libmongoc/current/mongoc_bulk_operation_destroy.html" rel="noopener noreferrer"> <span> mongoc_bulk_operation_destroy </span> <svg alt="" aria-hidden="true" class="leafygreen-ui-1ie5kuq" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M13.823 2.4491C13.8201 2.30008 13.6999 2.17994 13.5509 2.17704L9.5062 2.09836C9.25654 2.09351 9.12821 2.39519 9.30482 2.5718L10.3856 3.65257L7.93433 6.10383C7.87964 6.15852 7.83047 6.21665 7.78683 6.27752L5.99909 8.06525C5.46457 8.59977 5.46457 9.4664 5.99909 10.0009C6.53361 10.5354 7.40023 10.5354 7.93475 10.0009L9.72249 8.21317C9.78336 8.16953 9.84148 8.12037 9.89618 8.06567L12.3474 5.61441L13.4282 6.69518C13.6048 6.87179 13.9065 6.74347 13.9016 6.4938L13.823 2.4491Z" fill="currentColor"> </path> <path d="M7.25 3.12893C7.66421 3.12893 8 3.46472 8 3.87893C8 4.29315 7.66421 4.62893 7.25 4.62893H4C3.72386 4.62893 3.5 4.85279 3.5 5.12893V11.9929C3.5 12.2691 3.72386 12.4929 4 12.4929H10.864C11.1401 12.4929 11.364 12.2691 11.364 11.9929V8.75C11.364 8.33579 11.6998 8 12.114 8C12.5282 8 12.864 8.33579 12.864 8.75V11.9929C12.864 13.0975 11.9686 13.9929 10.864 13.9929H4C2.89543 13.9929 2 13.0975 2 11.9929V5.12893C2 4.02436 2.89543 3.12893 4 3.12893H7.25Z" fill="currentColor"> </path> </svg> </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://mongoc.org/libmongoc/current/mongoc_collection_destroy" rel="noopener noreferrer"> <span> mongoc_collection_destroy </span> <svg alt="" aria-hidden="true" class="leafygreen-ui-1ie5kuq" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M13.823 2.4491C13.8201 2.30008 13.6999 2.17994 13.5509 2.17704L9.5062 2.09836C9.25654 2.09351 9.12821 2.39519 9.30482 2.5718L10.3856 3.65257L7.93433 6.10383C7.87964 6.15852 7.83047 6.21665 7.78683 6.27752L5.99909 8.06525C5.46457 8.59977 5.46457 9.4664 5.99909 10.0009C6.53361 10.5354 7.40023 10.5354 7.93475 10.0009L9.72249 8.21317C9.78336 8.16953 9.84148 8.12037 9.89618 8.06567L12.3474 5.61441L13.4282 6.69518C13.6048 6.87179 13.9065 6.74347 13.9016 6.4938L13.823 2.4491Z" fill="currentColor"> </path> <path d="M7.25 3.12893C7.66421 3.12893 8 3.46472 8 3.87893C8 4.29315 7.66421 4.62893 7.25 4.62893H4C3.72386 4.62893 3.5 4.85279 3.5 5.12893V11.9929C3.5 12.2691 3.72386 12.4929 4 12.4929H10.864C11.1401 12.4929 11.364 12.2691 11.364 11.9929V8.75C11.364 8.33579 11.6998 8 12.114 8C12.5282 8 12.864 8.33579 12.864 8.75V11.9929C12.864 13.0975 11.9686 13.9929 10.864 13.9929H4C2.89543 13.9929 2 13.0975 2 11.9929V5.12893C2 4.02436 2.89543 3.12893 4 3.12893H7.25Z" fill="currentColor"> </path> </svg> </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://mongoc.org/libmongoc/current/mongoc_cursor_destroy.html" rel="noopener noreferrer"> <span> mongoc_cursor_destroy <!-- --> , </span> <svg alt="" aria-hidden="true" class="leafygreen-ui-1ie5kuq" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M13.823 2.4491C13.8201 2.30008 13.6999 2.17994 13.5509 2.17704L9.5062 2.09836C9.25654 2.09351 9.12821 2.39519 9.30482 2.5718L10.3856 3.65257L7.93433 6.10383C7.87964 6.15852 7.83047 6.21665 7.78683 6.27752L5.99909 8.06525C5.46457 8.59977 5.46457 9.4664 5.99909 10.0009C6.53361 10.5354 7.40023 10.5354 7.93475 10.0009L9.72249 8.21317C9.78336 8.16953 9.84148 8.12037 9.89618 8.06567L12.3474 5.61441L13.4282 6.69518C13.6048 6.87179 13.9065 6.74347 13.9016 6.4938L13.823 2.4491Z" fill="currentColor"> </path> <path d="M7.25 3.12893C7.66421 3.12893 8 3.46472 8 3.87893C8 4.29315 7.66421 4.62893 7.25 4.62893H4C3.72386 4.62893 3.5 4.85279 3.5 5.12893V11.9929C3.5 12.2691 3.72386 12.4929 4 12.4929H10.864C11.1401 12.4929 11.364 12.2691 11.364 11.9929V8.75C11.364 8.33579 11.6998 8 12.114 8C12.5282 8 12.864 8.33579 12.864 8.75V11.9929C12.864 13.0975 11.9686 13.9929 10.864 13.9929H4C2.89543 13.9929 2 13.0975 2 11.9929V5.12893C2 4.02436 2.89543 3.12893 4 3.12893H7.25Z" fill="currentColor"> </path> </svg> </a> </p> </li> </ul> </div> </div> </div> <div> <div aria-labelledby="_h1sn2pa02" class="leafygreen-ui-38lglc" id="_fuwhjmp7c" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"var filter = Builders&lt;bsondocument&gt;.Filter.Empty;\nvar result = collection.Find(filter).ToList();","programmingLanguage":"C#"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <pre class="leafygreen-ui-11itue3" 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"><span class="lg-highlight-keyword">var</span> filter = <span class="lg-highlight-title lg-highlight-class">Builders</span>&lt;<span class="lg-highlight-title lg-highlight-class">BsonDocument</span>&gt;.<span class="lg-highlight-property">Filter</span>.<span class="lg-highlight-property">Empty</span>;</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-keyword">var</span> result = collection.<span class="lg-highlight-title lg-highlight-class">Find</span>(filter).<span class="lg-highlight-title lg-highlight-class">ToList</span>();</td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-167-menu" aria-describedby="select-167-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-168" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:r8v:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":r8v:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r8v:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r8v:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_jz2k9wo0r" class="leafygreen-ui-38lglc" id="_on5u5x7ow" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"\ncursor, err := coll.Find(\n\tcontext.TODO(),\n\tbson.D{},\n)\n","programmingLanguage":"Golang"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <pre class="leafygreen-ui-11itue3" 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">cursor<!-- -->, <!-- -->err := coll.<span class="lg-highlight-title lg-highlight-class">Find</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> context.<span class="lg-highlight-title lg-highlight-function">TODO</span>(),</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> bson.<span class="lg-highlight-property">D</span>{},</td></tr><tr class=""><td class="leafygreen-ui-7razhx">)</td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-170-menu" aria-describedby="select-170-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-171" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:r90:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":r90:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r90:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r90:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_cdcjwk6kl" class="leafygreen-ui-38lglc" id="_qmtaeh3k8" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"FindPublisher&lt;document&gt; findPublisher = collection.find(new Document());","programmingLanguage":"Java"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <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"><span class="lg-highlight-title lg-highlight-class">FindPublisher</span>&lt;<span class="lg-highlight-title lg-highlight-class">Document</span>&gt; findPublisher = collection.<span class="lg-highlight-title lg-highlight-function">find</span>(<span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">Document</span>());</td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-173-menu" aria-describedby="select-173-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-174" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:r91:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":r91:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r91:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r91:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_i2yneeo2g" class="leafygreen-ui-38lglc" id="_a8t9kpa6n" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"FindIterable&lt;document&gt; findIterable = collection.find(new Document());","programmingLanguage":"Java"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <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"><span class="lg-highlight-title lg-highlight-class">FindIterable</span>&lt;<span class="lg-highlight-title lg-highlight-class">Document</span>&gt; findIterable = collection.<span class="lg-highlight-title lg-highlight-function">find</span>(<span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">Document</span>());</td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-176-menu" aria-describedby="select-176-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-177" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:r92:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":r92:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r92:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r92:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_29rbgqjmo" class="leafygreen-ui-38lglc" id="_kcpjp919e" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"val flowInsertMany = collection\n .find(empty())","programmingLanguage":"Kotlin"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <pre class="leafygreen-ui-11itue3" 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">val flowInsertMany = collection</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> .<span class="lg-highlight-title lg-highlight-function">find</span>(<span class="lg-highlight-title lg-highlight-function">empty</span>())</td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-179-menu" aria-describedby="select-179-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-180" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:r93:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":r93:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r93:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r93:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_e3qdk415p" class="leafygreen-ui-38lglc" id="_ndiz6kyqu" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"cursor = db.inventory.find({})","programmingLanguage":"Python"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <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">cursor = db.<span class="lg-highlight-property">inventory</span>.<span class="lg-highlight-title lg-highlight-function">find</span>({})</td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-182-menu" aria-describedby="select-182-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-183" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:r94:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":r94:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r94:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r94:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_gxtists0f" class="" id="_8gw9a7j96" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"const cursor = db.collection('inventory').find({});","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <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"><span class="lg-highlight-keyword">const</span> cursor <!-- -->= <!-- -->db.<span class="lg-highlight-title lg-highlight-function">collection</span>(<span class="lg-highlight-string">'inventory'</span>).<span class="lg-highlight-title lg-highlight-function">find</span>(<!-- -->{<!-- -->})<!-- -->;</td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-185-menu" aria-describedby="select-185-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-186" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:r95:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":r95:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r95:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r95:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_no68l4k4i" class="leafygreen-ui-38lglc" id="_4ln3o354g" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"$cursor = $db-&gt;coll(\"inventory\")-&gt;find( {} );","programmingLanguage":"Perl"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <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">$cursor<!-- --> <!-- -->= <!-- -->$db<!-- -->-<!-- -->&gt;<!-- --><!-- --><span class="lg-highlight-title lg-highlight-function">coll</span>(<span class="lg-highlight-string">"inventory"</span>)<!-- -->-<!-- -->&gt;<!-- --><!-- --><span class="lg-highlight-title lg-highlight-function">find</span>( <!-- -->{<!-- -->} )<!-- -->;</td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-188-menu" aria-describedby="select-188-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-189" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:r96:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":r96:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r96:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r96:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_iiuuturq9" class="leafygreen-ui-38lglc" id="_1kkxiwmc6" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"$cursor = $db-&gt;inventory-&gt;find([]);","programmingLanguage":"PHP"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <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">$cursor = $db-&gt;<!-- -->inventory-&gt;<span class="lg-highlight-title lg-highlight-function">find</span>([]);</td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-191-menu" aria-describedby="select-191-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-192" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:r97:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":r97:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r97:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r97:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_nij6iecqg" class="leafygreen-ui-38lglc" id="_nelq626sm" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"cursor = db.inventory.find({})","programmingLanguage":"Python"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <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">cursor = db.<span class="lg-highlight-property">inventory</span>.<span class="lg-highlight-title lg-highlight-function">find</span>({})</td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-194-menu" aria-describedby="select-194-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-195" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:r98:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":r98:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r98:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r98:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_js6nyal2i" class="leafygreen-ui-38lglc" id="_dccjq9i32" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"client[:inventory].find({})","programmingLanguage":"Ruby"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <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">client<!-- -->[<!-- -->:inventory].<span class="lg-highlight-title lg-highlight-function">find</span>(<!-- -->{<!-- -->})</td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-197-menu" aria-describedby="select-197-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-198" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:r99:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":r99:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r99:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r99:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_lq0s8q731" class="leafygreen-ui-38lglc" id="_gsht4ax7z" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"var findObservable = collection.find(Document())","programmingLanguage":"Scala"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <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"><span class="lg-highlight-keyword">var</span> findObservable = collection.<span class="lg-highlight-title lg-highlight-function">find</span>(<span class="lg-highlight-title lg-highlight-class">Document</span>())</td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-200-menu" aria-describedby="select-200-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-201" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:r9a:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":r9a:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r9a:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r9a:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> </div> </div> <span class="leafygreen-ui-1qnjd6d" id="std-label-write-op-insert-behavior"> </span> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Insert Behavior <a class="headerlink leafygreen-ui-1kepx47" href="#insert-behavior" 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="insert-behavior"> </div> </a> </h2> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Collection Creation <a class="headerlink leafygreen-ui-1kepx47" href="#collection-creation" 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="collection-creation"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> If the collection does not currently exist, insert operations will create the collection. </p> <span class="leafygreen-ui-1qnjd6d" id="std-label-insert-id-field"> </span> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> <code class="leafygreen-ui-1l06pbn"> _id </code> Field <a class="headerlink leafygreen-ui-1kepx47" href="#_id-field" 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="_id-field"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> In MongoDB, each document stored in a collection requires a unique <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-_id"> _id </a> field that acts as a <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-primary-key"> primary key </a> . If an inserted document omits the <code class="leafygreen-ui-1l06pbn"> _id </code> field, the MongoDB driver automatically generates an <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/bson-types/#std-label-objectid"> ObjectId </a> for the <code class="leafygreen-ui-1l06pbn"> _id </code> field. </p> <p class="leafygreen-ui-1kp3ins"> This also applies to documents inserted through update operations with <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/db.collection.update/#std-label-upsert-parameter"> upsert: true <!-- --> . </a> </p> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Atomicity <a class="headerlink leafygreen-ui-1kepx47" href="#atomicity" 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="atomicity"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> All write operations in MongoDB are atomic on the level of a single document. For more information on MongoDB and atomicity, see <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/write-operations-atomicity/"> Atomicity and Transactions </a> </p> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Write Acknowledgement <a class="headerlink leafygreen-ui-1kepx47" href="#write-acknowledgement" 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="write-acknowledgement"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> With write concerns, you can specify the level of acknowledgment requested from MongoDB for write operations. For details, see <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/write-concern/"> Write Concern <!-- --> . </a> </p> <div aria-hidden="true"> </div> <div class="leafygreen-ui-f2qztv" data-lgid="lg-tabs"> <div class="leafygreen-ui-jp7pox" id="tabs-24"> <div aria-label="Tabs to describe usage of drivers" aria-orientation="horizontal" class="leafygreen-ui-m8p1vb lg-ui-tab-list-0000" data-lgid="lg-tabs-tab_list" role="tablist"> <button aria-controls="_5av8k0237" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_pedmp1wm7" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> MongoDB Shell </div> </button> <button aria-controls="_wildtos8a" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_919ecgszj" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> C </div> </button> <button aria-controls="_7l4h868q3" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_rgpoo9uge" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> C# </div> </button> <button aria-controls="_9a1el7sbk" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_4h6nbwfpu" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Go </div> </button> <button aria-controls="_o2ae1wn2q" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_fvezsg8yr" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Java (Async) </div> </button> <button aria-controls="_kgpnyxxby" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_6bfeho247" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Java (Sync) </div> </button> <button aria-controls="_h17v7mjru" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_dfn1jx5ro" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Kotlin (Coroutine) </div> </button> <button aria-controls="_hfs4rfoxu" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_oz5ggu6sx" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Motor </div> </button> <button aria-controls="_2jguip91z" aria-selected="true" class="leafygreen-ui-1l773z1" data-text="" id="_riatzik77" name="" role="tab" tabindex="0"> <div class="leafygreen-ui-1nxuzmg"> Node.js </div> </button> <button aria-controls="_mc15v4yr8" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_ywlephpdt" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Perl </div> </button> <button aria-controls="_m1apebzox" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_ua00vbj0r" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> PHP </div> </button> <button aria-controls="_pme0817mu" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_z4cpib0of" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Python </div> </button> <button aria-controls="_zwrmn415e" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_wtxetalxg" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Ruby </div> </button> <button aria-controls="_jd6e193v0" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_e2wd8n8hk" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Scala </div> </button> </div> <div class="leafygreen-ui-ov1ktg"> <div class="leafygreen-ui-1sg2lsz"> </div> </div> </div> <div class="lg-ui-tab-panels-0000" data-lgid="lg-tabs-tab_panels"> <div> <div aria-labelledby="_upvmrxk8p" class="leafygreen-ui-38lglc" id="_ubl7vm3ln" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <div class="leafygreen-ui-13vw3ie" role="note"> <h2 class="leafygreen-ui-1fn4p2b"> Tip </h2> <h3 class="leafygreen-ui-144d5kf"> <strong> See also: </strong> </h3> <div class="leafygreen-ui-9mycqc"> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/db.collection.insertOne/#mongodb-method-db.collection.insertOne"> <code class="leafygreen-ui-1l06pbn"> db.collection.insertOne() </code> </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/db.collection.insertMany/#mongodb-method-db.collection.insertMany"> <code class="leafygreen-ui-1l06pbn"> db.collection.insertMany() </code> </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/insert-methods/#std-label-additional-inserts"> Additional Methods for Inserts </a> </p> </li> </ul> </div> </div> </div> </div> </div> <div> <div aria-labelledby="_d9tqkpdxx" class="leafygreen-ui-38lglc" id="_gar50whwi" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <div class="leafygreen-ui-13vw3ie" role="note"> <h2 class="leafygreen-ui-1fn4p2b"> Tip </h2> <h3 class="leafygreen-ui-144d5kf"> <strong> See also: </strong> </h3> <div class="leafygreen-ui-9mycqc"> <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://mongoc.org/libmongoc/current/mongoc_bulk_operation_insert_with_opts.html" rel="noopener noreferrer"> <span> mongoc_bulk_operation_insert_with_opts </span> <svg alt="" aria-hidden="true" class="leafygreen-ui-1ie5kuq" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M13.823 2.4491C13.8201 2.30008 13.6999 2.17994 13.5509 2.17704L9.5062 2.09836C9.25654 2.09351 9.12821 2.39519 9.30482 2.5718L10.3856 3.65257L7.93433 6.10383C7.87964 6.15852 7.83047 6.21665 7.78683 6.27752L5.99909 8.06525C5.46457 8.59977 5.46457 9.4664 5.99909 10.0009C6.53361 10.5354 7.40023 10.5354 7.93475 10.0009L9.72249 8.21317C9.78336 8.16953 9.84148 8.12037 9.89618 8.06567L12.3474 5.61441L13.4282 6.69518C13.6048 6.87179 13.9065 6.74347 13.9016 6.4938L13.823 2.4491Z" fill="currentColor"> </path> <path d="M7.25 3.12893C7.66421 3.12893 8 3.46472 8 3.87893C8 4.29315 7.66421 4.62893 7.25 4.62893H4C3.72386 4.62893 3.5 4.85279 3.5 5.12893V11.9929C3.5 12.2691 3.72386 12.4929 4 12.4929H10.864C11.1401 12.4929 11.364 12.2691 11.364 11.9929V8.75C11.364 8.33579 11.6998 8 12.114 8C12.5282 8 12.864 8.33579 12.864 8.75V11.9929C12.864 13.0975 11.9686 13.9929 10.864 13.9929H4C2.89543 13.9929 2 13.0975 2 11.9929V5.12893C2 4.02436 2.89543 3.12893 4 3.12893H7.25Z" fill="currentColor"> </path> </svg> </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/insert-methods/#std-label-additional-inserts"> Additional Methods for Inserts </a> </p> </li> </ul> </div> </div> </div> </div> </div> <div> <div aria-labelledby="_oz4biebkc" class="leafygreen-ui-38lglc" id="_qdau1mj5e" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <div class="leafygreen-ui-13vw3ie" role="note"> <h2 class="leafygreen-ui-1fn4p2b"> Tip </h2> <h3 class="leafygreen-ui-144d5kf"> <strong> See also: </strong> </h3> <div class="leafygreen-ui-9mycqc"> <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://mongodb.github.io/mongo-csharp-driver/2.10/apidocs/html/M_MongoDB_Driver_IMongoCollection_1_InsertOne.htm" rel="noopener noreferrer"> <span> IMongoCollection.InsertOne() </span> <svg alt="" aria-hidden="true" class="leafygreen-ui-1ie5kuq" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M13.823 2.4491C13.8201 2.30008 13.6999 2.17994 13.5509 2.17704L9.5062 2.09836C9.25654 2.09351 9.12821 2.39519 9.30482 2.5718L10.3856 3.65257L7.93433 6.10383C7.87964 6.15852 7.83047 6.21665 7.78683 6.27752L5.99909 8.06525C5.46457 8.59977 5.46457 9.4664 5.99909 10.0009C6.53361 10.5354 7.40023 10.5354 7.93475 10.0009L9.72249 8.21317C9.78336 8.16953 9.84148 8.12037 9.89618 8.06567L12.3474 5.61441L13.4282 6.69518C13.6048 6.87179 13.9065 6.74347 13.9016 6.4938L13.823 2.4491Z" fill="currentColor"> </path> <path d="M7.25 3.12893C7.66421 3.12893 8 3.46472 8 3.87893C8 4.29315 7.66421 4.62893 7.25 4.62893H4C3.72386 4.62893 3.5 4.85279 3.5 5.12893V11.9929C3.5 12.2691 3.72386 12.4929 4 12.4929H10.864C11.1401 12.4929 11.364 12.2691 11.364 11.9929V8.75C11.364 8.33579 11.6998 8 12.114 8C12.5282 8 12.864 8.33579 12.864 8.75V11.9929C12.864 13.0975 11.9686 13.9929 10.864 13.9929H4C2.89543 13.9929 2 13.0975 2 11.9929V5.12893C2 4.02436 2.89543 3.12893 4 3.12893H7.25Z" fill="currentColor"> </path> </svg> </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://mongodb.github.io/mongo-csharp-driver/2.10/apidocs/html/M_MongoDB_Driver_IMongoCollection_1_InsertMany.htm" rel="noopener noreferrer"> <span> IMongoCollection.InsertMany() </span> <svg alt="" aria-hidden="true" class="leafygreen-ui-1ie5kuq" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M13.823 2.4491C13.8201 2.30008 13.6999 2.17994 13.5509 2.17704L9.5062 2.09836C9.25654 2.09351 9.12821 2.39519 9.30482 2.5718L10.3856 3.65257L7.93433 6.10383C7.87964 6.15852 7.83047 6.21665 7.78683 6.27752L5.99909 8.06525C5.46457 8.59977 5.46457 9.4664 5.99909 10.0009C6.53361 10.5354 7.40023 10.5354 7.93475 10.0009L9.72249 8.21317C9.78336 8.16953 9.84148 8.12037 9.89618 8.06567L12.3474 5.61441L13.4282 6.69518C13.6048 6.87179 13.9065 6.74347 13.9016 6.4938L13.823 2.4491Z" fill="currentColor"> </path> <path d="M7.25 3.12893C7.66421 3.12893 8 3.46472 8 3.87893C8 4.29315 7.66421 4.62893 7.25 4.62893H4C3.72386 4.62893 3.5 4.85279 3.5 5.12893V11.9929C3.5 12.2691 3.72386 12.4929 4 12.4929H10.864C11.1401 12.4929 11.364 12.2691 11.364 11.9929V8.75C11.364 8.33579 11.6998 8 12.114 8C12.5282 8 12.864 8.33579 12.864 8.75V11.9929C12.864 13.0975 11.9686 13.9929 10.864 13.9929H4C2.89543 13.9929 2 13.0975 2 11.9929V5.12893C2 4.02436 2.89543 3.12893 4 3.12893H7.25Z" fill="currentColor"> </path> </svg> </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/insert-methods/#std-label-additional-inserts"> Additional Methods for Inserts </a> </p> </li> </ul> </div> </div> </div> </div> </div> <div> <div aria-labelledby="_3ucvfkccw" class="leafygreen-ui-38lglc" id="_1i4o2pcbc" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <div class="leafygreen-ui-13vw3ie" role="note"> <h2 class="leafygreen-ui-1fn4p2b"> Tip </h2> <h3 class="leafygreen-ui-144d5kf"> <strong> See also: </strong> </h3> <div class="leafygreen-ui-9mycqc"> <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://godoc.org/github.com/mongodb/mongo-go-driver/mongo#Collection.InsertOne" rel="noopener noreferrer"> <span> Collection.InsertOne </span> <svg alt="" aria-hidden="true" class="leafygreen-ui-1ie5kuq" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M13.823 2.4491C13.8201 2.30008 13.6999 2.17994 13.5509 2.17704L9.5062 2.09836C9.25654 2.09351 9.12821 2.39519 9.30482 2.5718L10.3856 3.65257L7.93433 6.10383C7.87964 6.15852 7.83047 6.21665 7.78683 6.27752L5.99909 8.06525C5.46457 8.59977 5.46457 9.4664 5.99909 10.0009C6.53361 10.5354 7.40023 10.5354 7.93475 10.0009L9.72249 8.21317C9.78336 8.16953 9.84148 8.12037 9.89618 8.06567L12.3474 5.61441L13.4282 6.69518C13.6048 6.87179 13.9065 6.74347 13.9016 6.4938L13.823 2.4491Z" fill="currentColor"> </path> <path d="M7.25 3.12893C7.66421 3.12893 8 3.46472 8 3.87893C8 4.29315 7.66421 4.62893 7.25 4.62893H4C3.72386 4.62893 3.5 4.85279 3.5 5.12893V11.9929C3.5 12.2691 3.72386 12.4929 4 12.4929H10.864C11.1401 12.4929 11.364 12.2691 11.364 11.9929V8.75C11.364 8.33579 11.6998 8 12.114 8C12.5282 8 12.864 8.33579 12.864 8.75V11.9929C12.864 13.0975 11.9686 13.9929 10.864 13.9929H4C2.89543 13.9929 2 13.0975 2 11.9929V5.12893C2 4.02436 2.89543 3.12893 4 3.12893H7.25Z" fill="currentColor"> </path> </svg> </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://godoc.org/github.com/mongodb/mongo-go-driver/mongo#Collection.InsertMany" rel="noopener noreferrer"> <span> Collection.InsertMany </span> <svg alt="" aria-hidden="true" class="leafygreen-ui-1ie5kuq" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M13.823 2.4491C13.8201 2.30008 13.6999 2.17994 13.5509 2.17704L9.5062 2.09836C9.25654 2.09351 9.12821 2.39519 9.30482 2.5718L10.3856 3.65257L7.93433 6.10383C7.87964 6.15852 7.83047 6.21665 7.78683 6.27752L5.99909 8.06525C5.46457 8.59977 5.46457 9.4664 5.99909 10.0009C6.53361 10.5354 7.40023 10.5354 7.93475 10.0009L9.72249 8.21317C9.78336 8.16953 9.84148 8.12037 9.89618 8.06567L12.3474 5.61441L13.4282 6.69518C13.6048 6.87179 13.9065 6.74347 13.9016 6.4938L13.823 2.4491Z" fill="currentColor"> </path> <path d="M7.25 3.12893C7.66421 3.12893 8 3.46472 8 3.87893C8 4.29315 7.66421 4.62893 7.25 4.62893H4C3.72386 4.62893 3.5 4.85279 3.5 5.12893V11.9929C3.5 12.2691 3.72386 12.4929 4 12.4929H10.864C11.1401 12.4929 11.364 12.2691 11.364 11.9929V8.75C11.364 8.33579 11.6998 8 12.114 8C12.5282 8 12.864 8.33579 12.864 8.75V11.9929C12.864 13.0975 11.9686 13.9929 10.864 13.9929H4C2.89543 13.9929 2 13.0975 2 11.9929V5.12893C2 4.02436 2.89543 3.12893 4 3.12893H7.25Z" fill="currentColor"> </path> </svg> </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/insert-methods/#std-label-additional-inserts"> Additional Methods for Inserts </a> </p> </li> </ul> </div> </div> </div> </div> </div> <div> <div aria-labelledby="_wd4wdevns" class="leafygreen-ui-38lglc" id="_ggkjbw67u" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <div class="leafygreen-ui-13vw3ie" role="note"> <h2 class="leafygreen-ui-1fn4p2b"> Tip </h2> <h3 class="leafygreen-ui-144d5kf"> <strong> See also: </strong> </h3> <div class="leafygreen-ui-9mycqc"> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="http://mongodb.github.io/mongo-java-driver-reactivestreams/1.6/javadoc/com/mongodb/reactivestreams/client/MongoCollection.html#insertOne(TDocument)" rel="noopener noreferrer"> <span> com.mongodb.reactivestreams.client.MongoCollection.insertOne </span> <svg alt="" aria-hidden="true" class="leafygreen-ui-1ie5kuq" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M13.823 2.4491C13.8201 2.30008 13.6999 2.17994 13.5509 2.17704L9.5062 2.09836C9.25654 2.09351 9.12821 2.39519 9.30482 2.5718L10.3856 3.65257L7.93433 6.10383C7.87964 6.15852 7.83047 6.21665 7.78683 6.27752L5.99909 8.06525C5.46457 8.59977 5.46457 9.4664 5.99909 10.0009C6.53361 10.5354 7.40023 10.5354 7.93475 10.0009L9.72249 8.21317C9.78336 8.16953 9.84148 8.12037 9.89618 8.06567L12.3474 5.61441L13.4282 6.69518C13.6048 6.87179 13.9065 6.74347 13.9016 6.4938L13.823 2.4491Z" fill="currentColor"> </path> <path d="M7.25 3.12893C7.66421 3.12893 8 3.46472 8 3.87893C8 4.29315 7.66421 4.62893 7.25 4.62893H4C3.72386 4.62893 3.5 4.85279 3.5 5.12893V11.9929C3.5 12.2691 3.72386 12.4929 4 12.4929H10.864C11.1401 12.4929 11.364 12.2691 11.364 11.9929V8.75C11.364 8.33579 11.6998 8 12.114 8C12.5282 8 12.864 8.33579 12.864 8.75V11.9929C12.864 13.0975 11.9686 13.9929 10.864 13.9929H4C2.89543 13.9929 2 13.0975 2 11.9929V5.12893C2 4.02436 2.89543 3.12893 4 3.12893H7.25Z" fill="currentColor"> </path> </svg> </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="http://mongodb.github.io/mongo-java-driver-reactivestreams/1.6/javadoc/com/mongodb/reactivestreams/client/MongoCollection.html#insertMany(java.util.List)" rel="noopener noreferrer"> <span> com.mongodb.reactivestreams.client.MongoCollection.html.insertMany </span> <svg alt="" aria-hidden="true" class="leafygreen-ui-1ie5kuq" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M13.823 2.4491C13.8201 2.30008 13.6999 2.17994 13.5509 2.17704L9.5062 2.09836C9.25654 2.09351 9.12821 2.39519 9.30482 2.5718L10.3856 3.65257L7.93433 6.10383C7.87964 6.15852 7.83047 6.21665 7.78683 6.27752L5.99909 8.06525C5.46457 8.59977 5.46457 9.4664 5.99909 10.0009C6.53361 10.5354 7.40023 10.5354 7.93475 10.0009L9.72249 8.21317C9.78336 8.16953 9.84148 8.12037 9.89618 8.06567L12.3474 5.61441L13.4282 6.69518C13.6048 6.87179 13.9065 6.74347 13.9016 6.4938L13.823 2.4491Z" fill="currentColor"> </path> <path d="M7.25 3.12893C7.66421 3.12893 8 3.46472 8 3.87893C8 4.29315 7.66421 4.62893 7.25 4.62893H4C3.72386 4.62893 3.5 4.85279 3.5 5.12893V11.9929C3.5 12.2691 3.72386 12.4929 4 12.4929H10.864C11.1401 12.4929 11.364 12.2691 11.364 11.9929V8.75C11.364 8.33579 11.6998 8 12.114 8C12.5282 8 12.864 8.33579 12.864 8.75V11.9929C12.864 13.0975 11.9686 13.9929 10.864 13.9929H4C2.89543 13.9929 2 13.0975 2 11.9929V5.12893C2 4.02436 2.89543 3.12893 4 3.12893H7.25Z" fill="currentColor"> </path> </svg> </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="http://mongodb.github.io/mongo-java-driver-reactivestreams/1.6/getting-started/quick-tour/" rel="noopener noreferrer"> <span> Java Reactive Streams Driver Quick Tour </span> <svg alt="" aria-hidden="true" class="leafygreen-ui-1ie5kuq" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M13.823 2.4491C13.8201 2.30008 13.6999 2.17994 13.5509 2.17704L9.5062 2.09836C9.25654 2.09351 9.12821 2.39519 9.30482 2.5718L10.3856 3.65257L7.93433 6.10383C7.87964 6.15852 7.83047 6.21665 7.78683 6.27752L5.99909 8.06525C5.46457 8.59977 5.46457 9.4664 5.99909 10.0009C6.53361 10.5354 7.40023 10.5354 7.93475 10.0009L9.72249 8.21317C9.78336 8.16953 9.84148 8.12037 9.89618 8.06567L12.3474 5.61441L13.4282 6.69518C13.6048 6.87179 13.9065 6.74347 13.9016 6.4938L13.823 2.4491Z" fill="currentColor"> </path> <path d="M7.25 3.12893C7.66421 3.12893 8 3.46472 8 3.87893C8 4.29315 7.66421 4.62893 7.25 4.62893H4C3.72386 4.62893 3.5 4.85279 3.5 5.12893V11.9929C3.5 12.2691 3.72386 12.4929 4 12.4929H10.864C11.1401 12.4929 11.364 12.2691 11.364 11.9929V8.75C11.364 8.33579 11.6998 8 12.114 8C12.5282 8 12.864 8.33579 12.864 8.75V11.9929C12.864 13.0975 11.9686 13.9929 10.864 13.9929H4C2.89543 13.9929 2 13.0975 2 11.9929V5.12893C2 4.02436 2.89543 3.12893 4 3.12893H7.25Z" fill="currentColor"> </path> </svg> </a> </p> </li> </ul> </div> </div> </div> </div> </div> <div> <div aria-labelledby="_9bszel44t" class="leafygreen-ui-38lglc" id="_pj462028z" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <div class="leafygreen-ui-13vw3ie" role="note"> <h2 class="leafygreen-ui-1fn4p2b"> Tip </h2> <h3 class="leafygreen-ui-144d5kf"> <strong> See also: </strong> </h3> <div class="leafygreen-ui-9mycqc"> <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://mongodb.github.io/mongo-java-driver/3.4/javadoc/com/mongodb/client/MongoCollection.html#insertOne-TDocument-" rel="noopener noreferrer"> <span> com.mongodb.client.MongoCollection.insertOne </span> <svg alt="" aria-hidden="true" class="leafygreen-ui-1ie5kuq" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M13.823 2.4491C13.8201 2.30008 13.6999 2.17994 13.5509 2.17704L9.5062 2.09836C9.25654 2.09351 9.12821 2.39519 9.30482 2.5718L10.3856 3.65257L7.93433 6.10383C7.87964 6.15852 7.83047 6.21665 7.78683 6.27752L5.99909 8.06525C5.46457 8.59977 5.46457 9.4664 5.99909 10.0009C6.53361 10.5354 7.40023 10.5354 7.93475 10.0009L9.72249 8.21317C9.78336 8.16953 9.84148 8.12037 9.89618 8.06567L12.3474 5.61441L13.4282 6.69518C13.6048 6.87179 13.9065 6.74347 13.9016 6.4938L13.823 2.4491Z" fill="currentColor"> </path> <path d="M7.25 3.12893C7.66421 3.12893 8 3.46472 8 3.87893C8 4.29315 7.66421 4.62893 7.25 4.62893H4C3.72386 4.62893 3.5 4.85279 3.5 5.12893V11.9929C3.5 12.2691 3.72386 12.4929 4 12.4929H10.864C11.1401 12.4929 11.364 12.2691 11.364 11.9929V8.75C11.364 8.33579 11.6998 8 12.114 8C12.5282 8 12.864 8.33579 12.864 8.75V11.9929C12.864 13.0975 11.9686 13.9929 10.864 13.9929H4C2.89543 13.9929 2 13.0975 2 11.9929V5.12893C2 4.02436 2.89543 3.12893 4 3.12893H7.25Z" fill="currentColor"> </path> </svg> </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://mongodb.github.io/mongo-java-driver/3.4/javadoc/com/mongodb/client/MongoCollection.html#insertMany-java.util.List-" rel="noopener noreferrer"> <span> com.mongodb.client.MongoCollection.insertMany </span> <svg alt="" aria-hidden="true" class="leafygreen-ui-1ie5kuq" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M13.823 2.4491C13.8201 2.30008 13.6999 2.17994 13.5509 2.17704L9.5062 2.09836C9.25654 2.09351 9.12821 2.39519 9.30482 2.5718L10.3856 3.65257L7.93433 6.10383C7.87964 6.15852 7.83047 6.21665 7.78683 6.27752L5.99909 8.06525C5.46457 8.59977 5.46457 9.4664 5.99909 10.0009C6.53361 10.5354 7.40023 10.5354 7.93475 10.0009L9.72249 8.21317C9.78336 8.16953 9.84148 8.12037 9.89618 8.06567L12.3474 5.61441L13.4282 6.69518C13.6048 6.87179 13.9065 6.74347 13.9016 6.4938L13.823 2.4491Z" fill="currentColor"> </path> <path d="M7.25 3.12893C7.66421 3.12893 8 3.46472 8 3.87893C8 4.29315 7.66421 4.62893 7.25 4.62893H4C3.72386 4.62893 3.5 4.85279 3.5 5.12893V11.9929C3.5 12.2691 3.72386 12.4929 4 12.4929H10.864C11.1401 12.4929 11.364 12.2691 11.364 11.9929V8.75C11.364 8.33579 11.6998 8 12.114 8C12.5282 8 12.864 8.33579 12.864 8.75V11.9929C12.864 13.0975 11.9686 13.9929 10.864 13.9929H4C2.89543 13.9929 2 13.0975 2 11.9929V5.12893C2 4.02436 2.89543 3.12893 4 3.12893H7.25Z" fill="currentColor"> </path> </svg> </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="http://mongodb.github.io/mongo-java-driver/3.4/driver/tutorials/perform-write-operations/" rel="noopener noreferrer"> <span> Additional Java Synchronous Driver Write Examples </span> <svg alt="" aria-hidden="true" class="leafygreen-ui-1ie5kuq" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M13.823 2.4491C13.8201 2.30008 13.6999 2.17994 13.5509 2.17704L9.5062 2.09836C9.25654 2.09351 9.12821 2.39519 9.30482 2.5718L10.3856 3.65257L7.93433 6.10383C7.87964 6.15852 7.83047 6.21665 7.78683 6.27752L5.99909 8.06525C5.46457 8.59977 5.46457 9.4664 5.99909 10.0009C6.53361 10.5354 7.40023 10.5354 7.93475 10.0009L9.72249 8.21317C9.78336 8.16953 9.84148 8.12037 9.89618 8.06567L12.3474 5.61441L13.4282 6.69518C13.6048 6.87179 13.9065 6.74347 13.9016 6.4938L13.823 2.4491Z" fill="currentColor"> </path> <path d="M7.25 3.12893C7.66421 3.12893 8 3.46472 8 3.87893C8 4.29315 7.66421 4.62893 7.25 4.62893H4C3.72386 4.62893 3.5 4.85279 3.5 5.12893V11.9929C3.5 12.2691 3.72386 12.4929 4 12.4929H10.864C11.1401 12.4929 11.364 12.2691 11.364 11.9929V8.75C11.364 8.33579 11.6998 8 12.114 8C12.5282 8 12.864 8.33579 12.864 8.75V11.9929C12.864 13.0975 11.9686 13.9929 10.864 13.9929H4C2.89543 13.9929 2 13.0975 2 11.9929V5.12893C2 4.02436 2.89543 3.12893 4 3.12893H7.25Z" fill="currentColor"> </path> </svg> </a> </p> </li> </ul> </div> </div> </div> </div> </div> <div> <div aria-labelledby="_msor86ufj" class="leafygreen-ui-38lglc" id="_qnqm6c1c9" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <div class="leafygreen-ui-13vw3ie" role="note"> <h2 class="leafygreen-ui-1fn4p2b"> Tip </h2> <h3 class="leafygreen-ui-144d5kf"> <strong> See also: </strong> </h3> <div class="leafygreen-ui-9mycqc"> <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://mongodb.github.io/mongo-java-driver/4.11/apidocs/mongodb-driver-kotlin-coroutine/mongodb-driver-kotlin-coroutine/com.mongodb.kotlin.client.coroutine/-mongo-collection/insert-one.html" rel="noopener noreferrer"> <span> MongoCollection.insertOne </span> <svg alt="" aria-hidden="true" class="leafygreen-ui-1ie5kuq" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M13.823 2.4491C13.8201 2.30008 13.6999 2.17994 13.5509 2.17704L9.5062 2.09836C9.25654 2.09351 9.12821 2.39519 9.30482 2.5718L10.3856 3.65257L7.93433 6.10383C7.87964 6.15852 7.83047 6.21665 7.78683 6.27752L5.99909 8.06525C5.46457 8.59977 5.46457 9.4664 5.99909 10.0009C6.53361 10.5354 7.40023 10.5354 7.93475 10.0009L9.72249 8.21317C9.78336 8.16953 9.84148 8.12037 9.89618 8.06567L12.3474 5.61441L13.4282 6.69518C13.6048 6.87179 13.9065 6.74347 13.9016 6.4938L13.823 2.4491Z" fill="currentColor"> </path> <path d="M7.25 3.12893C7.66421 3.12893 8 3.46472 8 3.87893C8 4.29315 7.66421 4.62893 7.25 4.62893H4C3.72386 4.62893 3.5 4.85279 3.5 5.12893V11.9929C3.5 12.2691 3.72386 12.4929 4 12.4929H10.864C11.1401 12.4929 11.364 12.2691 11.364 11.9929V8.75C11.364 8.33579 11.6998 8 12.114 8C12.5282 8 12.864 8.33579 12.864 8.75V11.9929C12.864 13.0975 11.9686 13.9929 10.864 13.9929H4C2.89543 13.9929 2 13.0975 2 11.9929V5.12893C2 4.02436 2.89543 3.12893 4 3.12893H7.25Z" fill="currentColor"> </path> </svg> </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://mongodb.github.io/mongo-java-driver/4.11/apidocs/mongodb-driver-kotlin-coroutine/mongodb-driver-kotlin-coroutine/com.mongodb.kotlin.client.coroutine/-mongo-collection/insert-many.html" rel="noopener noreferrer"> <span> MongoCollection.insertMany </span> <svg alt="" aria-hidden="true" class="leafygreen-ui-1ie5kuq" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M13.823 2.4491C13.8201 2.30008 13.6999 2.17994 13.5509 2.17704L9.5062 2.09836C9.25654 2.09351 9.12821 2.39519 9.30482 2.5718L10.3856 3.65257L7.93433 6.10383C7.87964 6.15852 7.83047 6.21665 7.78683 6.27752L5.99909 8.06525C5.46457 8.59977 5.46457 9.4664 5.99909 10.0009C6.53361 10.5354 7.40023 10.5354 7.93475 10.0009L9.72249 8.21317C9.78336 8.16953 9.84148 8.12037 9.89618 8.06567L12.3474 5.61441L13.4282 6.69518C13.6048 6.87179 13.9065 6.74347 13.9016 6.4938L13.823 2.4491Z" fill="currentColor"> </path> <path d="M7.25 3.12893C7.66421 3.12893 8 3.46472 8 3.87893C8 4.29315 7.66421 4.62893 7.25 4.62893H4C3.72386 4.62893 3.5 4.85279 3.5 5.12893V11.9929C3.5 12.2691 3.72386 12.4929 4 12.4929H10.864C11.1401 12.4929 11.364 12.2691 11.364 11.9929V8.75C11.364 8.33579 11.6998 8 12.114 8C12.5282 8 12.864 8.33579 12.864 8.75V11.9929C12.864 13.0975 11.9686 13.9929 10.864 13.9929H4C2.89543 13.9929 2 13.0975 2 11.9929V5.12893C2 4.02436 2.89543 3.12893 4 3.12893H7.25Z" fill="currentColor"> </path> </svg> </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/drivers/kotlin/coroutine/current/fundamentals/crud/write-operations/insert/" target="_self"> <span> Kotlin Driver Write Operation Examples </span> </a> </p> </li> </ul> </div> </div> </div> </div> </div> <div> <div aria-labelledby="_gc2xj4hzc" class="leafygreen-ui-38lglc" id="_fraa4071w" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <div class="leafygreen-ui-13vw3ie" role="note"> <h2 class="leafygreen-ui-1fn4p2b"> Tip </h2> <h3 class="leafygreen-ui-144d5kf"> <strong> See also: </strong> </h3> <div class="leafygreen-ui-9mycqc"> <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://motor.readthedocs.io/en/stable/api-asyncio/asyncio_motor_collection.html#motor.motor_asyncio.AsyncIOMotorCollection.insert_one" rel="noopener noreferrer"> <span> <code class="leafygreen-ui-1l06pbn"> motor.motor_asyncio.AsyncIOMotorCollection.insert_one </code> </span> <svg alt="" aria-hidden="true" class="leafygreen-ui-1ie5kuq" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M13.823 2.4491C13.8201 2.30008 13.6999 2.17994 13.5509 2.17704L9.5062 2.09836C9.25654 2.09351 9.12821 2.39519 9.30482 2.5718L10.3856 3.65257L7.93433 6.10383C7.87964 6.15852 7.83047 6.21665 7.78683 6.27752L5.99909 8.06525C5.46457 8.59977 5.46457 9.4664 5.99909 10.0009C6.53361 10.5354 7.40023 10.5354 7.93475 10.0009L9.72249 8.21317C9.78336 8.16953 9.84148 8.12037 9.89618 8.06567L12.3474 5.61441L13.4282 6.69518C13.6048 6.87179 13.9065 6.74347 13.9016 6.4938L13.823 2.4491Z" fill="currentColor"> </path> <path d="M7.25 3.12893C7.66421 3.12893 8 3.46472 8 3.87893C8 4.29315 7.66421 4.62893 7.25 4.62893H4C3.72386 4.62893 3.5 4.85279 3.5 5.12893V11.9929C3.5 12.2691 3.72386 12.4929 4 12.4929H10.864C11.1401 12.4929 11.364 12.2691 11.364 11.9929V8.75C11.364 8.33579 11.6998 8 12.114 8C12.5282 8 12.864 8.33579 12.864 8.75V11.9929C12.864 13.0975 11.9686 13.9929 10.864 13.9929H4C2.89543 13.9929 2 13.0975 2 11.9929V5.12893C2 4.02436 2.89543 3.12893 4 3.12893H7.25Z" fill="currentColor"> </path> </svg> </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://motor.readthedocs.io/en/stable/api-asyncio/asyncio_motor_collection.html#motor.motor_asyncio.AsyncIOMotorCollection.insert_many" rel="noopener noreferrer"> <span> <code class="leafygreen-ui-1l06pbn"> motor.motor_asyncio.AsyncIOMotorCollection.insert_many </code> </span> <svg alt="" aria-hidden="true" class="leafygreen-ui-1ie5kuq" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M13.823 2.4491C13.8201 2.30008 13.6999 2.17994 13.5509 2.17704L9.5062 2.09836C9.25654 2.09351 9.12821 2.39519 9.30482 2.5718L10.3856 3.65257L7.93433 6.10383C7.87964 6.15852 7.83047 6.21665 7.78683 6.27752L5.99909 8.06525C5.46457 8.59977 5.46457 9.4664 5.99909 10.0009C6.53361 10.5354 7.40023 10.5354 7.93475 10.0009L9.72249 8.21317C9.78336 8.16953 9.84148 8.12037 9.89618 8.06567L12.3474 5.61441L13.4282 6.69518C13.6048 6.87179 13.9065 6.74347 13.9016 6.4938L13.823 2.4491Z" fill="currentColor"> </path> <path d="M7.25 3.12893C7.66421 3.12893 8 3.46472 8 3.87893C8 4.29315 7.66421 4.62893 7.25 4.62893H4C3.72386 4.62893 3.5 4.85279 3.5 5.12893V11.9929C3.5 12.2691 3.72386 12.4929 4 12.4929H10.864C11.1401 12.4929 11.364 12.2691 11.364 11.9929V8.75C11.364 8.33579 11.6998 8 12.114 8C12.5282 8 12.864 8.33579 12.864 8.75V11.9929C12.864 13.0975 11.9686 13.9929 10.864 13.9929H4C2.89543 13.9929 2 13.0975 2 11.9929V5.12893C2 4.02436 2.89543 3.12893 4 3.12893H7.25Z" fill="currentColor"> </path> </svg> </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/insert-methods/#std-label-additional-inserts"> Additional Methods for Inserts </a> </p> </li> </ul> </div> </div> </div> </div> </div> <div> <div aria-labelledby="_zjejrvwmi" class="" id="_c1tknbwbs" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <div class="leafygreen-ui-13vw3ie" role="note"> <h2 class="leafygreen-ui-1fn4p2b"> Tip </h2> <h3 class="leafygreen-ui-144d5kf"> <strong> See also: </strong> </h3> <div class="leafygreen-ui-9mycqc"> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="http://mongodb.github.io/node-mongodb-native/3.6/api/Collection.html#insertOne" rel="noopener noreferrer"> <span> Collection.insertOne() </span> <svg alt="" aria-hidden="true" class="leafygreen-ui-1ie5kuq" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M13.823 2.4491C13.8201 2.30008 13.6999 2.17994 13.5509 2.17704L9.5062 2.09836C9.25654 2.09351 9.12821 2.39519 9.30482 2.5718L10.3856 3.65257L7.93433 6.10383C7.87964 6.15852 7.83047 6.21665 7.78683 6.27752L5.99909 8.06525C5.46457 8.59977 5.46457 9.4664 5.99909 10.0009C6.53361 10.5354 7.40023 10.5354 7.93475 10.0009L9.72249 8.21317C9.78336 8.16953 9.84148 8.12037 9.89618 8.06567L12.3474 5.61441L13.4282 6.69518C13.6048 6.87179 13.9065 6.74347 13.9016 6.4938L13.823 2.4491Z" fill="currentColor"> </path> <path d="M7.25 3.12893C7.66421 3.12893 8 3.46472 8 3.87893C8 4.29315 7.66421 4.62893 7.25 4.62893H4C3.72386 4.62893 3.5 4.85279 3.5 5.12893V11.9929C3.5 12.2691 3.72386 12.4929 4 12.4929H10.864C11.1401 12.4929 11.364 12.2691 11.364 11.9929V8.75C11.364 8.33579 11.6998 8 12.114 8C12.5282 8 12.864 8.33579 12.864 8.75V11.9929C12.864 13.0975 11.9686 13.9929 10.864 13.9929H4C2.89543 13.9929 2 13.0975 2 11.9929V5.12893C2 4.02436 2.89543 3.12893 4 3.12893H7.25Z" fill="currentColor"> </path> </svg> </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="http://mongodb.github.io/node-mongodb-native/3.6/api/Collection.html#insertMany" rel="noopener noreferrer"> <span> Collection.insertMany() </span> <svg alt="" aria-hidden="true" class="leafygreen-ui-1ie5kuq" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M13.823 2.4491C13.8201 2.30008 13.6999 2.17994 13.5509 2.17704L9.5062 2.09836C9.25654 2.09351 9.12821 2.39519 9.30482 2.5718L10.3856 3.65257L7.93433 6.10383C7.87964 6.15852 7.83047 6.21665 7.78683 6.27752L5.99909 8.06525C5.46457 8.59977 5.46457 9.4664 5.99909 10.0009C6.53361 10.5354 7.40023 10.5354 7.93475 10.0009L9.72249 8.21317C9.78336 8.16953 9.84148 8.12037 9.89618 8.06567L12.3474 5.61441L13.4282 6.69518C13.6048 6.87179 13.9065 6.74347 13.9016 6.4938L13.823 2.4491Z" fill="currentColor"> </path> <path d="M7.25 3.12893C7.66421 3.12893 8 3.46472 8 3.87893C8 4.29315 7.66421 4.62893 7.25 4.62893H4C3.72386 4.62893 3.5 4.85279 3.5 5.12893V11.9929C3.5 12.2691 3.72386 12.4929 4 12.4929H10.864C11.1401 12.4929 11.364 12.2691 11.364 11.9929V8.75C11.364 8.33579 11.6998 8 12.114 8C12.5282 8 12.864 8.33579 12.864 8.75V11.9929C12.864 13.0975 11.9686 13.9929 10.864 13.9929H4C2.89543 13.9929 2 13.0975 2 11.9929V5.12893C2 4.02436 2.89543 3.12893 4 3.12893H7.25Z" fill="currentColor"> </path> </svg> </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/insert-methods/#std-label-additional-inserts"> Additional Methods for Inserts </a> </p> </li> </ul> </div> </div> </div> </div> </div> <div> <div aria-labelledby="_xj43ybn5x" class="leafygreen-ui-38lglc" id="_skggpmd8e" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <div class="leafygreen-ui-13vw3ie" role="note"> <h2 class="leafygreen-ui-1fn4p2b"> Tip </h2> <h3 class="leafygreen-ui-144d5kf"> <strong> See also: </strong> </h3> <div class="leafygreen-ui-9mycqc"> <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://metacpan.org/pod/MongoDB::Collection#insert_one" rel="noopener noreferrer"> <span> MongoDB::Collection::insert_one() </span> <svg alt="" aria-hidden="true" class="leafygreen-ui-1ie5kuq" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M13.823 2.4491C13.8201 2.30008 13.6999 2.17994 13.5509 2.17704L9.5062 2.09836C9.25654 2.09351 9.12821 2.39519 9.30482 2.5718L10.3856 3.65257L7.93433 6.10383C7.87964 6.15852 7.83047 6.21665 7.78683 6.27752L5.99909 8.06525C5.46457 8.59977 5.46457 9.4664 5.99909 10.0009C6.53361 10.5354 7.40023 10.5354 7.93475 10.0009L9.72249 8.21317C9.78336 8.16953 9.84148 8.12037 9.89618 8.06567L12.3474 5.61441L13.4282 6.69518C13.6048 6.87179 13.9065 6.74347 13.9016 6.4938L13.823 2.4491Z" fill="currentColor"> </path> <path d="M7.25 3.12893C7.66421 3.12893 8 3.46472 8 3.87893C8 4.29315 7.66421 4.62893 7.25 4.62893H4C3.72386 4.62893 3.5 4.85279 3.5 5.12893V11.9929C3.5 12.2691 3.72386 12.4929 4 12.4929H10.864C11.1401 12.4929 11.364 12.2691 11.364 11.9929V8.75C11.364 8.33579 11.6998 8 12.114 8C12.5282 8 12.864 8.33579 12.864 8.75V11.9929C12.864 13.0975 11.9686 13.9929 10.864 13.9929H4C2.89543 13.9929 2 13.0975 2 11.9929V5.12893C2 4.02436 2.89543 3.12893 4 3.12893H7.25Z" fill="currentColor"> </path> </svg> </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://metacpan.org/pod/MongoDB::Collection#insert_many" rel="noopener noreferrer"> <span> MongoDB::Collection::insert_many() </span> <svg alt="" aria-hidden="true" class="leafygreen-ui-1ie5kuq" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M13.823 2.4491C13.8201 2.30008 13.6999 2.17994 13.5509 2.17704L9.5062 2.09836C9.25654 2.09351 9.12821 2.39519 9.30482 2.5718L10.3856 3.65257L7.93433 6.10383C7.87964 6.15852 7.83047 6.21665 7.78683 6.27752L5.99909 8.06525C5.46457 8.59977 5.46457 9.4664 5.99909 10.0009C6.53361 10.5354 7.40023 10.5354 7.93475 10.0009L9.72249 8.21317C9.78336 8.16953 9.84148 8.12037 9.89618 8.06567L12.3474 5.61441L13.4282 6.69518C13.6048 6.87179 13.9065 6.74347 13.9016 6.4938L13.823 2.4491Z" fill="currentColor"> </path> <path d="M7.25 3.12893C7.66421 3.12893 8 3.46472 8 3.87893C8 4.29315 7.66421 4.62893 7.25 4.62893H4C3.72386 4.62893 3.5 4.85279 3.5 5.12893V11.9929C3.5 12.2691 3.72386 12.4929 4 12.4929H10.864C11.1401 12.4929 11.364 12.2691 11.364 11.9929V8.75C11.364 8.33579 11.6998 8 12.114 8C12.5282 8 12.864 8.33579 12.864 8.75V11.9929C12.864 13.0975 11.9686 13.9929 10.864 13.9929H4C2.89543 13.9929 2 13.0975 2 11.9929V5.12893C2 4.02436 2.89543 3.12893 4 3.12893H7.25Z" fill="currentColor"> </path> </svg> </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/insert-methods/#std-label-additional-inserts"> Additional Methods for Inserts </a> </p> </li> </ul> </div> </div> </div> </div> </div> <div> <div aria-labelledby="_g1q2jurdo" class="leafygreen-ui-38lglc" id="_mgja262p9" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <div class="leafygreen-ui-13vw3ie" role="note"> <h2 class="leafygreen-ui-1fn4p2b"> Tip </h2> <h3 class="leafygreen-ui-144d5kf"> <strong> See also: </strong> </h3> <div class="leafygreen-ui-9mycqc"> <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/php-library/upcoming/reference/method/MongoDBCollection-insertOne/#mongodb-phpmethod-phpmethod.MongoDB-Collection--insertOne--" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> MongoDB\\Collection::insertOne() </code> </span> </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/php-library/upcoming/reference/method/MongoDBCollection-insertMany/#mongodb-phpmethod-phpmethod.MongoDB-Collection--insertMany--" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> MongoDB\\Collection::insertMany() </code> </span> </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/insert-methods/#std-label-additional-inserts"> Additional Methods for Inserts </a> </p> </li> </ul> </div> </div> </div> </div> </div> <div> <div aria-labelledby="_swmaytfgg" class="leafygreen-ui-38lglc" id="_6b8xvatvj" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <div class="leafygreen-ui-13vw3ie" role="note"> <h2 class="leafygreen-ui-1fn4p2b"> Tip </h2> <h3 class="leafygreen-ui-144d5kf"> <strong> See also: </strong> </h3> <div class="leafygreen-ui-9mycqc"> <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://pymongo.readthedocs.io/en/stable/api/pymongo/collection.html#pymongo.collection.Collection.insert_one" rel="noopener noreferrer"> <span> <code class="leafygreen-ui-1l06pbn"> pymongo.collection.Collection.insert_one </code> </span> <svg alt="" aria-hidden="true" class="leafygreen-ui-1ie5kuq" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M13.823 2.4491C13.8201 2.30008 13.6999 2.17994 13.5509 2.17704L9.5062 2.09836C9.25654 2.09351 9.12821 2.39519 9.30482 2.5718L10.3856 3.65257L7.93433 6.10383C7.87964 6.15852 7.83047 6.21665 7.78683 6.27752L5.99909 8.06525C5.46457 8.59977 5.46457 9.4664 5.99909 10.0009C6.53361 10.5354 7.40023 10.5354 7.93475 10.0009L9.72249 8.21317C9.78336 8.16953 9.84148 8.12037 9.89618 8.06567L12.3474 5.61441L13.4282 6.69518C13.6048 6.87179 13.9065 6.74347 13.9016 6.4938L13.823 2.4491Z" fill="currentColor"> </path> <path d="M7.25 3.12893C7.66421 3.12893 8 3.46472 8 3.87893C8 4.29315 7.66421 4.62893 7.25 4.62893H4C3.72386 4.62893 3.5 4.85279 3.5 5.12893V11.9929C3.5 12.2691 3.72386 12.4929 4 12.4929H10.864C11.1401 12.4929 11.364 12.2691 11.364 11.9929V8.75C11.364 8.33579 11.6998 8 12.114 8C12.5282 8 12.864 8.33579 12.864 8.75V11.9929C12.864 13.0975 11.9686 13.9929 10.864 13.9929H4C2.89543 13.9929 2 13.0975 2 11.9929V5.12893C2 4.02436 2.89543 3.12893 4 3.12893H7.25Z" fill="currentColor"> </path> </svg> </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://pymongo.readthedocs.io/en/stable/api/pymongo/collection.html#pymongo.collection.Collection.insert_many" rel="noopener noreferrer"> <span> <code class="leafygreen-ui-1l06pbn"> pymongo.collection.Collection.insert_many </code> </span> <svg alt="" aria-hidden="true" class="leafygreen-ui-1ie5kuq" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M13.823 2.4491C13.8201 2.30008 13.6999 2.17994 13.5509 2.17704L9.5062 2.09836C9.25654 2.09351 9.12821 2.39519 9.30482 2.5718L10.3856 3.65257L7.93433 6.10383C7.87964 6.15852 7.83047 6.21665 7.78683 6.27752L5.99909 8.06525C5.46457 8.59977 5.46457 9.4664 5.99909 10.0009C6.53361 10.5354 7.40023 10.5354 7.93475 10.0009L9.72249 8.21317C9.78336 8.16953 9.84148 8.12037 9.89618 8.06567L12.3474 5.61441L13.4282 6.69518C13.6048 6.87179 13.9065 6.74347 13.9016 6.4938L13.823 2.4491Z" fill="currentColor"> </path> <path d="M7.25 3.12893C7.66421 3.12893 8 3.46472 8 3.87893C8 4.29315 7.66421 4.62893 7.25 4.62893H4C3.72386 4.62893 3.5 4.85279 3.5 5.12893V11.9929C3.5 12.2691 3.72386 12.4929 4 12.4929H10.864C11.1401 12.4929 11.364 12.2691 11.364 11.9929V8.75C11.364 8.33579 11.6998 8 12.114 8C12.5282 8 12.864 8.33579 12.864 8.75V11.9929C12.864 13.0975 11.9686 13.9929 10.864 13.9929H4C2.89543 13.9929 2 13.0975 2 11.9929V5.12893C2 4.02436 2.89543 3.12893 4 3.12893H7.25Z" fill="currentColor"> </path> </svg> </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/insert-methods/#std-label-additional-inserts"> Additional Methods for Inserts </a> </p> </li> </ul> </div> </div> </div> </div> </div> <div> <div aria-labelledby="_j2toe7fd4" class="leafygreen-ui-38lglc" id="_mk1c6xvnq" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <div class="leafygreen-ui-13vw3ie" role="note"> <h2 class="leafygreen-ui-1fn4p2b"> Tip </h2> <h3 class="leafygreen-ui-144d5kf"> <strong> See also: </strong> </h3> <div class="leafygreen-ui-9mycqc"> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="http://api.mongodb.com/ruby/current/Mongo/Collection.html#insert_one-instance_method" target="_self"> <span> Mongo::Collection#insert_one() </span> </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="http://api.mongodb.com/ruby/current/Mongo/Collection.html#insert_many-instance_method" target="_self"> <span> Mongo::Collection#insert_many() </span> </a> </p> </li> </ul> </div> </div> </div> </div> </div> <div> <div aria-labelledby="_et1esawg0" class="leafygreen-ui-38lglc" id="_3sdb941f1" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <div class="leafygreen-ui-13vw3ie" role="note"> <h2 class="leafygreen-ui-1fn4p2b"> Tip </h2> <h3 class="leafygreen-ui-144d5kf"> <strong> See also: </strong> </h3> <div class="leafygreen-ui-9mycqc"> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="http://mongodb.github.io/mongo-scala-driver/2.9/scaladoc/org/mongodb/scala/MongoCollection.html#insertOne(document:TResult,options:org.mongodb.scala.model.InsertOneOptions):org.mongodb.scala.SingleObservable[org.mongodb.scala.Completed]" rel="noopener noreferrer"> <span> collection.insertOne() </span> <svg alt="" aria-hidden="true" class="leafygreen-ui-1ie5kuq" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M13.823 2.4491C13.8201 2.30008 13.6999 2.17994 13.5509 2.17704L9.5062 2.09836C9.25654 2.09351 9.12821 2.39519 9.30482 2.5718L10.3856 3.65257L7.93433 6.10383C7.87964 6.15852 7.83047 6.21665 7.78683 6.27752L5.99909 8.06525C5.46457 8.59977 5.46457 9.4664 5.99909 10.0009C6.53361 10.5354 7.40023 10.5354 7.93475 10.0009L9.72249 8.21317C9.78336 8.16953 9.84148 8.12037 9.89618 8.06567L12.3474 5.61441L13.4282 6.69518C13.6048 6.87179 13.9065 6.74347 13.9016 6.4938L13.823 2.4491Z" fill="currentColor"> </path> <path d="M7.25 3.12893C7.66421 3.12893 8 3.46472 8 3.87893C8 4.29315 7.66421 4.62893 7.25 4.62893H4C3.72386 4.62893 3.5 4.85279 3.5 5.12893V11.9929C3.5 12.2691 3.72386 12.4929 4 12.4929H10.864C11.1401 12.4929 11.364 12.2691 11.364 11.9929V8.75C11.364 8.33579 11.6998 8 12.114 8C12.5282 8 12.864 8.33579 12.864 8.75V11.9929C12.864 13.0975 11.9686 13.9929 10.864 13.9929H4C2.89543 13.9929 2 13.0975 2 11.9929V5.12893C2 4.02436 2.89543 3.12893 4 3.12893H7.25Z" fill="currentColor"> </path> </svg> </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="http://mongodb.github.io/mongo-scala-driver/2.9/scaladoc/org/mongodb/scala/MongoCollection.html#insertMany(documents:Seq[_&lt;:TResult],options:org.mongodb.scala.model.InsertManyOptions):org.mongodb.scala.SingleObservable[org.mongodb.scala.Completed]" rel="noopener noreferrer"> <span> collection.insertMany() </span> <svg alt="" aria-hidden="true" class="leafygreen-ui-1ie5kuq" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M13.823 2.4491C13.8201 2.30008 13.6999 2.17994 13.5509 2.17704L9.5062 2.09836C9.25654 2.09351 9.12821 2.39519 9.30482 2.5718L10.3856 3.65257L7.93433 6.10383C7.87964 6.15852 7.83047 6.21665 7.78683 6.27752L5.99909 8.06525C5.46457 8.59977 5.46457 9.4664 5.99909 10.0009C6.53361 10.5354 7.40023 10.5354 7.93475 10.0009L9.72249 8.21317C9.78336 8.16953 9.84148 8.12037 9.89618 8.06567L12.3474 5.61441L13.4282 6.69518C13.6048 6.87179 13.9065 6.74347 13.9016 6.4938L13.823 2.4491Z" fill="currentColor"> </path> <path d="M7.25 3.12893C7.66421 3.12893 8 3.46472 8 3.87893C8 4.29315 7.66421 4.62893 7.25 4.62893H4C3.72386 4.62893 3.5 4.85279 3.5 5.12893V11.9929C3.5 12.2691 3.72386 12.4929 4 12.4929H10.864C11.1401 12.4929 11.364 12.2691 11.364 11.9929V8.75C11.364 8.33579 11.6998 8 12.114 8C12.5282 8 12.864 8.33579 12.864 8.75V11.9929C12.864 13.0975 11.9686 13.9929 10.864 13.9929H4C2.89543 13.9929 2 13.0975 2 11.9929V5.12893C2 4.02436 2.89543 3.12893 4 3.12893H7.25Z" fill="currentColor"> </path> </svg> </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/insert-methods/#std-label-additional-inserts"> Additional Methods for Inserts </a> </p> </li> </ul> </div> </div> </div> </div> </div> </div> </div> </section> </section> </section>
https://www.mongodb.com/docs/manual/reference/ulimit/
<section> <h1 class="contains-headerlink leafygreen-ui-41fr9s" weight="medium"> UNIX <code class="leafygreen-ui-1l06pbn"> ulimit </code> Settings for Self-Managed Deployments <a class="headerlink leafygreen-ui-1kepx47" href="#unix-ulimit-settings-for-self-managed-deployments" 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="unix-ulimit-settings-for-self-managed-deployments"> </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="#resource-utilization" target="_self"> <span> Resource Utilization </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#review-and-set-resource-limits" target="_self"> <span> Review and Set Resource Limits </span> </a> </li> </ul> </div> <p class="leafygreen-ui-1kp3ins"> Most UNIX-like operating systems, including Linux and macOS, provide ways to limit and control the usage of system resources such as threads, files, and network connections on a per-process and per-user basis. These "ulimits" prevent single users from using too many system resources. Sometimes, these limits have low default values that can cause a number of issues in the course of normal MongoDB operation. </p> <span class="leafygreen-ui-1qnjd6d" id="std-label-system-resource-utilization"> </span> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Resource Utilization <a class="headerlink leafygreen-ui-1kepx47" href="#resource-utilization" 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="resource-utilization"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> and <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongos/#mongodb-binary-bin.mongos"> <code class="leafygreen-ui-1l06pbn"> mongos </code> </a> each use threads and file descriptors to track connections and manage internal operations. This section outlines the general resource utilization patterns for MongoDB. Use these figures in combination with the actual information about your deployment and its use to determine ideal <code class="leafygreen-ui-1l06pbn"> ulimit </code> settings. </p> <p class="leafygreen-ui-1kp3ins"> Generally, all <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> and <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongos/#mongodb-binary-bin.mongos"> <code class="leafygreen-ui-1l06pbn"> mongos </code> </a> instances: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> track each incoming connection with two file descriptors <em> and </em> a thread. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> track each internal thread or <em> pthread </em> as a system process. </p> </li> </ul> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> <code class="leafygreen-ui-1l06pbn"> mongod </code> <a class="headerlink leafygreen-ui-1kepx47" href="#mongod" 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="mongod"> </div> </a> </h3> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> 1 file descriptor for each data file in use by the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> instance. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> 1 file descriptor for each journal file used by the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> instance. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> In replica sets, each <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> maintains a connection to all other members of the set. </p> </li> </ul> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> uses background threads for a number of internal processes, including <a class="leafygreen-ui-tqgtui" href="/docs/manual/tutorial/expire-data/#std-label-ttl-collections"> TTL collections </a> , replication, and replica set health checks, which may require a small number of additional resources. </p> <span class="leafygreen-ui-1qnjd6d" id="std-label-mongos-connection-use-information"> </span> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> <code class="leafygreen-ui-1l06pbn"> mongos </code> <a class="headerlink leafygreen-ui-1kepx47" href="#mongos" 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="mongos"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> In addition to the threads and file descriptors for client connections, <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongos/#mongodb-binary-bin.mongos"> <code class="leafygreen-ui-1l06pbn"> mongos </code> </a> must maintain connections to all config servers and all shards, which includes all members of all replica sets. </p> <p class="leafygreen-ui-1kp3ins"> For <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongos/#mongodb-binary-bin.mongos"> <code class="leafygreen-ui-1l06pbn"> mongos </code> </a> , consider the following behaviors: </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/program/mongos/#mongodb-binary-bin.mongos"> <code class="leafygreen-ui-1l06pbn"> mongos </code> </a> instances maintain a connection pool to each shard so that the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongos/#mongodb-binary-bin.mongos"> <code class="leafygreen-ui-1l06pbn"> mongos </code> </a> can reuse connections and quickly fulfill requests without needing to create new connections. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> You can limit the number of incoming connections using the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/configuration-options/#mongodb-setting-net.maxIncomingConnections"> <code class="leafygreen-ui-1l06pbn"> net.maxIncomingConnections </code> </a> run-time option. By restricting the number of incoming connections you can prevent a cascade effect where the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongos/#mongodb-binary-bin.mongos"> <code class="leafygreen-ui-1l06pbn"> mongos </code> </a> creates too many connections on the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> instances. </p> </li> </ul> </section> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Review and Set Resource Limits <a class="headerlink leafygreen-ui-1kepx47" href="#review-and-set-resource-limits" 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="review-and-set-resource-limits"> </div> </a> </h2> <span class="leafygreen-ui-1qnjd6d" id="std-label-ulimit-settings"> </span> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> <code class="leafygreen-ui-1l06pbn"> ulimit </code> <a class="headerlink leafygreen-ui-1kepx47" href="#ulimit" 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="ulimit"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> You can use the <code class="leafygreen-ui-1l06pbn"> ulimit </code> command at the system prompt to check system limits, as in the following example: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"$ ulimit -a\n-t: cpu time (seconds) unlimited\n-f: file size (blocks) unlimited\n-d: data seg size (kbytes) unlimited\n-s: stack size (kbytes) 8192\n-c: core file size (blocks) 0\n-m: resident set size (kbytes) unlimited\n-u: processes 64000\n-n: file descriptors 64000\n-l: locked-in-memory size (kb) unlimited\n-v: address space (kb) unlimited\n-x: file locks unlimited\n-i: pending signals 192276\n-q: bytes in POSIX msg queues 819200\n-e: max nice 30\n-r: max rt priority 65\n-N 15: unlimited","programmingLanguage":"Bash"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" tabindex="-1"><code class="lg-highlight-hljs-light bash leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">$ <span class="lg-highlight-built_in">ulimit</span> -a</td></tr><tr class=""><td class="leafygreen-ui-7razhx">-t: cpu time (seconds) unlimited</td></tr><tr class=""><td class="leafygreen-ui-7razhx">-f: file size (blocks) unlimited</td></tr><tr class=""><td class="leafygreen-ui-7razhx">-d: data seg size (kbytes) unlimited</td></tr><tr class=""><td class="leafygreen-ui-7razhx">-s: stack size (kbytes) 8192</td></tr><tr class=""><td class="leafygreen-ui-7razhx">-c: core file size (blocks) 0</td></tr><tr class=""><td class="leafygreen-ui-7razhx">-m: resident <span class="lg-highlight-built_in">set</span> size (kbytes) unlimited</td></tr><tr class=""><td class="leafygreen-ui-7razhx">-u: processes 64000</td></tr><tr class=""><td class="leafygreen-ui-7razhx">-n: file descriptors 64000</td></tr><tr class=""><td class="leafygreen-ui-7razhx">-l: locked-in-memory size (kb) unlimited</td></tr><tr class=""><td class="leafygreen-ui-7razhx">-v: address space (kb) unlimited</td></tr><tr class=""><td class="leafygreen-ui-7razhx">-x: file locks unlimited</td></tr><tr class=""><td class="leafygreen-ui-7razhx">-i: pending signals 192276</td></tr><tr class=""><td class="leafygreen-ui-7razhx">-q: bytes <span class="lg-highlight-keyword">in</span> POSIX msg queues 819200</td></tr><tr class=""><td class="leafygreen-ui-7razhx">-e: max <span class="lg-highlight-built_in">nice</span> 30</td></tr><tr class=""><td class="leafygreen-ui-7razhx">-r: max rt priority 65</td></tr><tr class=""><td class="leafygreen-ui-7razhx">-N 15: unlimited</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"> <code class="leafygreen-ui-1l06pbn"> ulimit </code> refers to the per- <em> user </em> limitations for various resources. Therefore, if your <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> instance executes as a user that is also running multiple processes, or multiple <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> processes, you might see contention for these resources. Also, be aware that the <code class="leafygreen-ui-1l06pbn"> processes </code> value (i.e. <code class="leafygreen-ui-1l06pbn"> -u </code> ) refers to the combined number of distinct processes and sub-process threads. </p> <p class="leafygreen-ui-1kp3ins"> On Linux, you can change <code class="leafygreen-ui-1l06pbn"> ulimit </code> settings by issuing a command in the following form: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"ulimit -n &lt;value&gt;","programmingLanguage":"Bash"} </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 bash leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-built_in">ulimit</span> -n &lt;value&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"> There are both "hard" and the "soft" <code class="leafygreen-ui-1l06pbn"> ulimit </code> s that affect MongoDB's performance. The "hard" <code class="leafygreen-ui-1l06pbn"> ulimit </code> refers to the maximum number of processes that a user can have active at any time. This is the ceiling: no non-root process can increase the "hard" <code class="leafygreen-ui-1l06pbn"> ulimit </code> . In contrast, the "soft" <code class="leafygreen-ui-1l06pbn"> ulimit </code> is the limit that is actually enforced for a session or process, but any process can increase it up to "hard" <code class="leafygreen-ui-1l06pbn"> ulimit </code> maximum. </p> <p class="leafygreen-ui-1kp3ins"> A low "soft" <code class="leafygreen-ui-1l06pbn"> ulimit </code> can cause <code class="leafygreen-ui-1l06pbn"> can't create new thread, closing connection </code> errors if the number of connections grows too high. For this reason, it is extremely important to set <em> both </em> <code class="leafygreen-ui-1l06pbn"> ulimit </code> values to the recommended values. </p> <p class="leafygreen-ui-1kp3ins"> <code class="leafygreen-ui-1l06pbn"> ulimit </code> will modify both "hard" and "soft" values unless the <code class="leafygreen-ui-1l06pbn"> -H </code> or <code class="leafygreen-ui-1l06pbn"> -S </code> modifiers are specified when modifying limit values. </p> <p class="leafygreen-ui-1kp3ins"> For many distributions of Linux you can change values by substituting the <code class="leafygreen-ui-1l06pbn"> -n </code> option for any possible value in the output of <code class="leafygreen-ui-1l06pbn"> ulimit -a </code> . </p> <p class="leafygreen-ui-1kp3ins"> After changing the <code class="leafygreen-ui-1l06pbn"> ulimit </code> settings, you <em> must </em> restart the process to take advantage of the modified settings. On Linux, you can use the <code class="leafygreen-ui-1l06pbn"> /proc </code> file system to see the current limitations on a running process. </p> <p class="leafygreen-ui-1kp3ins"> Depending on your system's configuration, and default settings, any change to system limits made using <code class="leafygreen-ui-1l06pbn"> ulimit </code> may revert following a system restart. Check your distribution and operating system documentation for more information. </p> <p class="leafygreen-ui-1kp3ins"> You should typically start <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> using <code class="leafygreen-ui-1l06pbn"> systemctl </code> , which uses the <code class="leafygreen-ui-1l06pbn"> ulimit </code> settings: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"systemctl start mongod.service","programmingLanguage":"Bash"} </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 bash leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">systemctl start mongod.service</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"> If you <em> do not </em> start <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> using <code class="leafygreen-ui-1l06pbn"> systemctl </code> , <code class="leafygreen-ui-1l06pbn"> systemd </code> overrides some of the <code class="leafygreen-ui-1l06pbn"> ulimit </code> settings. For example, if you start <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> as shown in the following command, then a user slice (such as <code class="leafygreen-ui-1l06pbn"> user-1000.slice </code> ) <code class="leafygreen-ui-1l06pbn"> systemd </code> setting is used: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"mongod --config ~/mongod.conf","programmingLanguage":"Bash"} </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 bash leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">mongod --config ~<!-- -->/mongod.conf</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-15mdk4" role="note"> <h2 class="leafygreen-ui-6n7b7d"> Note </h2> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> A <code class="leafygreen-ui-1l06pbn"> systemd </code> user slice limits the resources for the user's processes. </p> </div> </div> <section> <h4 class="contains-headerlink leafygreen-ui-1vzlt5f"> macOS <a class="headerlink leafygreen-ui-1kepx47" href="#macos" 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="macos"> </div> </a> </h4> <p class="leafygreen-ui-1kp3ins"> For macOS systems that have installed MongoDB Community using the brew installation method, the recommended open files value is automatically set when you start MongoDB through <code class="leafygreen-ui-1l06pbn"> brew services </code> . </p> <p class="leafygreen-ui-1kp3ins"> For macOS systems running MongoDB Enterprise or using the TGZ installation method, use the <code class="leafygreen-ui-1l06pbn"> ulimit </code> command to set the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-recommended-ulimit-settings" target="_self"> <span> recommended values </span> </a> . See your operating system documentation for the precise procedure for changing system limits on running systems. </p> </section> <section> <h4 class="contains-headerlink leafygreen-ui-1vzlt5f"> Red Hat Linux Enterprise Server and CentOS <a class="headerlink leafygreen-ui-1kepx47" href="#red-hat-linux-enterprise-server-and-centos" 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="red-hat-linux-enterprise-server-and-centos"> </div> </a> </h4> <p class="leafygreen-ui-1kp3ins"> Red Hat Enterprise Linux and CentOS 6 and 7 enforce a separate max process limitation, <code class="leafygreen-ui-1l06pbn"> nproc </code> , which overrides <code class="leafygreen-ui-1l06pbn"> ulimit </code> settings. This value is defined in the following configuration file, depending on version: </p> <div class="leafygreen-ui-skkc39" tabindex="0"> <table class="leafygreen-ui-hr8lsv"> <colgroup> <col style="width:25%"/> <col style="width:8%"/> <col style="width:60%"/> </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> Version </div> </div> </th> <th class="leafygreen-ui-13uteka" role="columnheader" scope="col"> <div class="leafygreen-ui-ui0te9"> <div> Value </div> </div> </th> <th class="leafygreen-ui-13uteka" role="columnheader" scope="col"> <div class="leafygreen-ui-ui0te9"> <div> File </div> </div> </th> </tr> </thead> <tbody> <tr class=""> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> RHEL / CentOS 7 </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> 4096 </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> /etc/security/limits.d/20-nproc.conf </code> </div> </div> </td> </tr> <tr class=""> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> RHEL / CentOS 6 </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> 1024 </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> /etc/security/limits.d/90-nproc.conf </code> </div> </div> </td> </tr> </tbody> </table> </div> <p class="leafygreen-ui-1kp3ins"> To configure an <code class="leafygreen-ui-1l06pbn"> nproc </code> value for these versions, create a file named <code class="leafygreen-ui-1l06pbn"> /etc/security/limits.d/99-mongodb-nproc.conf </code> with new <code class="leafygreen-ui-1l06pbn"> soft nproc </code> and <code class="leafygreen-ui-1l06pbn"> hard nproc </code> values to increase the process limit. For recommended values, see <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-recommended-ulimit-settings" target="_self"> <span> Recommended <code class="leafygreen-ui-1l06pbn"> ulimit </code> Settings <!-- --> . </span> </a> </p> <p class="leafygreen-ui-1kp3ins"> With RHEL / CentOS 8, separate <code class="leafygreen-ui-1l06pbn"> nproc </code> values are no longer necessary. The <code class="leafygreen-ui-1l06pbn"> ulimit </code> command is sufficient to configure the required max process values on RHEL / CentOS 8. </p> <span class="leafygreen-ui-1qnjd6d" id="std-label-recommended-ulimit-settings"> </span> </section> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Recommended <code class="leafygreen-ui-1l06pbn"> ulimit </code> Settings <a class="headerlink leafygreen-ui-1kepx47" href="#recommended-ulimit-settings" 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="recommended-ulimit-settings"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> Every deployment may have unique requirements and settings; however, the following thresholds and settings are particularly important for <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> and <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongos/#mongodb-binary-bin.mongos"> <code class="leafygreen-ui-1l06pbn"> mongos </code> </a> deployments: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <code class="leafygreen-ui-1l06pbn"> -f </code> (file size): <code class="leafygreen-ui-1l06pbn"> unlimited </code> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <code class="leafygreen-ui-1l06pbn"> -t </code> (cpu time): <code class="leafygreen-ui-1l06pbn"> unlimited </code> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <code class="leafygreen-ui-1l06pbn"> -v </code> (virtual memory): <code class="leafygreen-ui-1l06pbn"> unlimited </code> <a class="footnote-reference header-buffer" href="#footnote-memory-size" id="ref-memory-size-id1"> [ <!-- --> 1 <!-- --> ] </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <code class="leafygreen-ui-1l06pbn"> -l </code> (locked-in-memory size): <code class="leafygreen-ui-1l06pbn"> unlimited </code> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <code class="leafygreen-ui-1l06pbn"> -n </code> (open files): <code class="leafygreen-ui-1l06pbn"> 64000 </code> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <code class="leafygreen-ui-1l06pbn"> -m </code> (memory size): <code class="leafygreen-ui-1l06pbn"> unlimited </code> <a class="footnote-reference header-buffer" href="#footnote-memory-size" id="ref-memory-size-id2"> [ <!-- --> 1 <!-- --> ] </a> <a class="footnote-reference header-buffer" href="#footnote-rss-linux" id="ref-rss-linux-id3"> [ <!-- --> 2 <!-- --> ] </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <code class="leafygreen-ui-1l06pbn"> -u </code> (processes/threads): <code class="leafygreen-ui-1l06pbn"> 64000 </code> </p> </li> </ul> <p class="leafygreen-ui-1kp3ins"> Always remember to restart your <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> and <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongos/#mongodb-binary-bin.mongos"> <code class="leafygreen-ui-1l06pbn"> mongos </code> </a> instances after changing the <code class="leafygreen-ui-1l06pbn"> ulimit </code> settings to ensure that the changes take effect. </p> <section> <h4 class="contains-headerlink leafygreen-ui-1vzlt5f"> Considerations <a class="headerlink leafygreen-ui-1kepx47" href="#considerations" 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="considerations"> </div> </a> </h4> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Incoming connections to a <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> or <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongos/#mongodb-binary-bin.mongos"> <code class="leafygreen-ui-1l06pbn"> mongos </code> </a> instance require <strong> two </strong> file descriptors. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> For the macOS platform, the recommended process limit is <code class="leafygreen-ui-1l06pbn"> 2500 </code> , which is the maximum configurable value for this platform. </p> </li> </ul> </section> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Linux distributions using Upstart <a class="headerlink leafygreen-ui-1kepx47" href="#linux-distributions-using-upstart" 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="linux-distributions-using-upstart"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> For Linux distributions that use Upstart, you can specify limits within service scripts if you start <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> and/or <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongos/#mongodb-binary-bin.mongos"> <code class="leafygreen-ui-1l06pbn"> mongos </code> </a> instances as Upstart services. You can do this by using <code class="leafygreen-ui-1l06pbn"> limit </code> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="http://upstart.ubuntu.com/wiki/Stanzas#limit" rel="noopener noreferrer"> <span> stanzas </span> <svg alt="" aria-hidden="true" class="leafygreen-ui-1ie5kuq" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M13.823 2.4491C13.8201 2.30008 13.6999 2.17994 13.5509 2.17704L9.5062 2.09836C9.25654 2.09351 9.12821 2.39519 9.30482 2.5718L10.3856 3.65257L7.93433 6.10383C7.87964 6.15852 7.83047 6.21665 7.78683 6.27752L5.99909 8.06525C5.46457 8.59977 5.46457 9.4664 5.99909 10.0009C6.53361 10.5354 7.40023 10.5354 7.93475 10.0009L9.72249 8.21317C9.78336 8.16953 9.84148 8.12037 9.89618 8.06567L12.3474 5.61441L13.4282 6.69518C13.6048 6.87179 13.9065 6.74347 13.9016 6.4938L13.823 2.4491Z" fill="currentColor"> </path> <path d="M7.25 3.12893C7.66421 3.12893 8 3.46472 8 3.87893C8 4.29315 7.66421 4.62893 7.25 4.62893H4C3.72386 4.62893 3.5 4.85279 3.5 5.12893V11.9929C3.5 12.2691 3.72386 12.4929 4 12.4929H10.864C11.1401 12.4929 11.364 12.2691 11.364 11.9929V8.75C11.364 8.33579 11.6998 8 12.114 8C12.5282 8 12.864 8.33579 12.864 8.75V11.9929C12.864 13.0975 11.9686 13.9929 10.864 13.9929H4C2.89543 13.9929 2 13.0975 2 11.9929V5.12893C2 4.02436 2.89543 3.12893 4 3.12893H7.25Z" fill="currentColor"> </path> </svg> </a> . </p> <p class="leafygreen-ui-1kp3ins"> Specify the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-recommended-ulimit-settings" target="_self"> <span> Recommended <code class="leafygreen-ui-1l06pbn"> ulimit </code> Settings </span> </a> , as in the following example: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"limit fsize unlimited unlimited # (file size)\nlimit cpu unlimited unlimited # (cpu time)\nlimit as unlimited unlimited # (virtual memory size)\nlimit memlock unlimited unlimited # (locked-in-memory size)\nlimit nofile 64000 64000 # (open files)\nlimit nproc 64000 64000 # (processes/threads)","programmingLanguage":"Bash"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><code class="lg-highlight-hljs-light bash leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-built_in">limit</span> fsize unlimited unlimited <span class="lg-highlight-comment"># (file size)</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-built_in">limit</span> cpu unlimited unlimited <span class="lg-highlight-comment"># (cpu time)</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-built_in">limit</span> as unlimited unlimited <span class="lg-highlight-comment"># (virtual memory size)</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-built_in">limit</span> memlock unlimited unlimited <span class="lg-highlight-comment"># (locked-in-memory size)</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-built_in">limit</span> nofile 64000 64000 <span class="lg-highlight-comment"># (open files)</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-built_in">limit</span> <span class="lg-highlight-built_in">nproc</span> 64000 64000 <span class="lg-highlight-comment"># (processes/threads)</span></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"> Each <code class="leafygreen-ui-1l06pbn"> limit </code> stanza sets the "soft" limit to the first value specified and the "hard" limit to the second. </p> <p class="leafygreen-ui-1kp3ins"> After changing <code class="leafygreen-ui-1l06pbn"> limit </code> stanzas, ensure that the changes take effect by restarting the application services, using the following form: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"restart &lt;service&gt;","programmingLanguage":"Bash"} </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 bash leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">restart &lt;service name&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> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Linux distributions using <code class="leafygreen-ui-1l06pbn"> systemd </code> <a class="headerlink leafygreen-ui-1kepx47" href="#linux-distributions-using-systemd" 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="linux-distributions-using-systemd"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> If you start a <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> and/or <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongos/#mongodb-binary-bin.mongos"> <code class="leafygreen-ui-1l06pbn"> mongos </code> </a> instance as a <code class="leafygreen-ui-1l06pbn"> systemd </code> service, you can specify limits within the <code class="leafygreen-ui-1l06pbn"> [Service] </code> section of its service file. The service file has a location like <code class="leafygreen-ui-1l06pbn"> /etc/systemd/system/&lt;process-name&gt;.service </code> . </p> <p class="leafygreen-ui-1kp3ins"> You can set limits by using <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="http://www.freedesktop.org/software/systemd/man/systemd.exec.html#LimitCPU=" rel="noopener noreferrer"> <span> resource limit directives </span> <svg alt="" aria-hidden="true" class="leafygreen-ui-1ie5kuq" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M13.823 2.4491C13.8201 2.30008 13.6999 2.17994 13.5509 2.17704L9.5062 2.09836C9.25654 2.09351 9.12821 2.39519 9.30482 2.5718L10.3856 3.65257L7.93433 6.10383C7.87964 6.15852 7.83047 6.21665 7.78683 6.27752L5.99909 8.06525C5.46457 8.59977 5.46457 9.4664 5.99909 10.0009C6.53361 10.5354 7.40023 10.5354 7.93475 10.0009L9.72249 8.21317C9.78336 8.16953 9.84148 8.12037 9.89618 8.06567L12.3474 5.61441L13.4282 6.69518C13.6048 6.87179 13.9065 6.74347 13.9016 6.4938L13.823 2.4491Z" fill="currentColor"> </path> <path d="M7.25 3.12893C7.66421 3.12893 8 3.46472 8 3.87893C8 4.29315 7.66421 4.62893 7.25 4.62893H4C3.72386 4.62893 3.5 4.85279 3.5 5.12893V11.9929C3.5 12.2691 3.72386 12.4929 4 12.4929H10.864C11.1401 12.4929 11.364 12.2691 11.364 11.9929V8.75C11.364 8.33579 11.6998 8 12.114 8C12.5282 8 12.864 8.33579 12.864 8.75V11.9929C12.864 13.0975 11.9686 13.9929 10.864 13.9929H4C2.89543 13.9929 2 13.0975 2 11.9929V5.12893C2 4.02436 2.89543 3.12893 4 3.12893H7.25Z" fill="currentColor"> </path> </svg> </a> . </p> <p class="leafygreen-ui-1kp3ins"> Specify the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-recommended-ulimit-settings" target="_self"> <span> Recommended <code class="leafygreen-ui-1l06pbn"> ulimit </code> Settings </span> </a> , as in the following example: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"[Service]\n# Other directives omitted\n# (file size)\nLimitFSIZE=infinity\n# (cpu time)\nLimitCPU=infinity\n# (virtual memory size)\nLimitAS=infinity\n# (locked-in-memory size)\nLimitMEMLOCK=infinity\n# (open files)\nLimitNOFILE=64000\n# (processes/threads)\nLimitNPROC=64000","programmingLanguage":"Bash"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" tabindex="-1"><code class="lg-highlight-hljs-light bash leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">[Service]</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-comment"># Other directives omitted</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-comment"># (file size)</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx">LimitFSIZE=infinity</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-comment"># (cpu time)</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx">LimitCPU=infinity</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-comment"># (virtual memory size)</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx">LimitAS=infinity</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-comment"># (locked-in-memory size)</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx">LimitMEMLOCK=infinity</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-comment"># (open files)</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx">LimitNOFILE=64000</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-comment"># (processes/threads)</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx">LimitNPROC=64000</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"> Each <code class="leafygreen-ui-1l06pbn"> systemd </code> limit directive sets both the "hard" and "soft" limits to the value specified. </p> <p class="leafygreen-ui-1kp3ins"> After changing <code class="leafygreen-ui-1l06pbn"> limit </code> stanzas, ensure that the changes take effect by restarting the application services, using the following form: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"systemctl restart &lt;service&gt;","programmingLanguage":"Bash"} </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 bash leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">systemctl restart &lt;service name&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-15mdk4" role="note"> <h2 class="leafygreen-ui-6n7b7d"> Note </h2> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> If you installed MongoDB via a package manager such as <code class="leafygreen-ui-1l06pbn"> yum </code> or <code class="leafygreen-ui-1l06pbn"> apt </code> , the service file installed as part of your installation already contains these ulimit values. </p> </div> </div> <span class="leafygreen-ui-1qnjd6d" id="std-label-proc-file-system"> </span> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> <code class="leafygreen-ui-1l06pbn"> /proc </code> File System <a class="headerlink leafygreen-ui-1kepx47" href="#-proc-file-system" 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="-proc-file-system"> </div> </a> </h3> <div class="leafygreen-ui-15mdk4" role="note"> <h2 class="leafygreen-ui-6n7b7d"> Note </h2> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> This section applies only to Linux operating systems. </p> </div> </div> <p class="leafygreen-ui-1kp3ins"> The <code class="leafygreen-ui-1l06pbn"> /proc </code> file-system stores the per-process limits in the file system object located at <code class="leafygreen-ui-1l06pbn"> /proc/&lt;pid&gt;/limits </code> , where <code class="leafygreen-ui-1l06pbn"> &lt;pid&gt; </code> is the process's <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-PID"> PID </a> or process identifier. You can use the following <code class="leafygreen-ui-1l06pbn"> bash </code> function to return the content of the <code class="leafygreen-ui-1l06pbn"> limits </code> object for a process or processes with a given name: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"return-limits(){\n\n for process in $@; do\n process_pids=`ps -C $process -o pid --no-headers | cut -d \" \" -f 2`\n\n if [ -z $@ ]; then\n echo \"[no $process running]\"\n else\n for pid in $process_pids; do\n echo \"[$process #$pid -- limits]\"\n cat /proc/$pid/limits\n done\n fi\n\n done\n\n}","programmingLanguage":"Bash"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><code class="lg-highlight-hljs-light bash leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-built_in">return</span>-<span class="lg-highlight-title lg-highlight-function">limits</span>(){</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><div class="leafygreen-ui-ihxujy"></div></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-keyword">for</span> process <span class="lg-highlight-keyword">in</span> <span class="lg-highlight-variable">$@</span>; <span class="lg-highlight-keyword">do</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> process_pids=`ps -C <span class="lg-highlight-variable">$process</span> -o pid --no-headers | <span class="lg-highlight-built_in">cut</span> -d <span class="lg-highlight-string">" "</span> -f 2`</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><div class="leafygreen-ui-ihxujy"></div></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-keyword">if</span> [ -z <span class="lg-highlight-variable">$@</span> ]; <span class="lg-highlight-keyword">then</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-built_in">echo</span> <span class="lg-highlight-string">"[no </span><span class="lg-highlight-variable lg-highlight-string">$process</span><span class="lg-highlight-string"> running]"</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-keyword">else</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-keyword">for</span> pid <span class="lg-highlight-keyword">in</span> <span class="lg-highlight-variable">$process_pids</span>; <span class="lg-highlight-keyword">do</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-built_in">echo</span> <span class="lg-highlight-string">"[</span><span class="lg-highlight-variable lg-highlight-string">$process</span><span class="lg-highlight-string"> #</span><span class="lg-highlight-variable lg-highlight-string">$pid</span><span class="lg-highlight-string"> -- limits]"</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-built_in">cat</span> <!-- -->/proc<!-- -->/<span class="lg-highlight-variable">$pid</span>/limits</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-keyword">done</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-keyword">fi</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"><div class="leafygreen-ui-ihxujy"></div></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-keyword">done</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"><div class="leafygreen-ui-ihxujy"></div></td></tr><tr class=""><td class="leafygreen-ui-7razhx">}</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"> You can copy and paste this function into a current shell session or load it as part of a script. Call the function with one the following invocations: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"return-limits mongod\nreturn-limits mongos\nreturn-limits mongod mongos","programmingLanguage":"Bash"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" tabindex="-1"><code class="lg-highlight-hljs-light bash leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">return-limits mongod</td></tr><tr class=""><td class="leafygreen-ui-7razhx">return-limits mongos</td></tr><tr class=""><td class="leafygreen-ui-7razhx">return-limits mongod mongos</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> <table class="header-buffer leafygreen-ui-rbqgrl" frame="void" id="footnote-memory-size" rules="none"> <colgroup> <col/> </colgroup> <tbody valign="top"> <tr> <td class="leafygreen-ui-17r2xs0"> [ <!-- --> 1 <!-- --> ] </td> <td class="leafygreen-ui-17r2xs0"> <em> ( <a href="#ref-memory-size-id1"> 1 </a> , <a href="#ref-memory-size-id2"> 2 </a> ) </em> <!-- --> If you limit virtual or resident memory size on a system running MongoDB the operating system will refuse to honor additional allocation requests. </td> </tr> </tbody> </table> <table class="header-buffer leafygreen-ui-rbqgrl" frame="void" id="footnote-rss-linux" rules="none"> <colgroup> <col/> </colgroup> <tbody valign="top"> <tr> <td class="leafygreen-ui-17r2xs0"> [ <a href="#ref-rss-linux-id3"> 2 </a> ] </td> <td class="leafygreen-ui-17r2xs0"> <!-- --> The <code class="leafygreen-ui-1l06pbn"> -m </code> parameter to <code class="leafygreen-ui-1l06pbn"> ulimit </code> has no effect on Linux systems with kernel versions more recent than 2.4.30. You may omit <code class="leafygreen-ui-1l06pbn"> -m </code> if you wish. </td> </tr> </tbody> </table> </section> </section> </section>
https://www.mongodb.com/docs/manual/reference/command/connPoolStats/
<section> <h1 class="contains-headerlink leafygreen-ui-41fr9s" weight="medium"> connPoolStats <a class="headerlink leafygreen-ui-1kepx47" href="#connpoolstats" 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="connpoolstats"> </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="#definition" target="_self"> <span> Definition </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#compatibility" target="_self"> <span> Compatibility </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#syntax" target="_self"> <span> Syntax </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#behavior" target="_self"> <span> Behavior </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#example" target="_self"> <span> Example </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#output" target="_self"> <span> Output </span> </a> </li> </ul> </div> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Definition <a class="headerlink leafygreen-ui-1kepx47" href="#definition" 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="definition"> </div> </a> </h2> <dl class="dbcommand"> <dt> <code class="leafygreen-ui-1l06pbn"> connPoolStats </code> <a class="headerlink leafygreen-ui-1kepx47" href="#mongodb-dbcommand-dbcmd.connPoolStats" title="Permalink to this definition"> <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="mongodb-dbcommand-dbcmd.connPoolStats"> </div> </a> </dt> <dd> <p class="leafygreen-ui-1kp3ins"> The command <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-dbcommand-dbcmd.connPoolStats" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> connPoolStats </code> </span> </a> returns information regarding the open outgoing connections from the current database instance to other members of the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-sharded-cluster"> sharded cluster </a> or <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-replica-set"> replica set <!-- --> . </a> </p> <p class="leafygreen-ui-1kp3ins"> To run <code class="leafygreen-ui-1l06pbn"> connPoolStats </code> , use the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/db.runCommand/#mongodb-method-db.runCommand"> <code class="leafygreen-ui-1l06pbn"> db.runCommand( { &lt;command&gt; } ) </code> </a> method. </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"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-dbcommand-dbcmd.connPoolStats" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> connPoolStats </code> </span> </a> only returns meaningful results for <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongos/#mongodb-binary-bin.mongos"> <code class="leafygreen-ui-1l06pbn"> mongos </code> </a> instances and for <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> instances in sharded clusters. </p> </div> </div> </dd> </dl> </section> <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"> This command is available in 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> <div class="leafygreen-ui-15mdk4" role="note"> <h2 class="leafygreen-ui-6n7b7d"> Note </h2> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> This command is supported in all MongoDB Atlas clusters. For information on Atlas support for all commands, see <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/atlas/unsupported-commands/" target="_self"> <span> Unsupported Commands <!-- --> . </span> </a> </p> </div> </div> <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"> Syntax <a class="headerlink leafygreen-ui-1kepx47" href="#syntax" 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="syntax"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> The command has the following syntax: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.runCommand(\n {\n connPoolStats: 1\n }\n)","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">runCommand</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">connPoolStats</span>: <span class="lg-highlight-number">1</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">)</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 value of the argument (i.e. <code class="leafygreen-ui-1l06pbn"> 1 </code> ) does not affect the output of the command. </p> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Behavior <a class="headerlink leafygreen-ui-1kepx47" href="#behavior" 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="behavior"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-dbcommand-dbcmd.connPoolStats" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> connPoolStats </code> </span> </a> includes aggregated statistics in its output: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> The <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-data-connPoolStats.hosts" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> hosts </code> </span> </a> field displays the information aggregated by host. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> The <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-data-connPoolStats.pools" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> pools </code> </span> </a> field displays the information aggregated by pool. </p> </li> </ul> <div class="leafygreen-ui-15mdk4" role="note"> <h2 class="leafygreen-ui-6n7b7d"> Note </h2> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> To avoid interference with any running operations, <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-dbcommand-dbcmd.connPoolStats" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> connPoolStats </code> </span> </a> does not take any locks. As such, the counts may change slightly as <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-dbcommand-dbcmd.connPoolStats" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> connPoolStats </code> </span> </a> gathers information, resulting in slight differences between the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-data-connPoolStats.hosts" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> hosts </code> </span> </a> and <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-data-connPoolStats.pools" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> pools </code> </span> </a> connection counts. </p> </div> </div> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Example <a class="headerlink leafygreen-ui-1kepx47" href="#example" 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="example"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> The following operation uses the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/db.runCommand/#mongodb-method-db.runCommand"> <code class="leafygreen-ui-1l06pbn"> db.runCommand() </code> </a> method to run the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-dbcommand-dbcmd.connPoolStats" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> connPoolStats </code> </span> </a> command on a <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongos/#mongodb-binary-bin.mongos"> <code class="leafygreen-ui-1l06pbn"> mongos </code> </a> of a sharded cluster. The sharded cluster has 2 shards, each a single-member replica set, and a config server replica set. The <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongos/#mongodb-binary-bin.mongos"> <code class="leafygreen-ui-1l06pbn"> mongos </code> </a> runs on a 4-core machine. </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.runCommand( { \"connPoolStats\" : 1 } )","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">runCommand</span>( <!-- -->{ <span class="lg-highlight-string">"connPoolStats"</span> <!-- -->: <span class="lg-highlight-number">1</span> } )</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 command returns the output of the following form: </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"> The <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-dbcommand-dbcmd.connPoolStats" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> connPoolStats </code> </span> </a> output varies depending on the deployment and the member against which you run <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-dbcommand-dbcmd.connPoolStats" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> connPoolStats </code> </span> </a> among other factors. </p> </div> </div> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{\n \"numClientConnections\" : &lt;num&gt;,\n \"numAScopedConnections\" : &lt;num&gt;,\n \"totalInUse\" : &lt;num&gt;,\n \"totalAvailable\" : &lt;num&gt;,\n \"totalLeased\" : &lt;num&gt;,\n \"totalCreated\" : &lt;num&gt;,\n \"totalRefreshing\" : &lt;num&gt;,\n \"replicaSetMatchingStrategy\" : &lt;string&gt;,\n \"acquisitionWaitTimes\" : { // Added in MongoDB 6.3\n \"(-inf, 0ms)\" : { \"count\" : &lt;num&gt; },\n \"[0ms, 50ms)\" : { \"count\" : &lt;num&gt; },\n \"[50ms, 100ms)\" : { \"count\" : &lt;num&gt; },\n \"[100ms, 150ms)\" : { \"count\" : &lt;num&gt; },\n \"[150ms, 200ms)\" : { \"count\" : &lt;num&gt; },\n \"[200ms, 250ms)\" : { \"count\" : &lt;num&gt; },\n \"[250ms, 300ms)\" : { \"count\" : &lt;num&gt; },\n \"[300ms, 350ms)\" : { \"count\" : &lt;num&gt; },\n \"[350ms, 400ms)\" : { \"count\" : &lt;num&gt; },\n \"[400ms, 450ms)\" : { \"count\" : &lt;num&gt; },\n \"[450ms, 500ms)\" : { \"count\" : &lt;num&gt; },\n \"[500ms, 550ms)\" : { \"count\" : &lt;num&gt; },\n \"[550ms, 600ms)\" : { \"count\" : &lt;num&gt; },\n \"[600ms, 650ms)\" : { \"count\" : &lt;num&gt; },\n \"[650ms, 700ms)\" : { \"count\" : &lt;num&gt; },\n \"[700ms, 750ms)\" : { \"count\" : &lt;num&gt; },\n \"[750ms, 800ms)\" : { \"count\" : &lt;num&gt; },\n \"[800ms, 850ms)\" : { \"count\" : &lt;num&gt; },\n \"[850ms, 900ms)\" : { \"count\" : &lt;num&gt; },\n \"[900ms, 950ms)\" : { \"count\" : &lt;num&gt; },\n \"[950ms, 1000ms)\" : { \"count\" : &lt;num&gt; },\n \"[1000ms, inf)\" : { \"count\" : &lt;num&gt; },\n \"totalCount\" : &lt;num&gt;\n },\n \"pools\" : {\n \"NetworkInterfaceTL-TaskExecutorPool-0\" : {\n \"poolInUse\" : &lt;num&gt;,\n \"poolAvailable\" : &lt;num&gt;,\n \"poolLeased\" : &lt;num&gt;,\n \"poolCreated\" : &lt;num&gt;,\n \"poolRefreshing\" : &lt;num&gt;,\n \"acquisitionWaitTimes\" : &lt;document&gt;, // Added in MongoDB 6.3\n \"cfg1.example.net:27019\" : {\n \"inUse\" : &lt;num&gt;,\n \"available\" : &lt;num&gt;,\n \"leased\" : &lt;num&gt;,\n \"created\" : &lt;num&gt;,\n \"refreshing\" : &lt;num&gt;,\n \"acquisitionWaitTimes\" : &lt;document&gt; // Added in MongoDB 6.3\n },\n },\n \"NetworkInterfaceTL-TaskExecutorPool-1\" : {\n \"poolInUse\" : &lt;num&gt;,\n \"poolAvailable\" : &lt;num&gt;,\n \"poolLeased\" : &lt;num&gt;,\n \"poolCreated\" : &lt;num&gt;,\n \"poolRefreshing\" : &lt;num&gt;,\n \"acquisitionWaitTimes\" : &lt;document&gt;, // Added in MongoDB 6.3\n \"cfg1.example.net:27019\" : {\n \"inUse\" : &lt;num&gt;,\n \"available\" : &lt;num&gt;,\n \"leased\" : &lt;num&gt;,\n \"created\" : &lt;num&gt;,\n \"refreshing\" : &lt;num&gt;,\n \"acquisitionWaitTimes\" : &lt;document&gt; // Added in MongoDB 6.3\n }\n },\n \"NetworkInterfaceTL-TaskExecutorPool-2\" : {\n \"poolInUse\" : &lt;num&gt;,\n \"poolAvailable\" : &lt;num&gt;,\n \"poolLeased\" : &lt;num&gt;,\n \"poolCreated\" : &lt;num&gt;,\n \"poolRefreshing\" : &lt;num&gt;,\n \"acquisitionWaitTimes\" : &lt;document&gt;, // Added in MongoDB 6.3\n \"cfg1.example.net:27019\" : {\n \"inUse\" : &lt;num&gt;,\n \"available\" : &lt;num&gt;,\n \"leased\" : &lt;num&gt;,\n \"created\" : &lt;num&gt;,\n \"refreshing\" : &lt;num&gt;,\n \"acquisitionWaitTimes\" : &lt;document&gt; // Added in MongoDB 6.3\n }\n },\n \"NetworkInterfaceTL-TaskExecutorPool-3\" : {\n \"poolInUse\" : &lt;num&gt;,\n \"poolAvailable\" : &lt;num&gt;,\n \"poolLeased\" : &lt;num&gt;,\n \"poolCreated\" : &lt;num&gt;,\n \"poolRefreshing\" : &lt;num&gt;,\n \"acquisitionWaitTimes\" : &lt;document&gt;, // Added in MongoDB 6.3\n \"cfg1.example.net:27019\" : {\n \"inUse\" : &lt;num&gt;,\n \"available\" : &lt;num&gt;,\n \"leased\" : &lt;num&gt;,\n \"created\" : &lt;num&gt;,\n \"refreshing\" : &lt;num&gt;,\n \"acquisitionWaitTimes\" : &lt;document&gt; // Added in MongoDB 6.3\n }\n },\n \"NetworkInterfaceTL-ShardRegistry\" : {\n \"poolInUse\" : &lt;num&gt;,\n \"poolAvailable\" : &lt;num&gt;,\n \"poolLeased\" : &lt;num&gt;,\n \"poolCreated\" : &lt;num&gt;,\n \"poolRefreshing\" : &lt;num&gt;,\n \"acquisitionWaitTimes\" : &lt;document&gt;, // Added in MongoDB 6.3\n \"cfg1.example.net:27019\" : {\n \"inUse\" : &lt;num&gt;,\n \"available\" : &lt;num&gt;,\n \"leased\" : &lt;num&gt;,\n \"created\" : &lt;num&gt;,\n \"refreshing\" : &lt;num&gt;,\n \"acquisitionWaitTimes\" : &lt;document&gt; // Added in MongoDB 6.3\n },\n \"cfg2.example.net:27019\" : {\n \"inUse\" : &lt;num&gt;,\n \"available\" : &lt;num&gt;,\n \"leased\" : &lt;num&gt;,\n \"created\" : &lt;num&gt;,\n \"refreshing\" : &lt;num&gt;,\n \"acquisitionWaitTimes\" : &lt;document&gt; // Added in MongoDB 6.3\n },\n \"cfg3.example.net:27019\" : {\n \"inUse\" : &lt;num&gt;,\n \"available\" : &lt;num&gt;,\n \"leased\" : &lt;num&gt;,\n \"created\" : &lt;num&gt;,\n \"refreshing\" : &lt;num&gt;,\n \"acquisitionWaitTimes\" : &lt;document&gt; // Added in MongoDB 6.3\n },\n \"shard1.example.net:27018\" : {\n \"inUse\" : &lt;num&gt;,\n \"available\" : &lt;num&gt;,\n \"leased\" : &lt;num&gt;,\n \"created\" : &lt;num&gt;,\n \"refreshing\" : &lt;num&gt;,\n \"acquisitionWaitTimes\" : &lt;document&gt; // Added in MongoDB 6.3\n },\n \"shard2.example.net:27018\" : {\n \"inUse\" : &lt;num&gt;,\n \"available\" : &lt;num&gt;,\n \"leased\" : &lt;num&gt;,\n \"created\" : &lt;num&gt;,\n \"refreshing\" : &lt;num&gt;,\n \"acquisitionWaitTimes\" : &lt;document&gt; // Added in MongoDB 6.3\n }\n },\n \"global\" : {\n \"poolInUse\" : &lt;num&gt;,\n \"poolAvailable\" : &lt;num&gt;,\n \"poolLeased\" : &lt;num&gt;,\n \"poolCreated\" : &lt;num&gt;,\n \"poolRefreshing\" : &lt;num&gt;,\n \"acquisitionWaitTimes\" : &lt;document&gt;, // Added in MongoDB 6.3\n \"cfg3.example.net:27019\" : {\n \"inUse\" : &lt;num&gt;,\n \"available\" : &lt;num&gt;,\n \"leased\" : &lt;num&gt;,\n \"created\" : &lt;num&gt;,\n \"refreshing\" : &lt;num&gt;,\n \"acquisitionWaitTimes\" : &lt;document&gt; // Added in MongoDB 6.3\n },\n \"cfg1.example.net:27019\" : {\n \"inUse\" : &lt;num&gt;,\n \"available\" : &lt;num&gt;,\n \"leased\" : &lt;num&gt;,\n \"created\" : &lt;num&gt;,\n \"refreshing\" : &lt;num&gt;,\n \"acquisitionWaitTimes\" : &lt;document&gt; // Added in MongoDB 6.3\n },\n \"cfg2.example.net:27019\" : {\n \"inUse\" : &lt;num&gt;,\n \"available\" : &lt;num&gt;,\n \"leased\" : &lt;num&gt;,\n \"created\" : &lt;num&gt;,\n \"refreshing\" : &lt;num&gt;,\n \"acquisitionWaitTimes\" : &lt;document&gt; // Added in MongoDB 6.3\n },\n \"shard2.example.net:27018\" : {\n \"inUse\" : &lt;num&gt;,\n \"available\" : &lt;num&gt;,\n \"leased\" : &lt;num&gt;,\n \"created\" : &lt;num&gt;,\n \"refreshing\" : &lt;num&gt;,\n \"acquisitionWaitTimes\" : &lt;document&gt; // Added in MongoDB 6.3\n },\n \"shard1.example.net:27018\" : {\n \"inUse\" : &lt;num&gt;,\n \"available\" : &lt;num&gt;,\n \"leased\" : &lt;num&gt;,\n \"created\" : &lt;num&gt;,\n \"refreshing\" : &lt;num&gt;,\n \"acquisitionWaitTimes\" : &lt;document&gt; // Added in MongoDB 6.3\n }\n }\n },\n \"hosts\" : {\n \"cfg3.example.net:27019\" : {\n \"inUse\" : &lt;num&gt;,\n \"available\" : &lt;num&gt;,\n \"leased\" : &lt;num&gt;,\n \"created\" : &lt;num&gt;,\n \"refreshing\" : &lt;num&gt;,\n \"acquisitionWaitTimes\" : &lt;document&gt; // Added in MongoDB 6.3\n },\n \"cfg1.example.net:27019\" : {\n \"inUse\" : &lt;num&gt;,\n \"available\" : &lt;num&gt;,\n \"leased\" : &lt;num&gt;,\n \"created\" : &lt;num&gt;,\n \"refreshing\" : &lt;num&gt;,\n \"acquisitionWaitTimes\" : &lt;document&gt; // Added in MongoDB 6.3\n },\n \"cfg2.example.net:27019\" : {\n \"inUse\" : &lt;num&gt;,\n \"available\" : &lt;num&gt;,\n \"leased\" : &lt;num&gt;,\n \"created\" : &lt;num&gt;,\n \"refreshing\" : &lt;num&gt;,\n \"acquisitionWaitTimes\" : &lt;document&gt; // Added in MongoDB 6.3\n },\n \"shard2.example.net:27018\" : {\n \"inUse\" : &lt;num&gt;,\n \"available\" : &lt;num&gt;,\n \"leased\" : &lt;num&gt;,\n \"created\" : &lt;num&gt;,\n \"refreshing\" : &lt;num&gt;,\n \"acquisitionWaitTimes\" : &lt;document&gt; // Added in MongoDB 6.3\n },\n \"shard1.example.net:27018\" : {\n \"inUse\" : &lt;num&gt;,\n \"available\" : &lt;num&gt;,\n \"leased\" : &lt;num&gt;,\n \"created\" : &lt;num&gt;,\n \"refreshing\" : &lt;num&gt;,\n \"acquisitionWaitTimes\" : &lt;document&gt; // Added in MongoDB 6.3\n }\n },\n \"replicaSets\" : {\n \"csRS\" : {\n \"hosts\" : [\n {\n \"addr\" : \"cfg1.example.net:27019\",\n \"ok\" : &lt;bool&gt;,\n \"ismaster\" : &lt;bool&gt;,\n \"hidden\" : &lt;bool&gt;,\n \"secondary\" : &lt;bool&gt;,\n \"pingTimeMillis\" : &lt;num&gt;\n },\n {\n \"addr\" : \"cfg2.example.net:27019\",\n \"ok\" : &lt;bool&gt;,\n \"ismaster\" : &lt;bool&gt;,\n \"hidden\" : &lt;bool&gt;,\n \"secondary\" : &lt;bool&gt;,\n \"pingTimeMillis\" : &lt;num&gt;\n },\n {\n \"addr\" : \"cfg3.example.net:27019\",\n \"ok\" : &lt;bool&gt;,\n \"ismaster\" : &lt;bool&gt;,\n \"hidden\" : &lt;bool&gt;,\n \"secondary\" : &lt;bool&gt;,\n \"pingTimeMillis\" : &lt;num&gt;\n }\n ]\n },\n \"shardB\" : {\n \"hosts\" : [\n {\n \"addr\" : \"shard2.example.net:27018\",\n \"ok\" : &lt;bool&gt;,\n \"ismaster\" : &lt;bool&gt;,\n \"hidden\" : &lt;bool&gt;,\n \"secondary\" : &lt;bool&gt;,\n \"pingTimeMillis\" : &lt;num&gt;\n }\n ]\n },\n \"shardA\" : {\n \"hosts\" : [\n {\n \"addr\" : \"shard1.example.net:27018\",\n \"ok\" : &lt;bool&gt;,\n \"ismaster\" : &lt;bool&gt;,\n \"hidden\" : &lt;bool&gt;,\n \"secondary\" : &lt;bool&gt;,\n \"pingTimeMillis\" : &lt;num&gt;\n }\n ]\n }\n },\n \"ok\" : 1,\n \"$clusterTime\" : {\n \"clusterTime\" : &lt;timestamp&gt;,\n \"signature\" : &lt;document&gt;\n },\n \"operationTime\" : &lt;timestamp&gt;\n}","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"numClientConnections"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"numAScopedConnections"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"totalInUse"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"totalAvailable"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"totalLeased"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"totalCreated"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"totalRefreshing"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"replicaSetMatchingStrategy"</span> <!-- -->: &lt;<!-- -->string<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"acquisitionWaitTimes"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-comment">// Added in MongoDB 6.3</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"(-inf, 0ms)"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-string">"count"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt; <!-- -->}<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"[0ms, 50ms)"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-string">"count"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt; <!-- -->}<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"[50ms, 100ms)"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-string">"count"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt; <!-- -->}<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"[100ms, 150ms)"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-string">"count"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt; <!-- -->}<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"[150ms, 200ms)"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-string">"count"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt; <!-- -->}<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"[200ms, 250ms)"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-string">"count"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt; <!-- -->}<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"[250ms, 300ms)"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-string">"count"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt; <!-- -->}<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"[300ms, 350ms)"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-string">"count"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt; <!-- -->}<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"[350ms, 400ms)"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-string">"count"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt; <!-- -->}<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"[400ms, 450ms)"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-string">"count"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt; <!-- -->}<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"[450ms, 500ms)"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-string">"count"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt; <!-- -->}<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"[500ms, 550ms)"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-string">"count"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt; <!-- -->}<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"[550ms, 600ms)"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-string">"count"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt; <!-- -->}<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"[600ms, 650ms)"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-string">"count"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt; <!-- -->}<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"[650ms, 700ms)"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-string">"count"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt; <!-- -->}<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"[700ms, 750ms)"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-string">"count"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt; <!-- -->}<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"[750ms, 800ms)"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-string">"count"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt; <!-- -->}<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"[800ms, 850ms)"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-string">"count"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt; <!-- -->}<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"[850ms, 900ms)"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-string">"count"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt; <!-- -->}<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"[900ms, 950ms)"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-string">"count"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt; <!-- -->}<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"[950ms, 1000ms)"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-string">"count"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt; <!-- -->}<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"[1000ms, inf)"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-string">"count"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt; <!-- -->}<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"totalCount"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->}<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"pools"</span> <!-- -->: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"NetworkInterfaceTL-TaskExecutorPool-0"</span> <!-- -->: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"poolInUse"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"poolAvailable"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"poolLeased"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"poolCreated"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"poolRefreshing"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"acquisitionWaitTimes"</span> <!-- -->: &lt;<span class="lg-highlight-variable lg-highlight-language">document</span>&gt;<!-- -->,<!-- --> <span class="lg-highlight-comment">// Added in MongoDB 6.3</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"cfg1.example.net:27019"</span> <!-- -->: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"inUse"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"available"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"leased"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"created"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"refreshing"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"acquisitionWaitTimes"</span> <!-- -->: &lt;<span class="lg-highlight-variable lg-highlight-language">document</span>&gt; <span class="lg-highlight-comment">// Added in MongoDB 6.3</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->}<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->}<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"NetworkInterfaceTL-TaskExecutorPool-1"</span> <!-- -->: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"poolInUse"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"poolAvailable"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"poolLeased"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"poolCreated"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"poolRefreshing"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"acquisitionWaitTimes"</span> <!-- -->: &lt;<span class="lg-highlight-variable lg-highlight-language">document</span>&gt;<!-- -->,<!-- --> <span class="lg-highlight-comment">// Added in MongoDB 6.3</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"cfg1.example.net:27019"</span> <!-- -->: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"inUse"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"available"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"leased"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"created"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"refreshing"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"acquisitionWaitTimes"</span> <!-- -->: &lt;<span class="lg-highlight-variable lg-highlight-language">document</span>&gt; <span class="lg-highlight-comment">// Added in MongoDB 6.3</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->}</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"NetworkInterfaceTL-TaskExecutorPool-2"</span> <!-- -->: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"poolInUse"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"poolAvailable"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"poolLeased"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"poolCreated"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"poolRefreshing"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"acquisitionWaitTimes"</span> <!-- -->: &lt;<span class="lg-highlight-variable lg-highlight-language">document</span>&gt;<!-- -->,<!-- --> <span class="lg-highlight-comment">// Added in MongoDB 6.3</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"cfg1.example.net:27019"</span> <!-- -->: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"inUse"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"available"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"leased"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"created"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"refreshing"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"acquisitionWaitTimes"</span> <!-- -->: &lt;<span class="lg-highlight-variable lg-highlight-language">document</span>&gt; <span class="lg-highlight-comment">// Added in MongoDB 6.3</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->}</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"NetworkInterfaceTL-TaskExecutorPool-3"</span> <!-- -->: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"poolInUse"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"poolAvailable"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"poolLeased"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"poolCreated"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"poolRefreshing"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"acquisitionWaitTimes"</span> <!-- -->: &lt;<span class="lg-highlight-variable lg-highlight-language">document</span>&gt;<!-- -->,<!-- --> <span class="lg-highlight-comment">// Added in MongoDB 6.3</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"cfg1.example.net:27019"</span> <!-- -->: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"inUse"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"available"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"leased"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"created"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"refreshing"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"acquisitionWaitTimes"</span> <!-- -->: &lt;<span class="lg-highlight-variable lg-highlight-language">document</span>&gt; <span class="lg-highlight-comment">// Added in MongoDB 6.3</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->}</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"NetworkInterfaceTL-ShardRegistry"</span> <!-- -->: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"poolInUse"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"poolAvailable"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"poolLeased"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"poolCreated"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"poolRefreshing"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"acquisitionWaitTimes"</span> <!-- -->: &lt;<span class="lg-highlight-variable lg-highlight-language">document</span>&gt;<!-- -->,<!-- --> <span class="lg-highlight-comment">// Added in MongoDB 6.3</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"cfg1.example.net:27019"</span> <!-- -->: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"inUse"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"available"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"leased"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"created"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"refreshing"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"acquisitionWaitTimes"</span> <!-- -->: &lt;<span class="lg-highlight-variable lg-highlight-language">document</span>&gt; <span class="lg-highlight-comment">// Added in MongoDB 6.3</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->}<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"cfg2.example.net:27019"</span> <!-- -->: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"inUse"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"available"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"leased"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"created"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"refreshing"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"acquisitionWaitTimes"</span> <!-- -->: &lt;<span class="lg-highlight-variable lg-highlight-language">document</span>&gt; <span class="lg-highlight-comment">// Added in MongoDB 6.3</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->}<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"cfg3.example.net:27019"</span> <!-- -->: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"inUse"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"available"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"leased"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"created"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"refreshing"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"acquisitionWaitTimes"</span> <!-- -->: &lt;<span class="lg-highlight-variable lg-highlight-language">document</span>&gt; <span class="lg-highlight-comment">// Added in MongoDB 6.3</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->}<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"shard1.example.net:27018"</span> <!-- -->: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"inUse"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"available"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"leased"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"created"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"refreshing"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"acquisitionWaitTimes"</span> <!-- -->: &lt;<span class="lg-highlight-variable lg-highlight-language">document</span>&gt; <span class="lg-highlight-comment">// Added in MongoDB 6.3</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->}<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"shard2.example.net:27018"</span> <!-- -->: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"inUse"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"available"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"leased"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"created"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"refreshing"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"acquisitionWaitTimes"</span> <!-- -->: &lt;<span class="lg-highlight-variable lg-highlight-language">document</span>&gt; <span class="lg-highlight-comment">// Added in MongoDB 6.3</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->}</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"global"</span> <!-- -->: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"poolInUse"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"poolAvailable"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"poolLeased"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"poolCreated"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"poolRefreshing"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"acquisitionWaitTimes"</span> <!-- -->: &lt;<span class="lg-highlight-variable lg-highlight-language">document</span>&gt;<!-- -->,<!-- --> <span class="lg-highlight-comment">// Added in MongoDB 6.3</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"cfg3.example.net:27019"</span> <!-- -->: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"inUse"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"available"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"leased"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"created"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"refreshing"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"acquisitionWaitTimes"</span> <!-- -->: &lt;<span class="lg-highlight-variable lg-highlight-language">document</span>&gt; <span class="lg-highlight-comment">// Added in MongoDB 6.3</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->}<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"cfg1.example.net:27019"</span> <!-- -->: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"inUse"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"available"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"leased"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"created"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"refreshing"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"acquisitionWaitTimes"</span> <!-- -->: &lt;<span class="lg-highlight-variable lg-highlight-language">document</span>&gt; <span class="lg-highlight-comment">// Added in MongoDB 6.3</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->}<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"cfg2.example.net:27019"</span> <!-- -->: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"inUse"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"available"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"leased"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"created"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"refreshing"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"acquisitionWaitTimes"</span> <!-- -->: &lt;<span class="lg-highlight-variable lg-highlight-language">document</span>&gt; <span class="lg-highlight-comment">// Added in MongoDB 6.3</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->}<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"shard2.example.net:27018"</span> <!-- -->: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"inUse"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"available"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"leased"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"created"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"refreshing"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"acquisitionWaitTimes"</span> <!-- -->: &lt;<span class="lg-highlight-variable lg-highlight-language">document</span>&gt; <span class="lg-highlight-comment">// Added in MongoDB 6.3</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->}<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"shard1.example.net:27018"</span> <!-- -->: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"inUse"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"available"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"leased"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"created"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"refreshing"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"acquisitionWaitTimes"</span> <!-- -->: &lt;<span class="lg-highlight-variable lg-highlight-language">document</span>&gt; <span class="lg-highlight-comment">// Added in MongoDB 6.3</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->}</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"hosts"</span> <!-- -->: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"cfg3.example.net:27019"</span> <!-- -->: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"inUse"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"available"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"leased"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"created"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"refreshing"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"acquisitionWaitTimes"</span> <!-- -->: &lt;<span class="lg-highlight-variable lg-highlight-language">document</span>&gt; <span class="lg-highlight-comment">// Added in MongoDB 6.3</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->}<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"cfg1.example.net:27019"</span> <!-- -->: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"inUse"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"available"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"leased"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"created"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"refreshing"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"acquisitionWaitTimes"</span> <!-- -->: &lt;<span class="lg-highlight-variable lg-highlight-language">document</span>&gt; <span class="lg-highlight-comment">// Added in MongoDB 6.3</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->}<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"cfg2.example.net:27019"</span> <!-- -->: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"inUse"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"available"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"leased"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"created"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"refreshing"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"acquisitionWaitTimes"</span> <!-- -->: &lt;<span class="lg-highlight-variable lg-highlight-language">document</span>&gt; <span class="lg-highlight-comment">// Added in MongoDB 6.3</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->}<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"shard2.example.net:27018"</span> <!-- -->: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"inUse"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"available"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"leased"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"created"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"refreshing"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"acquisitionWaitTimes"</span> <!-- -->: &lt;<span class="lg-highlight-variable lg-highlight-language">document</span>&gt; <span class="lg-highlight-comment">// Added in MongoDB 6.3</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->}<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"shard1.example.net:27018"</span> <!-- -->: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"inUse"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"available"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"leased"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"created"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"refreshing"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"acquisitionWaitTimes"</span> <!-- -->: &lt;<span class="lg-highlight-variable lg-highlight-language">document</span>&gt; <span class="lg-highlight-comment">// Added in MongoDB 6.3</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->}</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"replicaSets"</span> <!-- -->: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"csRS"</span> <!-- -->: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"hosts"</span> <!-- -->: <!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"addr"</span> <!-- -->: <span class="lg-highlight-string">"cfg1.example.net:27019"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"ok"</span> <!-- -->: &lt;<!-- -->bool<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"ismaster"</span> <!-- -->: &lt;<!-- -->bool<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"hidden"</span> <!-- -->: &lt;<!-- -->bool<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"secondary"</span> <!-- -->: &lt;<!-- -->bool<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"pingTimeMillis"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->}<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"addr"</span> <!-- -->: <span class="lg-highlight-string">"cfg2.example.net:27019"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"ok"</span> <!-- -->: &lt;<!-- -->bool<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"ismaster"</span> <!-- -->: &lt;<!-- -->bool<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"hidden"</span> <!-- -->: &lt;<!-- -->bool<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"secondary"</span> <!-- -->: &lt;<!-- -->bool<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"pingTimeMillis"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->}<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"addr"</span> <!-- -->: <span class="lg-highlight-string">"cfg3.example.net:27019"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"ok"</span> <!-- -->: &lt;<!-- -->bool<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"ismaster"</span> <!-- -->: &lt;<!-- -->bool<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"hidden"</span> <!-- -->: &lt;<!-- -->bool<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"secondary"</span> <!-- -->: &lt;<!-- -->bool<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"pingTimeMillis"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->}</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> ]</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"shardB"</span> <!-- -->: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"hosts"</span> <!-- -->: <!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"addr"</span> <!-- -->: <span class="lg-highlight-string">"shard2.example.net:27018"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"ok"</span> <!-- -->: &lt;<!-- -->bool<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"ismaster"</span> <!-- -->: &lt;<!-- -->bool<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"hidden"</span> <!-- -->: &lt;<!-- -->bool<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"secondary"</span> <!-- -->: &lt;<!-- -->bool<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"pingTimeMillis"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->}</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> ]</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"shardA"</span> <!-- -->: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"hosts"</span> <!-- -->: <!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"addr"</span> <!-- -->: <span class="lg-highlight-string">"shard1.example.net:27018"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"ok"</span> <!-- -->: &lt;<!-- -->bool<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"ismaster"</span> <!-- -->: &lt;<!-- -->bool<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"hidden"</span> <!-- -->: &lt;<!-- -->bool<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"secondary"</span> <!-- -->: &lt;<!-- -->bool<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"pingTimeMillis"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->}</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> ]</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"ok"</span> <!-- -->: <span class="lg-highlight-number">1</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"$clusterTime"</span> <!-- -->: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"clusterTime"</span> <!-- -->: &lt;<!-- -->timestamp<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"signature"</span> <!-- -->: &lt;<span class="lg-highlight-variable lg-highlight-language">document</span>&gt;</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->}<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"operationTime"</span> <!-- -->: &lt;<!-- -->timestamp<!-- -->&gt;</td></tr><tr class=""><td class="leafygreen-ui-7razhx">}</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> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Output <a class="headerlink leafygreen-ui-1kepx47" href="#output" 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="output"> </div> </a> </h2> <dl class="data"> <dt> <code class="leafygreen-ui-1l06pbn"> connPoolStats.totalAvailable </code> <a class="headerlink leafygreen-ui-1kepx47" href="#mongodb-data-connPoolStats.totalAvailable" title="Permalink to this definition"> <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="mongodb-data-connPoolStats.totalAvailable"> </div> </a> </dt> <dd> <p class="leafygreen-ui-1kp3ins"> Reports the total number of available outgoing connections from the current <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> / <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongos/#mongodb-binary-bin.mongos"> <code class="leafygreen-ui-1l06pbn"> mongos </code> </a> instance to other members of the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-sharded-cluster"> sharded cluster </a> or <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-replica-set"> replica set <!-- --> . </a> </p> </dd> </dl> <dl class="data"> <dt> <code class="leafygreen-ui-1l06pbn"> connPoolStats.totalLeased </code> <a class="headerlink leafygreen-ui-1kepx47" href="#mongodb-data-connPoolStats.totalLeased" title="Permalink to this definition"> <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="mongodb-data-connPoolStats.totalLeased"> </div> </a> </dt> <dd> <p class="leafygreen-ui-1kp3ins"> Reports the total number of connections borrowed from a pool and expected to return. These connections might not remain active through the duration of a lease, and are excluded from the related metrics. These connections are unavailble through the duration of the lease. </p> </dd> </dl> <dl class="data"> <dt> <code class="leafygreen-ui-1l06pbn"> connPoolStats.totalCreated </code> <a class="headerlink leafygreen-ui-1kepx47" href="#mongodb-data-connPoolStats.totalCreated" title="Permalink to this definition"> <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="mongodb-data-connPoolStats.totalCreated"> </div> </a> </dt> <dd> <p class="leafygreen-ui-1kp3ins"> Reports the total number of outgoing connections ever created by the current <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> / <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongos/#mongodb-binary-bin.mongos"> <code class="leafygreen-ui-1l06pbn"> mongos </code> </a> instance to other members of the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-sharded-cluster"> sharded cluster </a> or <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-replica-set"> replica set <!-- --> . </a> </p> </dd> </dl> <dl class="data"> <dt> <code class="leafygreen-ui-1l06pbn"> connPoolStats.totalInUse </code> <a class="headerlink leafygreen-ui-1kepx47" href="#mongodb-data-connPoolStats.totalInUse" title="Permalink to this definition"> <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="mongodb-data-connPoolStats.totalInUse"> </div> </a> </dt> <dd> <p class="leafygreen-ui-1kp3ins"> Reports the total number of outgoing connections from the current <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> / <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongos/#mongodb-binary-bin.mongos"> <code class="leafygreen-ui-1l06pbn"> mongos </code> </a> instance to other members of the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-sharded-cluster"> sharded cluster </a> or <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-replica-set"> replica set </a> that are currently in use. </p> </dd> </dl> <dl class="data"> <dt> <code class="leafygreen-ui-1l06pbn"> connPoolStats.totalRefreshing </code> <a class="headerlink leafygreen-ui-1kepx47" href="#mongodb-data-connPoolStats.totalRefreshing" title="Permalink to this definition"> <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="mongodb-data-connPoolStats.totalRefreshing"> </div> </a> </dt> <dd> <p class="leafygreen-ui-1kp3ins"> Reports the total number of outgoing connections from the current <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> / <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongos/#mongodb-binary-bin.mongos"> <code class="leafygreen-ui-1l06pbn"> mongos </code> </a> instance to other members of the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-sharded-cluster"> sharded cluster </a> or <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-replica-set"> replica set </a> that are currently being refreshed. </p> </dd> </dl> <dl class="data"> <dt> <code class="leafygreen-ui-1l06pbn"> connPoolStats.totalWasNeverUsed </code> <a class="headerlink leafygreen-ui-1kepx47" href="#mongodb-data-connPoolStats.totalWasNeverUsed" title="Permalink to this definition"> <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="mongodb-data-connPoolStats.totalWasNeverUsed"> </div> </a> </dt> <dd> <p class="leafygreen-ui-1kp3ins"> Reports the total number of outgoing connections from the current <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> / <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongos/#mongodb-binary-bin.mongos"> <code class="leafygreen-ui-1l06pbn"> mongos </code> </a> instance to other members of the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-sharded-cluster"> sharded cluster </a> or <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-replica-set"> replica set </a> that were closed having never been used. </p> </dd> </dl> <dl class="data"> <dt> <code class="leafygreen-ui-1l06pbn"> connPoolStats.replicaSetMatchingStrategy </code> <a class="headerlink leafygreen-ui-1kepx47" href="#mongodb-data-connPoolStats.replicaSetMatchingStrategy" title="Permalink to this definition"> <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="mongodb-data-connPoolStats.replicaSetMatchingStrategy"> </div> </a> </dt> <dd> <div> <p> <em> New <!-- --> in version <!-- --> 5.0 </em> . </p> </div> <p class="leafygreen-ui-1kp3ins"> On a <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongos/#mongodb-binary-bin.mongos"> <code class="leafygreen-ui-1l06pbn"> mongos </code> </a> instance, this value reports the policy used by the instance to determine the minimum size limit of its connection pools to nodes within replica sets. </p> <p class="leafygreen-ui-1kp3ins"> On a <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> instance, this value reports the policy used by the instance to determine the minimum size limit of its connection pools to nodes within <em> other </em> replica sets. </p> <p class="leafygreen-ui-1kp3ins"> The policy for <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongos/#mongodb-binary-bin.mongos"> <code class="leafygreen-ui-1l06pbn"> mongos </code> </a> and <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> can be set with the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/parameters/#mongodb-parameter-param.ShardingTaskExecutorPoolReplicaSetMatching"> <code class="leafygreen-ui-1l06pbn"> ShardingTaskExecutorPoolReplicaSetMatching </code> </a> parameter. </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"> If the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/parameters/#mongodb-parameter-param.ShardingTaskExecutorPoolReplicaSetMatching"> <code class="leafygreen-ui-1l06pbn"> ShardingTaskExecutorPoolReplicaSetMatching </code> </a> is set to <code class="leafygreen-ui-1l06pbn"> "automatic" </code> , the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-data-connPoolStats.replicaSetMatchingStrategy" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> replicaSetMatchingStrategy </code> </span> </a> still describes the actual policy being used, not <code class="leafygreen-ui-1l06pbn"> "automatic" </code> . To find the value of the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/parameters/#mongodb-parameter-param.ShardingTaskExecutorPoolReplicaSetMatching"> <code class="leafygreen-ui-1l06pbn"> ShardingTaskExecutorPoolReplicaSetMatching </code> </a> , use <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/command/getParameter/#mongodb-dbcommand-dbcmd.getParameter"> <code class="leafygreen-ui-1l06pbn"> getParameter </code> </a> which returns the value of the server parameter: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.adminCommand( { getParameter : 1, \"ShardingTaskExecutorPoolReplicaSetMatching\" : 1 } )","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-1q4bxgx" tabindex="0"><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">adminCommand</span>( <!-- -->{ <!-- -->getParameter <!-- -->: <span class="lg-highlight-number">1</span>, <span class="lg-highlight-string">"ShardingTaskExecutorPoolReplicaSetMatching"</span> <!-- -->: <span class="lg-highlight-number">1</span> } )</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> </div> </dd> </dl> <dl class="data"> <dt> <code class="leafygreen-ui-1l06pbn"> connPoolStats.acquisitionWaitTimes </code> <a class="headerlink leafygreen-ui-1kepx47" href="#mongodb-data-connPoolStats.acquisitionWaitTimes" title="Permalink to this definition"> <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="mongodb-data-connPoolStats.acquisitionWaitTimes"> </div> </a> </dt> <dd> <div> <p> <em> New <!-- --> in version <!-- --> 6.3 </em> . </p> </div> <p class="leafygreen-ui-1kp3ins"> Document reports a histogram with the wait times for requests to acquire a connection from <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongos/#mongodb-binary-bin.mongos"> <code class="leafygreen-ui-1l06pbn"> mongos </code> </a> to <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> : </a> </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> The document contains time ranges in milliseconds and the number of connection requests in each range. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <code class="leafygreen-ui-1l06pbn"> -inf </code> is negative infinity and connection requests in the range <code class="leafygreen-ui-1l06pbn"> (-inf, 0ms) </code> did not wait. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <code class="leafygreen-ui-1l06pbn"> inf </code> is positive infinity and connection requests in the range <code class="leafygreen-ui-1l06pbn"> [1000ms, inf) </code> waited a time greater than or equal to 1,000 milliseconds. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <code class="leafygreen-ui-1l06pbn"> totalCount </code> is the total number of connection requests for all time ranges. </p> </li> </ul> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"\"acquisitionWaitTimes\" : {\n \"(-inf, 0ms)\" : { \"count\" : &lt;num&gt; },\n \"[0ms, 50ms)\" : { \"count\" : &lt;num&gt; },\n \"[50ms, 100ms)\" : { \"count\" : &lt;num&gt; },\n \"[100ms, 150ms)\" : { \"count\" : &lt;num&gt; },\n \"[150ms, 200ms)\" : { \"count\" : &lt;num&gt; },\n \"[200ms, 250ms)\" : { \"count\" : &lt;num&gt; },\n \"[250ms, 300ms)\" : { \"count\" : &lt;num&gt; },\n \"[300ms, 350ms)\" : { \"count\" : &lt;num&gt; },\n \"[350ms, 400ms)\" : { \"count\" : &lt;num&gt; },\n \"[400ms, 450ms)\" : { \"count\" : &lt;num&gt; },\n \"[450ms, 500ms)\" : { \"count\" : &lt;num&gt; },\n \"[500ms, 550ms)\" : { \"count\" : &lt;num&gt; },\n \"[550ms, 600ms)\" : { \"count\" : &lt;num&gt; },\n \"[600ms, 650ms)\" : { \"count\" : &lt;num&gt; },\n \"[650ms, 700ms)\" : { \"count\" : &lt;num&gt; },\n \"[700ms, 750ms)\" : { \"count\" : &lt;num&gt; },\n \"[750ms, 800ms)\" : { \"count\" : &lt;num&gt; },\n \"[800ms, 850ms)\" : { \"count\" : &lt;num&gt; },\n \"[850ms, 900ms)\" : { \"count\" : &lt;num&gt; },\n \"[900ms, 950ms)\" : { \"count\" : &lt;num&gt; },\n \"[950ms, 1000ms)\" : { \"count\" : &lt;num&gt; },\n \"[1000ms, inf)\" : { \"count\" : &lt;num&gt; },\n \"totalCount\" : &lt;num&gt;\n}","programmingLanguage":"JavaScript"} </script> <div class="css-1lju8ps"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1jheeh3"> <pre class="leafygreen-ui-1453az5" 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"><span class="lg-highlight-string">"acquisitionWaitTimes"</span> <!-- -->: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"(-inf, 0ms)"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-string">"count"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt; <!-- -->}<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"[0ms, 50ms)"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-string">"count"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt; <!-- -->}<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"[50ms, 100ms)"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-string">"count"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt; <!-- -->}<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"[100ms, 150ms)"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-string">"count"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt; <!-- -->}<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"[150ms, 200ms)"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-string">"count"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt; <!-- -->}<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"[200ms, 250ms)"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-string">"count"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt; <!-- -->}<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"[250ms, 300ms)"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-string">"count"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt; <!-- -->}<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"[300ms, 350ms)"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-string">"count"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt; <!-- -->}<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"[350ms, 400ms)"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-string">"count"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt; <!-- -->}<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"[400ms, 450ms)"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-string">"count"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt; <!-- -->}<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"[450ms, 500ms)"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-string">"count"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt; <!-- -->}<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"[500ms, 550ms)"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-string">"count"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt; <!-- -->}<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"[550ms, 600ms)"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-string">"count"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt; <!-- -->}<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"[600ms, 650ms)"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-string">"count"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt; <!-- -->}<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"[650ms, 700ms)"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-string">"count"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt; <!-- -->}<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"[700ms, 750ms)"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-string">"count"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt; <!-- -->}<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"[750ms, 800ms)"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-string">"count"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt; <!-- -->}<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"[800ms, 850ms)"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-string">"count"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt; <!-- -->}<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"[850ms, 900ms)"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-string">"count"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt; <!-- -->}<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"[900ms, 950ms)"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-string">"count"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt; <!-- -->}<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"[950ms, 1000ms)"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-string">"count"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt; <!-- -->}<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"[1000ms, inf)"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-string">"count"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt; <!-- -->}<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"totalCount"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;</td></tr><tr class=""><td class="leafygreen-ui-7razhx">}</td></tr></tbody></table></code></pre> </div> </div> </div> </dd> </dl> <dl class="data"> <dt> <code class="leafygreen-ui-1l06pbn"> connPoolStats.numClientConnection </code> <a class="headerlink leafygreen-ui-1kepx47" href="#mongodb-data-connPoolStats.numClientConnection" title="Permalink to this definition"> <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="mongodb-data-connPoolStats.numClientConnection"> </div> </a> </dt> <dd> <p class="leafygreen-ui-1kp3ins"> Reports the number of active and stored outgoing <strong> synchronous </strong> connections from the current <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> / <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongos/#mongodb-binary-bin.mongos"> <code class="leafygreen-ui-1l06pbn"> mongos </code> </a> instance to other members of the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-sharded-cluster"> sharded cluster </a> or <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-replica-set"> replica set <!-- --> . </a> </p> <p class="leafygreen-ui-1kp3ins"> These connections are a part of a pool that is a subset of the data reported by <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-data-connPoolStats.totalAvailable" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> totalAvailable </code> </span> </a> , <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-data-connPoolStats.totalCreated" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> totalCreated </code> </span> </a> , and <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-data-connPoolStats.totalInUse" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> totalInUse </code> . </span> </a> </p> </dd> </dl> <dl class="data"> <dt> <code class="leafygreen-ui-1l06pbn"> connPoolStats.numAScopedConnection </code> <a class="headerlink leafygreen-ui-1kepx47" href="#mongodb-data-connPoolStats.numAScopedConnection" title="Permalink to this definition"> <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="mongodb-data-connPoolStats.numAScopedConnection"> </div> </a> </dt> <dd> <p class="leafygreen-ui-1kp3ins"> Reports the number of active and stored outgoing <strong> scoped synchronous </strong> connections from the current <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> / <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongos/#mongodb-binary-bin.mongos"> <code class="leafygreen-ui-1l06pbn"> mongos </code> </a> instance to other members of the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-sharded-cluster"> sharded cluster </a> or <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-replica-set"> replica set <!-- --> . </a> </p> <p class="leafygreen-ui-1kp3ins"> These connections are a part of a pool that is a subset of the data reported by <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-data-connPoolStats.totalAvailable" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> totalAvailable </code> </span> </a> , <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-data-connPoolStats.totalCreated" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> totalCreated </code> </span> </a> , and <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-data-connPoolStats.totalInUse" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> totalInUse </code> . </span> </a> </p> </dd> </dl> <dl class="data"> <dt> <code class="leafygreen-ui-1l06pbn"> connPoolStats.pools </code> <a class="headerlink leafygreen-ui-1kepx47" href="#mongodb-data-connPoolStats.pools" title="Permalink to this definition"> <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="mongodb-data-connPoolStats.pools"> </div> </a> </dt> <dd> <p class="leafygreen-ui-1kp3ins"> Reports on connection statistics (in use/available/created/refreshing) grouped by the connection pools. A <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> or <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongos/#mongodb-binary-bin.mongos"> <code class="leafygreen-ui-1l06pbn"> mongos </code> </a> has two distinct families of outgoing connection pools: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> DBClient-based pools (the "write path") and </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> NetworkInterfaceTL-based pools (the "read path"). </p> </li> </ul> <p class="leafygreen-ui-1kp3ins"> For each pool, the command returns a document that resembles the following: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{\n \"poolInUse\" : &lt;num&gt;,\n \"poolAvailable\" : &lt;num&gt;,\n \"poolLeased\" : &lt;num&gt;,\n \"poolCreated\" : &lt;num&gt;,\n \"poolRefreshing\" : &lt;num&gt;,\n \"acquisitionWaitTimes\" : &lt;document&gt;, // Added in MongoDB 6.3\n \"[host1]\" : {\n \"inUse\" : &lt;num&gt;, \"available\" : &lt;num&gt;, \"leased\" : &lt;num&gt;, \"created\" : &lt;num&gt;, \"refreshing\" : &lt;num&gt;,\n \"acquisitionWaitTimes\" : &lt;document&gt; // Added in MongoDB 6.3\n },\n \"[host2]\" : {\n \"inUse\" : &lt;num&gt;, \"available\" : &lt;num&gt;, \"leased\" : &lt;num&gt;, \"created\" : &lt;num&gt;, \"refreshing\" : &lt;num&gt;,\n \"acquisitionWaitTimes\" : &lt;document&gt; // Added in MongoDB 6.3\n },\n ...\n}"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><code class="lg-highlight-hljs-light none leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> "poolInUse" : &lt;num&gt;,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> "poolAvailable" : &lt;num&gt;,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> "poolLeased" : &lt;num&gt;,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> "poolCreated" : &lt;num&gt;,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> "poolRefreshing" : &lt;num&gt;,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> "acquisitionWaitTimes" : &lt;document&gt;, // Added in MongoDB 6.3</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> "[host1]" : {</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> "inUse" : &lt;num&gt;, "available" : &lt;num&gt;, "leased" : &lt;num&gt;, "created" : &lt;num&gt;, "refreshing" : &lt;num&gt;,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> "acquisitionWaitTimes" : &lt;document&gt; // Added in MongoDB 6.3</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> },</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> "[host2]" : {</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> "inUse" : &lt;num&gt;, "available" : &lt;num&gt;, "leased" : &lt;num&gt;, "created" : &lt;num&gt;, "refreshing" : &lt;num&gt;,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> "acquisitionWaitTimes" : &lt;document&gt; // Added in MongoDB 6.3</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> },</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> ...</td></tr><tr class=""><td class="leafygreen-ui-7razhx">}</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-15mdk4" role="note"> <h2 class="leafygreen-ui-6n7b7d"> Note </h2> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> If there are no connections (in use/available/created/refreshing) for a particular pool, the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-dbcommand-dbcmd.connPoolStats" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> connPoolStats </code> </span> </a> does not return statistics for that pool. </p> </div> </div> <dl class="data"> <dt> <code class="leafygreen-ui-1l06pbn"> connPoolStats.pools.NetworkInterfaceTL-TaskExecutorPool-[n] </code> <a class="headerlink leafygreen-ui-1kepx47" href="#mongodb-data-connPoolStats.pools.NetworkInterfaceTL-TaskExecutorPool--n-" title="Permalink to this definition"> <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="mongodb-data-connPoolStats.pools.NetworkInterfaceTL-TaskExecutorPool--n-"> </div> </a> </dt> <dd> <p class="leafygreen-ui-1kp3ins"> Displays connection statics related to TaskExecutor pools. Typically, there will be one TaskExecutorPool per core, e.g. <code class="leafygreen-ui-1l06pbn"> pools.NetworkInterfaceTL-TaskExecutorPool-0 </code> ... <code class="leafygreen-ui-1l06pbn"> pools.NetworkInterfaceTL-TaskExecutorPool-7 </code> for an 8-core processor. </p> <div class="leafygreen-ui-13vw3ie" role="note"> <h2 class="leafygreen-ui-1fn4p2b"> Tip </h2> <h3 class="leafygreen-ui-144d5kf"> <strong> See also: </strong> </h3> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/parameters/#mongodb-parameter-param.taskExecutorPoolSize"> <code class="leafygreen-ui-1l06pbn"> taskExecutorPoolSize </code> </a> </p> </div> </div> </dd> </dl> <dl class="data"> <dt> <code class="leafygreen-ui-1l06pbn"> connPoolStats.pools.NetworkInterfaceTL-ShardRegistry </code> <a class="headerlink leafygreen-ui-1kepx47" href="#mongodb-data-connPoolStats.pools.NetworkInterfaceTL-ShardRegistry" title="Permalink to this definition"> <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="mongodb-data-connPoolStats.pools.NetworkInterfaceTL-ShardRegistry"> </div> </a> </dt> <dd> <p class="leafygreen-ui-1kp3ins"> <em> Available if the command is run on a member of a sharded cluster. </em> </p> <p class="leafygreen-ui-1kp3ins"> Displays the pool statistics for the connections between the current <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> / <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongos/#mongodb-binary-bin.mongos"> <code class="leafygreen-ui-1l06pbn"> mongos </code> </a> instance and other members of the sharded cluster. </p> </dd> </dl> <dl class="data"> <dt> <code class="leafygreen-ui-1l06pbn"> connPoolStats.pools.NetworkInterfaceTL-Replication </code> <a class="headerlink leafygreen-ui-1kepx47" href="#mongodb-data-connPoolStats.pools.NetworkInterfaceTL-Replication" title="Permalink to this definition"> <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="mongodb-data-connPoolStats.pools.NetworkInterfaceTL-Replication"> </div> </a> </dt> <dd> <p class="leafygreen-ui-1kp3ins"> <em> Available if the command is run on a member of a replica set. </em> </p> <p class="leafygreen-ui-1kp3ins"> Displays the pool statistics for the connections between the current <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> instance and the other members of the replica set. </p> </dd> </dl> <dl class="data"> <dt> <code class="leafygreen-ui-1l06pbn"> connPoolStats.pools.global </code> <a class="headerlink leafygreen-ui-1kepx47" href="#mongodb-data-connPoolStats.pools.global" title="Permalink to this definition"> <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="mongodb-data-connPoolStats.pools.global"> </div> </a> </dt> <dd> <p class="leafygreen-ui-1kp3ins"> Displays the DBClient-based pool statistics. </p> </dd> </dl> <dl class="data"> <dt> <code class="leafygreen-ui-1l06pbn"> connPoolStats.pools.[pool].poolWasNeverUsed </code> <a class="headerlink leafygreen-ui-1kepx47" href="#mongodb-data-connPoolStats.pools.-pool-.poolWasNeverUsed" title="Permalink to this definition"> <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="mongodb-data-connPoolStats.pools.-pool-.poolWasNeverUsed"> </div> </a> </dt> <dd> <p class="leafygreen-ui-1kp3ins"> Displays the number of connections in this connection pool that were closed having never been used. </p> </dd> </dl> <dl class="data"> <dt> <code class="leafygreen-ui-1l06pbn"> connPoolStats.pools.[pool].acquisitionWaitTimes </code> <a class="headerlink leafygreen-ui-1kepx47" href="#mongodb-data-connPoolStats.pools.-pool-.acquisitionWaitTimes" title="Permalink to this definition"> <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="mongodb-data-connPoolStats.pools.-pool-.acquisitionWaitTimes"> </div> </a> </dt> <dd> <div> <p> <em> New <!-- --> in version <!-- --> 6.3 </em> . </p> </div> <p class="leafygreen-ui-1kp3ins"> Reports the wait times for requests to acquire a connection from <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongos/#mongodb-binary-bin.mongos"> <code class="leafygreen-ui-1l06pbn"> mongos </code> </a> to <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> . For details, see <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-data-connPoolStats.acquisitionWaitTimes" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> connPoolStats.acquisitionWaitTimes </code> . </span> </a> </p> </dd> </dl> </dd> </dl> <dl class="data"> <dt> <code class="leafygreen-ui-1l06pbn"> connPoolStats.hosts </code> <a class="headerlink leafygreen-ui-1kepx47" href="#mongodb-data-connPoolStats.hosts" title="Permalink to this definition"> <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="mongodb-data-connPoolStats.hosts"> </div> </a> </dt> <dd> <p class="leafygreen-ui-1kp3ins"> Reports on connection statistics (in use/available/created/refreshing) grouped by the hosts. </p> <p class="leafygreen-ui-1kp3ins"> Contains <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-document"> documents </a> that represent a report of connections between the current <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> / <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongos/#mongodb-binary-bin.mongos"> <code class="leafygreen-ui-1l06pbn"> mongos </code> </a> instance and each member of the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-sharded-cluster"> sharded cluster </a> or <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-replica-set"> replica set <!-- --> . </a> </p> <dl class="data"> <dt> <code class="leafygreen-ui-1l06pbn"> connPoolStats.hosts.[host].available </code> <a class="headerlink leafygreen-ui-1kepx47" href="#mongodb-data-connPoolStats.hosts.-host-.available" title="Permalink to this definition"> <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="mongodb-data-connPoolStats.hosts.-host-.available"> </div> </a> </dt> <dd> <p class="leafygreen-ui-1kp3ins"> Reports the total number of connections available for connecting to the <code class="leafygreen-ui-1l06pbn"> [host] </code> . </p> </dd> </dl> <dl class="data"> <dt> <code class="leafygreen-ui-1l06pbn"> connPoolStats.hosts.[host].leased </code> <a class="headerlink leafygreen-ui-1kepx47" href="#mongodb-data-connPoolStats.hosts.-host-.leased" title="Permalink to this definition"> <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="mongodb-data-connPoolStats.hosts.-host-.leased"> </div> </a> </dt> <dd> <p class="leafygreen-ui-1kp3ins"> Reports the total number of connections to the host borrowed from a pool and expected to return. These connections might not remain active through the duration of a lease, and are excluded from the related metrics. These connections are unavailble through the duration of the lease. </p> </dd> </dl> <dl class="data"> <dt> <code class="leafygreen-ui-1l06pbn"> connPoolStats.hosts.[host].created </code> <a class="headerlink leafygreen-ui-1kepx47" href="#mongodb-data-connPoolStats.hosts.-host-.created" title="Permalink to this definition"> <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="mongodb-data-connPoolStats.hosts.-host-.created"> </div> </a> </dt> <dd> <p class="leafygreen-ui-1kp3ins"> Reports the number of connections to the <code class="leafygreen-ui-1l06pbn"> [host] </code> ever created. </p> </dd> </dl> <dl class="data"> <dt> <code class="leafygreen-ui-1l06pbn"> connPoolStats.hosts.[host].inUse </code> <a class="headerlink leafygreen-ui-1kepx47" href="#mongodb-data-connPoolStats.hosts.-host-.inUse" title="Permalink to this definition"> <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="mongodb-data-connPoolStats.hosts.-host-.inUse"> </div> </a> </dt> <dd> <p class="leafygreen-ui-1kp3ins"> Reports the number of connections to the <code class="leafygreen-ui-1l06pbn"> [host] </code> that are currently in use. </p> </dd> </dl> <dl class="data"> <dt> <code class="leafygreen-ui-1l06pbn"> connPoolStats.hosts.[host].wasNeverUsed </code> <a class="headerlink leafygreen-ui-1kepx47" href="#mongodb-data-connPoolStats.hosts.-host-.wasNeverUsed" title="Permalink to this definition"> <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="mongodb-data-connPoolStats.hosts.-host-.wasNeverUsed"> </div> </a> </dt> <dd> <p class="leafygreen-ui-1kp3ins"> Reports the total number of outgoing connections from <code class="leafygreen-ui-1l06pbn"> host </code> to other members of the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-sharded-cluster"> sharded cluster </a> or <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-replica-set"> replica set </a> that were closed having never been used. </p> </dd> </dl> <dl class="data"> <dt> <code class="leafygreen-ui-1l06pbn"> connPoolStats.hosts.[host].acquisitionWaitTimes </code> <a class="headerlink leafygreen-ui-1kepx47" href="#mongodb-data-connPoolStats.hosts.-host-.acquisitionWaitTimes" title="Permalink to this definition"> <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="mongodb-data-connPoolStats.hosts.-host-.acquisitionWaitTimes"> </div> </a> </dt> <dd> <div> <p> <em> New <!-- --> in version <!-- --> 6.3 </em> . </p> </div> <p class="leafygreen-ui-1kp3ins"> Reports the wait times for requests to acquire a connection from <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongos/#mongodb-binary-bin.mongos"> <code class="leafygreen-ui-1l06pbn"> mongos </code> </a> to <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> . For details, see <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-data-connPoolStats.acquisitionWaitTimes" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> connPoolStats.acquisitionWaitTimes </code> . </span> </a> </p> </dd> </dl> </dd> </dl> <dl class="data"> <dt> <code class="leafygreen-ui-1l06pbn"> connPoolStats.replicaSets </code> <a class="headerlink leafygreen-ui-1kepx47" href="#mongodb-data-connPoolStats.replicaSets" title="Permalink to this definition"> <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="mongodb-data-connPoolStats.replicaSets"> </div> </a> </dt> <dd> <p class="leafygreen-ui-1kp3ins"> Contains <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-document"> documents </a> that represent a report of information related to each replica set connected to the current <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> / <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongos/#mongodb-binary-bin.mongos"> <code class="leafygreen-ui-1l06pbn"> mongos </code> . </a> </p> <dl class="data"> <dt> <code class="leafygreen-ui-1l06pbn"> connPoolStats.replicaSets.replicaSet </code> <a class="headerlink leafygreen-ui-1kepx47" href="#mongodb-data-connPoolStats.replicaSets.replicaSet" title="Permalink to this definition"> <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="mongodb-data-connPoolStats.replicaSets.replicaSet"> </div> </a> </dt> <dd> <p class="leafygreen-ui-1kp3ins"> Reports on each <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-replica-set"> replica set </a> connected to the current <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> / <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongos/#mongodb-binary-bin.mongos"> <code class="leafygreen-ui-1l06pbn"> mongos </code> . </a> </p> </dd> </dl> <dl class="data"> <dt> <code class="leafygreen-ui-1l06pbn"> connPoolStats.replicaSets.[replicaSets].hosts </code> <a class="headerlink leafygreen-ui-1kepx47" href="#mongodb-data-connPoolStats.replicaSets.-replicaSets-.hosts" title="Permalink to this definition"> <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="mongodb-data-connPoolStats.replicaSets.-replicaSets-.hosts"> </div> </a> </dt> <dd> <p class="leafygreen-ui-1kp3ins"> Holds an array of <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-document"> documents </a> that reports on each member in the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-replica-set"> replica set <!-- --> . </a> </p> <p class="leafygreen-ui-1kp3ins"> These values derive from the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/command/replSetGetStatus/"> replica set status </a> values. </p> <dl class="data"> <dt> <code class="leafygreen-ui-1l06pbn"> connPoolStats.replicaSets.[replicaSet].hosts[n].addr </code> <a class="headerlink leafygreen-ui-1kepx47" href="#mongodb-data-connPoolStats.replicaSets.-replicaSet-.hosts-n-.addr" title="Permalink to this definition"> <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="mongodb-data-connPoolStats.replicaSets.-replicaSet-.hosts-n-.addr"> </div> </a> </dt> <dd> <p class="leafygreen-ui-1kp3ins"> Reports the address for the member in the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-replica-set"> replica set </a> in <code class="leafygreen-ui-1l06pbn"> [hostname]:[port] </code> format. </p> </dd> </dl> <dl class="data"> <dt> <code class="leafygreen-ui-1l06pbn"> connPoolStats.replicaSets.[replicaSet].hosts[n].ok </code> <a class="headerlink leafygreen-ui-1kepx47" href="#mongodb-data-connPoolStats.replicaSets.-replicaSet-.hosts-n-.ok" title="Permalink to this definition"> <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="mongodb-data-connPoolStats.replicaSets.-replicaSet-.hosts-n-.ok"> </div> </a> </dt> <dd> <p class="leafygreen-ui-1kp3ins"> Reports <code class="leafygreen-ui-1l06pbn"> false </code> when: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> the current <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> cannot connect to instance. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> the current <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> received a connection exception or error. </p> </li> </ul> <p class="leafygreen-ui-1kp3ins"> This field is for internal use. </p> </dd> </dl> <dl class="data"> <dt> <code class="leafygreen-ui-1l06pbn"> connPoolStats.replicaSets.[replicaSet].hosts[n].ismaster </code> <a class="headerlink leafygreen-ui-1kepx47" href="#mongodb-data-connPoolStats.replicaSets.-replicaSet-.hosts-n-.ismaster" title="Permalink to this definition"> <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="mongodb-data-connPoolStats.replicaSets.-replicaSet-.hosts-n-.ismaster"> </div> </a> </dt> <dd> <p class="leafygreen-ui-1kp3ins"> Reports <code class="leafygreen-ui-1l06pbn"> true </code> if this <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-data-connPoolStats.replicaSets.-replicaSets-.hosts" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> host </code> </span> </a> is the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-primary"> primary </a> member of the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-replica-set"> replica set <!-- --> . </a> </p> </dd> </dl> <dl class="data"> <dt> <code class="leafygreen-ui-1l06pbn"> connPoolStats.replicaSets.[replicaSet].hosts[n].hidden </code> <a class="headerlink leafygreen-ui-1kepx47" href="#mongodb-data-connPoolStats.replicaSets.-replicaSet-.hosts-n-.hidden" title="Permalink to this definition"> <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="mongodb-data-connPoolStats.replicaSets.-replicaSet-.hosts-n-.hidden"> </div> </a> </dt> <dd> <p class="leafygreen-ui-1kp3ins"> Reports <code class="leafygreen-ui-1l06pbn"> true </code> if this <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-data-connPoolStats.replicaSets.-replicaSets-.hosts" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> host </code> </span> </a> is a <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-hidden-member"> hidden member </a> of the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-replica-set"> replica set <!-- --> . </a> </p> </dd> </dl> <dl class="data"> <dt> <code class="leafygreen-ui-1l06pbn"> connPoolStats.replicaSets.[replicaSet].hosts[n].secondary </code> <a class="headerlink leafygreen-ui-1kepx47" href="#mongodb-data-connPoolStats.replicaSets.-replicaSet-.hosts-n-.secondary" title="Permalink to this definition"> <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="mongodb-data-connPoolStats.replicaSets.-replicaSet-.hosts-n-.secondary"> </div> </a> </dt> <dd> <p class="leafygreen-ui-1kp3ins"> Reports <code class="leafygreen-ui-1l06pbn"> true </code> if this <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-data-connPoolStats.replicaSets.-replicaSets-.hosts" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> host </code> </span> </a> is a <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-secondary"> secondary </a> member of the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-replica-set"> replica set <!-- --> . </a> </p> </dd> </dl> <dl class="data"> <dt> <code class="leafygreen-ui-1l06pbn"> connPoolStats.replicaSets.[replicaSet].hosts[n].pingTimeMillis </code> <a class="headerlink leafygreen-ui-1kepx47" href="#mongodb-data-connPoolStats.replicaSets.-replicaSet-.hosts-n-.pingTimeMillis" title="Permalink to this definition"> <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="mongodb-data-connPoolStats.replicaSets.-replicaSet-.hosts-n-.pingTimeMillis"> </div> </a> </dt> <dd> <p class="leafygreen-ui-1kp3ins"> Reports the ping time in milliseconds from the <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> to this <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-data-connPoolStats.replicaSets.-replicaSets-.hosts" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> host </code> . </span> </a> </p> </dd> </dl> <dl class="data"> <dt> <code class="leafygreen-ui-1l06pbn"> connPoolStats.replicaSets.[replicaSet].hosts[n].tags </code> <a class="headerlink leafygreen-ui-1kepx47" href="#mongodb-data-connPoolStats.replicaSets.-replicaSet-.hosts-n-.tags" title="Permalink to this definition"> <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="mongodb-data-connPoolStats.replicaSets.-replicaSet-.hosts-n-.tags"> </div> </a> </dt> <dd> <p class="leafygreen-ui-1kp3ins"> Reports the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/replica-configuration/#mongodb-rsconf-rsconf.members-n-.tags"> <code class="leafygreen-ui-1l06pbn"> members[n].tags </code> </a> , if this member of the set has tags configured. </p> </dd> </dl> </dd> </dl> </dd> </dl> <p class="leafygreen-ui-1kp3ins"> See also <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/db.runCommand/#std-label-command-response"> Response </a> for details on the <code class="leafygreen-ui-1l06pbn"> ok </code> status field, the <code class="leafygreen-ui-1l06pbn"> operationTime </code> field and the <code class="leafygreen-ui-1l06pbn"> $clusterTime </code> field. </p> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-data-connPoolStats.replicaSets.-replicaSets-.hosts" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> host </code> </span> </a> </p> </section> </section>
https://www.mongodb.com/docs/manual/reference/method/Bulk.find.hint/
<section> <h1 class="contains-headerlink leafygreen-ui-41fr9s" weight="medium"> Bulk.find.hint() <a class="headerlink leafygreen-ui-1kepx47" href="#bulk.find.hint--" 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="bulk.find.hint--"> </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="#description" target="_self"> <span> Description </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#example" target="_self"> <span> Example </span> </a> </li> </ul> </div> <div class="leafygreen-ui-13vw3ie" role="note"> <h2 class="leafygreen-ui-1fn4p2b"> Tip </h2> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> MongoDB also provides the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/db.collection.bulkWrite/#mongodb-method-db.collection.bulkWrite"> <code class="leafygreen-ui-1l06pbn"> db.collection.bulkWrite() </code> </a> method for performing bulk write operations. </p> </div> </div> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Description <a class="headerlink leafygreen-ui-1kepx47" href="#description" 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="description"> </div> </a> </h2> <dl class="method"> <dt> <code class="leafygreen-ui-1l06pbn"> Bulk.find.hint() </code> <a class="headerlink leafygreen-ui-1kepx47" href="#mongodb-method-Bulk.find.hint" title="Permalink to this definition"> <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="mongodb-method-Bulk.find.hint"> </div> </a> </dt> <dd> <p class="leafygreen-ui-1kp3ins"> Sets the <code class="leafygreen-ui-1l06pbn"> hint </code> option that specifies the <a class="leafygreen-ui-tqgtui" href="/docs/manual/indexes/#std-label-indexes"> index </a> to support the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/Bulk.find/#mongodb-method-Bulk.find"> <code class="leafygreen-ui-1l06pbn"> Bulk.find() </code> </a> for: </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/method/Bulk.find.replaceOne/#mongodb-method-Bulk.find.replaceOne"> <code class="leafygreen-ui-1l06pbn"> Bulk.find.replaceOne() </code> </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/Bulk.find.update/#mongodb-method-Bulk.find.update"> <code class="leafygreen-ui-1l06pbn"> Bulk.find.update() </code> </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/Bulk.find.updateOne/#mongodb-method-Bulk.find.updateOne"> <code class="leafygreen-ui-1l06pbn"> Bulk.find.updateOne() </code> . </a> </p> </li> </ul> <p class="leafygreen-ui-1kp3ins"> The option can take an index specification document or the index name string. </p> <p class="leafygreen-ui-1kp3ins"> If you specify an index that does not exist, the operation errors. </p> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-method-Bulk.find.hint" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> Bulk.find.hint() </code> </span> </a> has no effect on <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/Bulk.find.removeOne/#mongodb-method-Bulk.find.removeOne"> <code class="leafygreen-ui-1l06pbn"> Bulk.find.removeOne() </code> </a> </p> </dd> </dl> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Example <a class="headerlink leafygreen-ui-1kepx47" href="#example" 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="example"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> Create an example collection <code class="leafygreen-ui-1l06pbn"> orders </code> : </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.orders.insertMany( [\n { \"_id\" : 1, \"item\" : \"abc\", \"price\" : NumberDecimal(\"12\"), \"quantity\" : 2, \"type\": \"apparel\" },\n { \"_id\" : 2, \"item\" : \"jkl\", \"price\" : NumberDecimal(\"20\"), \"quantity\" : 1, \"type\": \"electronics\" },\n { \"_id\" : 3, \"item\" : \"abc\", \"price\" : NumberDecimal(\"10\"), \"quantity\" : 5, \"type\": \"apparel\" },\n { \"_id\" : 4, \"item\" : \"abc\", \"price\" : NumberDecimal(\"8\"), \"quantity\" : 10, \"type\": \"apparel\" },\n { \"_id\" : 5, \"item\" : \"jkl\", \"price\" : NumberDecimal(\"15\"), \"quantity\" : 15, \"type\": \"electronics\" }\n] )","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><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">orders</span>.<span class="lg-highlight-title lg-highlight-function">insertMany</span>( <!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">1</span>, <span class="lg-highlight-string">"item"</span> <!-- -->: <span class="lg-highlight-string">"abc"</span>, <span class="lg-highlight-string">"price"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">NumberDecimal</span>(<span class="lg-highlight-string">"12"</span>)<!-- -->, <span class="lg-highlight-string">"quantity"</span> <!-- -->: <span class="lg-highlight-number">2</span>, <span class="lg-highlight-string">"type"</span>: <span class="lg-highlight-string">"apparel"</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">2</span>, <span class="lg-highlight-string">"item"</span> <!-- -->: <span class="lg-highlight-string">"jkl"</span>, <span class="lg-highlight-string">"price"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">NumberDecimal</span>(<span class="lg-highlight-string">"20"</span>)<!-- -->, <span class="lg-highlight-string">"quantity"</span> <!-- -->: <span class="lg-highlight-number">1</span>, <span class="lg-highlight-string">"type"</span>: <span class="lg-highlight-string">"electronics"</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">3</span>, <span class="lg-highlight-string">"item"</span> <!-- -->: <span class="lg-highlight-string">"abc"</span>, <span class="lg-highlight-string">"price"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">NumberDecimal</span>(<span class="lg-highlight-string">"10"</span>)<!-- -->, <span class="lg-highlight-string">"quantity"</span> <!-- -->: <span class="lg-highlight-number">5</span>, <span class="lg-highlight-string">"type"</span>: <span class="lg-highlight-string">"apparel"</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">4</span>, <span class="lg-highlight-string">"item"</span> <!-- -->: <span class="lg-highlight-string">"abc"</span>, <span class="lg-highlight-string">"price"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">NumberDecimal</span>(<span class="lg-highlight-string">"8"</span>)<!-- -->, <span class="lg-highlight-string">"quantity"</span> <!-- -->: <span class="lg-highlight-number">10</span>, <span class="lg-highlight-string">"type"</span>: <span class="lg-highlight-string">"apparel"</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">5</span>, <span class="lg-highlight-string">"item"</span> <!-- -->: <span class="lg-highlight-string">"jkl"</span>, <span class="lg-highlight-string">"price"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">NumberDecimal</span>(<span class="lg-highlight-string">"15"</span>)<!-- -->, <span class="lg-highlight-string">"quantity"</span> <!-- -->: <span class="lg-highlight-number">15</span>, <span class="lg-highlight-string">"type"</span>: <span class="lg-highlight-string">"electronics"</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">] )</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"> Create the following indexes on the example collection: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.orders.createIndex( { item: 1 } );\ndb.orders.createIndex( { item: 1, quantity: 1 } );\ndb.orders.createIndex( { item: 1, price: 1 } );","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">orders</span>.<span class="lg-highlight-title lg-highlight-function">createIndex</span>( <!-- -->{ <span class="lg-highlight-attr">item</span>: <span class="lg-highlight-number">1</span> } )<!-- -->;</td></tr><tr class=""><td class="leafygreen-ui-7razhx">db.<span class="lg-highlight-property">orders</span>.<span class="lg-highlight-title lg-highlight-function">createIndex</span>( <!-- -->{ <span class="lg-highlight-attr">item</span>: <span class="lg-highlight-number">1</span>, <span class="lg-highlight-attr">quantity</span>: <span class="lg-highlight-number">1</span> } )<!-- -->;</td></tr><tr class=""><td class="leafygreen-ui-7razhx">db.<span class="lg-highlight-property">orders</span>.<span class="lg-highlight-title lg-highlight-function">createIndex</span>( <!-- -->{ <span class="lg-highlight-attr">item</span>: <span class="lg-highlight-number">1</span>, <span class="lg-highlight-attr">price</span>: <span class="lg-highlight-number">1</span> } )<!-- -->;</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 bulk operations specify different index to use for the various update/replace document operations: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"var bulk = db.orders.initializeUnorderedBulkOp();\nbulk.find({ item: \"abc\", price: { $gte: NumberDecimal(\"10\") }, quantity: { $lte: 10 } }).hint({item: 1, quantity: 1}).replaceOne( { item: \"abc123\", status: \"P\", points: 100 } );\nbulk.find({ item: \"abc\", price: { $gte: NumberDecimal(\"10\") }, quantity: { $lte: 10 } }).hint({item: 1, price: 1}).updateOne( { $inc: { points: 10 } } );\nbulk.execute();","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-keyword">var</span> bulk <!-- -->= <!-- -->db.<span class="lg-highlight-property">orders</span>.<span class="lg-highlight-title lg-highlight-function">initializeUnorderedBulkOp</span>(<!-- -->)<!-- -->;</td></tr><tr class=""><td class="leafygreen-ui-7razhx">bulk.<span class="lg-highlight-title lg-highlight-function">find</span>(<!-- -->{ <span class="lg-highlight-attr">item</span>: <span class="lg-highlight-string">"abc"</span>, <span class="lg-highlight-attr">price</span>: <!-- -->{ <span class="lg-highlight-attr">$gte</span>: <span class="lg-highlight-title lg-highlight-class">NumberDecimal</span>(<span class="lg-highlight-string">"10"</span>) }<!-- -->, <span class="lg-highlight-attr">quantity</span>: <!-- -->{ <span class="lg-highlight-attr">$lte</span>: <span class="lg-highlight-number">10</span> } }).<span class="lg-highlight-title lg-highlight-function">hint</span>(<!-- -->{<span class="lg-highlight-attr">item</span>: <span class="lg-highlight-number">1</span>, <span class="lg-highlight-attr">quantity</span>: <span class="lg-highlight-number">1</span>}).<span class="lg-highlight-title lg-highlight-function">replaceOne</span>( <!-- -->{ <span class="lg-highlight-attr">item</span>: <span class="lg-highlight-string">"abc123"</span>, <span class="lg-highlight-attr">status</span>: <span class="lg-highlight-string">"P"</span>, <span class="lg-highlight-attr">points</span>: <span class="lg-highlight-number">100</span> } )<!-- -->;</td></tr><tr class=""><td class="leafygreen-ui-7razhx">bulk.<span class="lg-highlight-title lg-highlight-function">find</span>(<!-- -->{ <span class="lg-highlight-attr">item</span>: <span class="lg-highlight-string">"abc"</span>, <span class="lg-highlight-attr">price</span>: <!-- -->{ <span class="lg-highlight-attr">$gte</span>: <span class="lg-highlight-title lg-highlight-class">NumberDecimal</span>(<span class="lg-highlight-string">"10"</span>) }<!-- -->, <span class="lg-highlight-attr">quantity</span>: <!-- -->{ <span class="lg-highlight-attr">$lte</span>: <span class="lg-highlight-number">10</span> } }).<span class="lg-highlight-title lg-highlight-function">hint</span>(<!-- -->{<span class="lg-highlight-attr">item</span>: <span class="lg-highlight-number">1</span>, <span class="lg-highlight-attr">price</span>: <span class="lg-highlight-number">1</span>}).<span class="lg-highlight-title lg-highlight-function">updateOne</span>( <!-- -->{ <span class="lg-highlight-attr">$inc</span>: <!-- -->{ <span class="lg-highlight-attr">points</span>: <span class="lg-highlight-number">10</span> } } )<!-- -->;</td></tr><tr class=""><td class="leafygreen-ui-7razhx">bulk.<span class="lg-highlight-title lg-highlight-function">execute</span>(<!-- -->)<!-- -->;</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"> To view the indexes used, you can use the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/indexStats/#mongodb-pipeline-pipe.-indexStats"> <code class="leafygreen-ui-1l06pbn"> $indexStats </code> </a> pipeline: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.orders.aggregate( [ { $indexStats: { } }, { $sort: { name: 1 } } ] )","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-1q4bxgx" tabindex="0"><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">orders</span>.<span class="lg-highlight-title lg-highlight-function">aggregate</span>( <!-- -->[ <!-- -->{ <span class="lg-highlight-attr">$indexStats</span>: <!-- -->{ <!-- -->} }<!-- -->, <!-- -->{ <span class="lg-highlight-attr">$sort</span>: <!-- -->{ <span class="lg-highlight-attr">name</span>: <span class="lg-highlight-number">1</span> } } ] )</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-13vw3ie" role="note"> <h2 class="leafygreen-ui-1fn4p2b"> Tip </h2> <h3 class="leafygreen-ui-144d5kf"> <strong> See also: </strong> </h3> <div class="leafygreen-ui-9mycqc"> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/db.collection.initializeUnorderedBulkOp/#mongodb-method-db.collection.initializeUnorderedBulkOp"> <code class="leafygreen-ui-1l06pbn"> db.collection.initializeUnorderedBulkOp() </code> </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/db.collection.initializeOrderedBulkOp/#mongodb-method-db.collection.initializeOrderedBulkOp"> <code class="leafygreen-ui-1l06pbn"> db.collection.initializeOrderedBulkOp() </code> </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/Bulk.find/#mongodb-method-Bulk.find"> <code class="leafygreen-ui-1l06pbn"> Bulk.find() </code> </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/Bulk.execute/#mongodb-method-Bulk.execute"> <code class="leafygreen-ui-1l06pbn"> Bulk.execute() </code> </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/Bulk/#std-label-bulk-methods"> All Bulk Methods </a> </p> </li> </ul> </div> </div> </section> </section>
https://www.mongodb.com/docs/manual/reference/operator/aggregation/slice/
<section> <h1 class="contains-headerlink leafygreen-ui-41fr9s" weight="medium"> $slice (aggregation) <a class="headerlink leafygreen-ui-1kepx47" href="#-slice--aggregation-" 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="-slice--aggregation-"> </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="#definition" target="_self"> <span> Definition </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#behavior" target="_self"> <span> Behavior </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#example" target="_self"> <span> Example </span> </a> </li> </ul> </div> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Definition <a class="headerlink leafygreen-ui-1kepx47" href="#definition" 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="definition"> </div> </a> </h2> <dl class="expression"> <dt> <code class="leafygreen-ui-1l06pbn"> $slice </code> <a class="headerlink leafygreen-ui-1kepx47" href="#mongodb-expression-exp.-slice" title="Permalink to this definition"> <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="mongodb-expression-exp.-slice"> </div> </a> </dt> <dd> <p class="leafygreen-ui-1kp3ins"> Returns a subset of an array. </p> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-expression-exp.-slice" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $slice </code> </span> </a> has one of two syntax forms: </p> <p class="leafygreen-ui-1kp3ins"> The following syntax returns elements from either the start or end of the array: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ $slice: [ &lt;array&gt;, &lt;n&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">{ <span class="lg-highlight-attr">$slice</span>: <!-- -->[ &lt;<!-- -->array<!-- -->&gt;<!-- -->,<!-- --> <!-- -->&lt;<!-- -->n<!-- -->&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 syntax returns elements from the specified position in the array: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ $slice: [ &lt;array&gt;, &lt;position&gt;, &lt;n&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">{ <span class="lg-highlight-attr">$slice</span>: <!-- -->[ &lt;<!-- -->array<!-- -->&gt;<!-- -->,<!-- --> <!-- -->&lt;<!-- -->position<!-- -->&gt;<!-- -->,<!-- --> <!-- -->&lt;<!-- -->n<!-- -->&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:15%"/> <col style="width:85%"/> </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> Operand </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> <code class="leafygreen-ui-1l06pbn"> &lt;array&gt; </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Any valid <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/#std-label-aggregation-expressions"> expression </a> as long as it resolves to an array. </div> </div> </td> </tr> <tr class=""> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> &lt;position&gt; </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <p class="leafygreen-ui-1kp3ins"> Optional. Any valid <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/#std-label-aggregation-expressions"> expression </a> as long as it resolves to an integer. </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> If positive, <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-expression-exp.-slice" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $slice </code> </span> </a> determines the starting position from the start of the array. If <code class="leafygreen-ui-1l06pbn"> &lt;position&gt; </code> is greater than the number of elements, the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-expression-exp.-slice" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $slice </code> </span> </a> returns an empty array. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> If negative, <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-expression-exp.-slice" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $slice </code> </span> </a> determines the starting position from the end of the array. If the absolute value of the <code class="leafygreen-ui-1l06pbn"> &lt;position&gt; </code> is greater than the number of elements, the starting position is the start of the array. </p> </li> </ul> </div> </div> </td> </tr> <tr class=""> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> &lt;n&gt; </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <p class="leafygreen-ui-1kp3ins"> Any valid <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/#std-label-aggregation-expressions"> expression </a> as long as it resolves to an integer. If <code class="leafygreen-ui-1l06pbn"> &lt;position&gt; </code> is specified, <code class="leafygreen-ui-1l06pbn"> &lt;n&gt; </code> must resolve to a positive integer. </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> If positive, <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-expression-exp.-slice" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $slice </code> </span> </a> returns up to the first <code class="leafygreen-ui-1l06pbn"> n </code> elements in the array. If the <code class="leafygreen-ui-1l06pbn"> &lt;position&gt; </code> is specified, <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-expression-exp.-slice" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $slice </code> </span> </a> returns the first <code class="leafygreen-ui-1l06pbn"> n </code> elements starting from the position. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> If negative, <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-expression-exp.-slice" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $slice </code> </span> </a> returns up to the last <code class="leafygreen-ui-1l06pbn"> n </code> elements in the array. <code class="leafygreen-ui-1l06pbn"> n </code> cannot resolve to a negative number <em> if </em> <code class="leafygreen-ui-1l06pbn"> &lt;position&gt; </code> is specified. </p> </li> </ul> </div> </div> </td> </tr> </tbody> </table> </div> <p class="leafygreen-ui-1kp3ins"> For more information on expressions, see <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/#std-label-aggregation-expressions"> Expression Operators <!-- --> . </a> </p> </dd> </dl> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Behavior <a class="headerlink leafygreen-ui-1kepx47" href="#behavior" 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="behavior"> </div> </a> </h2> <div class="leafygreen-ui-skkc39" tabindex="0"> <table class="leafygreen-ui-hr8lsv"> <colgroup> <col style="width:80%"/> <col style="width:20%"/> </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> Example </div> </div> </th> <th class="leafygreen-ui-13uteka" role="columnheader" scope="col"> <div class="leafygreen-ui-ui0te9"> <div> Results </div> </div> </th> </tr> </thead> <tbody> <tr class=""> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ $slice: [ [ 1, 2, 3 ], 1, 1 ] }","programmingLanguage":"JavaScript"} </script> <div class="css-1lju8ps"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1jheeh3"> <pre class="leafygreen-ui-1agdxuk" 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">{ <span class="lg-highlight-attr">$slice</span>: <!-- -->[ <!-- -->[ <span class="lg-highlight-number">1</span>, <span class="lg-highlight-number">2</span>, <span class="lg-highlight-number">3</span> ]<!-- -->, <span class="lg-highlight-number">1</span>, <span class="lg-highlight-number">1</span> ] }</td></tr></tbody></table></code></pre> </div> </div> </div> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"[ 2 ]","programmingLanguage":"JavaScript"} </script> <div class="css-1lju8ps"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1jheeh3"> <pre class="leafygreen-ui-1agdxuk" 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">[ <span class="lg-highlight-number">2</span> ]</td></tr></tbody></table></code></pre> </div> </div> </div> </div> </div> </td> </tr> <tr class=""> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ $slice: [ [ 1, 2, 3 ], -2 ] }","programmingLanguage":"JavaScript"} </script> <div class="css-1lju8ps"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1jheeh3"> <pre class="leafygreen-ui-1agdxuk" 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">{ <span class="lg-highlight-attr">$slice</span>: <!-- -->[ <!-- -->[ <span class="lg-highlight-number">1</span>, <span class="lg-highlight-number">2</span>, <span class="lg-highlight-number">3</span> ]<!-- -->, <!-- -->-<span class="lg-highlight-number">2</span> ] }</td></tr></tbody></table></code></pre> </div> </div> </div> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"[ 2, 3 ]","programmingLanguage":"JavaScript"} </script> <div class="css-1lju8ps"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1jheeh3"> <pre class="leafygreen-ui-1agdxuk" 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">[ <span class="lg-highlight-number">2</span>, <span class="lg-highlight-number">3</span> ]</td></tr></tbody></table></code></pre> </div> </div> </div> </div> </div> </td> </tr> <tr class=""> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ $slice: [ [ 1, 2, 3 ], 15, 2 ] }","programmingLanguage":"JavaScript"} </script> <div class="css-1lju8ps"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1jheeh3"> <pre class="leafygreen-ui-1agdxuk" 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">{ <span class="lg-highlight-attr">$slice</span>: <!-- -->[ <!-- -->[ <span class="lg-highlight-number">1</span>, <span class="lg-highlight-number">2</span>, <span class="lg-highlight-number">3</span> ]<!-- -->, <span class="lg-highlight-number">15</span>, <span class="lg-highlight-number">2</span> ] }</td></tr></tbody></table></code></pre> </div> </div> </div> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"[ ]","programmingLanguage":"JavaScript"} </script> <div class="css-1lju8ps"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1jheeh3"> <pre class="leafygreen-ui-1agdxuk" 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">[ <!-- -->]</td></tr></tbody></table></code></pre> </div> </div> </div> </div> </div> </td> </tr> <tr class=""> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ $slice: [ [ 1, 2, 3 ], -15, 2 ] }","programmingLanguage":"JavaScript"} </script> <div class="css-1lju8ps"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1jheeh3"> <pre class="leafygreen-ui-1agdxuk" 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">{ <span class="lg-highlight-attr">$slice</span>: <!-- -->[ <!-- -->[ <span class="lg-highlight-number">1</span>, <span class="lg-highlight-number">2</span>, <span class="lg-highlight-number">3</span> ]<!-- -->, <!-- -->-<span class="lg-highlight-number">15</span>, <span class="lg-highlight-number">2</span> ] }</td></tr></tbody></table></code></pre> </div> </div> </div> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"[ 1, 2 ]","programmingLanguage":"JavaScript"} </script> <div class="css-1lju8ps"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1jheeh3"> <pre class="leafygreen-ui-1agdxuk" 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">[ <span class="lg-highlight-number">1</span>, <span class="lg-highlight-number">2</span> ]</td></tr></tbody></table></code></pre> </div> </div> </div> </div> </div> </td> </tr> </tbody> </table> </div> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Example <a class="headerlink leafygreen-ui-1kepx47" href="#example" 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="example"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> A collection named <code class="leafygreen-ui-1l06pbn"> users </code> contains the following documents: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ \"_id\" : 1, \"name\" : \"dave123\", favorites: [ \"chocolate\", \"cake\", \"butter\", \"apples\" ] }\n{ \"_id\" : 2, \"name\" : \"li\", favorites: [ \"apples\", \"pudding\", \"pie\" ] }\n{ \"_id\" : 3, \"name\" : \"ahn\", favorites: [ \"pears\", \"pecans\", \"chocolate\", \"cherries\" ] }\n{ \"_id\" : 4, \"name\" : \"ty\", favorites: [ \"ice cream\" ] }","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">1</span>, <span class="lg-highlight-string">"name"</span> <!-- -->: <span class="lg-highlight-string">"dave123"</span>, <span class="lg-highlight-attr">favorites</span>: <!-- -->[ <span class="lg-highlight-string">"chocolate"</span>, <span class="lg-highlight-string">"cake"</span>, <span class="lg-highlight-string">"butter"</span>, <span class="lg-highlight-string">"apples"</span> ] }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">2</span>, <span class="lg-highlight-string">"name"</span> <!-- -->: <span class="lg-highlight-string">"li"</span>, <span class="lg-highlight-attr">favorites</span>: <!-- -->[ <span class="lg-highlight-string">"apples"</span>, <span class="lg-highlight-string">"pudding"</span>, <span class="lg-highlight-string">"pie"</span> ] }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">3</span>, <span class="lg-highlight-string">"name"</span> <!-- -->: <span class="lg-highlight-string">"ahn"</span>, <span class="lg-highlight-attr">favorites</span>: <!-- -->[ <span class="lg-highlight-string">"pears"</span>, <span class="lg-highlight-string">"pecans"</span>, <span class="lg-highlight-string">"chocolate"</span>, <span class="lg-highlight-string">"cherries"</span> ] }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">4</span>, <span class="lg-highlight-string">"name"</span> <!-- -->: <span class="lg-highlight-string">"ty"</span>, <span class="lg-highlight-attr">favorites</span>: <!-- -->[ <span class="lg-highlight-string">"ice cream"</span> ] }</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 example returns at most the first three elements in the <code class="leafygreen-ui-1l06pbn"> favorites </code> array for each user: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.users.aggregate([\n { $project: { name: 1, threeFavorites: { $slice: [ \"$favorites\", 3 ] } } }\n])","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><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">users</span>.<span class="lg-highlight-title lg-highlight-function">aggregate</span>(<!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">$project</span>: <!-- -->{ <span class="lg-highlight-attr">name</span>: <span class="lg-highlight-number">1</span>, <span class="lg-highlight-attr">threeFavorites</span>: <!-- -->{ <span class="lg-highlight-attr">$slice</span>: <!-- -->[ <span class="lg-highlight-string">"$favorites"</span>, <span class="lg-highlight-number">3</span> ] } } }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">])</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 operation returns the following results: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ \"_id\" : 1, \"name\" : \"dave123\", \"threeFavorites\" : [ \"chocolate\", \"cake\", \"butter\" ] }\n{ \"_id\" : 2, \"name\" : \"li\", \"threeFavorites\" : [ \"apples\", \"pudding\", \"pie\" ] }\n{ \"_id\" : 3, \"name\" : \"ahn\", \"threeFavorites\" : [ \"pears\", \"pecans\", \"chocolate\" ] }\n{ \"_id\" : 4, \"name\" : \"ty\", \"threeFavorites\" : [ \"ice cream\" ] }","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">1</span>, <span class="lg-highlight-string">"name"</span> <!-- -->: <span class="lg-highlight-string">"dave123"</span>, <span class="lg-highlight-string">"threeFavorites"</span> <!-- -->: <!-- -->[ <span class="lg-highlight-string">"chocolate"</span>, <span class="lg-highlight-string">"cake"</span>, <span class="lg-highlight-string">"butter"</span> ] }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">2</span>, <span class="lg-highlight-string">"name"</span> <!-- -->: <span class="lg-highlight-string">"li"</span>, <span class="lg-highlight-string">"threeFavorites"</span> <!-- -->: <!-- -->[ <span class="lg-highlight-string">"apples"</span>, <span class="lg-highlight-string">"pudding"</span>, <span class="lg-highlight-string">"pie"</span> ] }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">3</span>, <span class="lg-highlight-string">"name"</span> <!-- -->: <span class="lg-highlight-string">"ahn"</span>, <span class="lg-highlight-string">"threeFavorites"</span> <!-- -->: <!-- -->[ <span class="lg-highlight-string">"pears"</span>, <span class="lg-highlight-string">"pecans"</span>, <span class="lg-highlight-string">"chocolate"</span> ] }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">4</span>, <span class="lg-highlight-string">"name"</span> <!-- -->: <span class="lg-highlight-string">"ty"</span>, <span class="lg-highlight-string">"threeFavorites"</span> <!-- -->: <!-- -->[ <span class="lg-highlight-string">"ice cream"</span> ] }</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> </section> </section>
https://www.mongodb.com/docs/manual/reference/operator/aggregation/toString/
<section> <h1 class="contains-headerlink leafygreen-ui-41fr9s" weight="medium"> $toString (aggregation) <a class="headerlink leafygreen-ui-1kepx47" href="#-tostring--aggregation-" 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="-tostring--aggregation-"> </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="#definition" target="_self"> <span> Definition </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#behavior" target="_self"> <span> Behavior </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#example" target="_self"> <span> Example </span> </a> </li> </ul> </div> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Definition <a class="headerlink leafygreen-ui-1kepx47" href="#definition" 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="definition"> </div> </a> </h2> <dl class="expression"> <dt> <code class="leafygreen-ui-1l06pbn"> $toString </code> <a class="headerlink leafygreen-ui-1kepx47" href="#mongodb-expression-exp.-toString" title="Permalink to this definition"> <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="mongodb-expression-exp.-toString"> </div> </a> </dt> <dd> <p class="leafygreen-ui-1kp3ins"> Converts a value to a string. If the value cannot be converted to a string, <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-expression-exp.-toString" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $toString </code> </span> </a> errors. If the value is null or missing, <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-expression-exp.-toString" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $toString </code> </span> </a> returns null. </p> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-expression-exp.-toString" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $toString </code> </span> </a> has the following syntax: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{\n $toString: &lt;expression&gt;\n}","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">$toString</span>: &lt;<!-- -->expression<!-- -->&gt;</td></tr><tr class=""><td class="leafygreen-ui-7razhx">}</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 <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-expression-exp.-toString" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $toString </code> </span> </a> takes any valid <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/#std-label-aggregation-expressions"> expression <!-- --> . </a> </p> <p class="leafygreen-ui-1kp3ins"> The <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-expression-exp.-toString" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $toString </code> </span> </a> is a shorthand for the following <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/convert/#mongodb-expression-exp.-convert"> <code class="leafygreen-ui-1l06pbn"> $convert </code> </a> expression: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ $convert: { input: &lt;expression&gt;, to: \"string\" } }","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">{ <span class="lg-highlight-attr">$convert</span>: <!-- -->{ <span class="lg-highlight-attr">input</span>: &lt;<!-- -->expression<!-- -->&gt;<!-- -->,<!-- --> <span class="lg-highlight-attr">to</span>: <span class="lg-highlight-string">"string"</span> } }</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-13vw3ie" role="note"> <h2 class="leafygreen-ui-1fn4p2b"> Tip </h2> <h3 class="leafygreen-ui-144d5kf"> <strong> See also: </strong> </h3> <div class="leafygreen-ui-9mycqc"> <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/convert/#mongodb-expression-exp.-convert"> <code class="leafygreen-ui-1l06pbn"> $convert </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/dateToString/#mongodb-expression-exp.-dateToString"> <code class="leafygreen-ui-1l06pbn"> $dateToString </code> </a> </p> </li> </ul> </div> </div> </dd> </dl> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Behavior <a class="headerlink leafygreen-ui-1kepx47" href="#behavior" 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="behavior"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> The following table lists the input types that can be converted to a string: </p> <div class="leafygreen-ui-skkc39" tabindex="0"> <table class="leafygreen-ui-hr8lsv"> <colgroup> <col style="width:55%"/> <col style="width:50%"/> </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> Input Type </div> </div> </th> <th class="leafygreen-ui-13uteka" role="columnheader" scope="col"> <div class="leafygreen-ui-ui0te9"> <div> Behavior </div> </div> </th> </tr> </thead> <tbody> <tr class="leafygreen-ui-15dvrnp"> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> BinData </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Returns the binary data value as a string. </div> </div> </td> </tr> <tr class="leafygreen-ui-15dvrnp"> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Boolean </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Returns the boolean value as a string. </div> </div> </td> </tr> <tr class="leafygreen-ui-15dvrnp"> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Double </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Returns the double value as a string. </div> </div> </td> </tr> <tr class="leafygreen-ui-15dvrnp"> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Decimal </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Returns the decimal value as a string. </div> </div> </td> </tr> <tr class="leafygreen-ui-15dvrnp"> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Integer </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Returns the integer value as a string. </div> </div> </td> </tr> <tr class="leafygreen-ui-15dvrnp"> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Long </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Returns the long value as a string. </div> </div> </td> </tr> <tr class="leafygreen-ui-15dvrnp"> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> ObjectId </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Returns the ObjectId value as a hexadecimal string.. </div> </div> </td> </tr> <tr class="leafygreen-ui-15dvrnp"> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> String </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> No-op. Returns the string value. </div> </div> </td> </tr> <tr class="leafygreen-ui-15dvrnp"> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Date </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Returns the date as a string. </div> </div> </td> </tr> </tbody> </table> </div> <p class="leafygreen-ui-1kp3ins"> The following table lists some conversion to string examples: </p> <div class="leafygreen-ui-skkc39" tabindex="0"> <table class="leafygreen-ui-hr8lsv"> <colgroup> <col style="width:80%"/> <col style="width:20%"/> </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> Example </div> </div> </th> <th class="leafygreen-ui-13uteka" role="columnheader" scope="col"> <div class="leafygreen-ui-ui0te9"> <div> Results </div> </div> </th> </tr> </thead> <tbody> <tr class="leafygreen-ui-15dvrnp"> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> {$toString: true} </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> "true" </div> </div> </td> </tr> <tr class="leafygreen-ui-15dvrnp"> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> {$toString: false} </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> "false" </div> </div> </td> </tr> <tr class="leafygreen-ui-15dvrnp"> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> {$toString: 2.5} </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> "2.5" </div> </div> </td> </tr> <tr class="leafygreen-ui-15dvrnp"> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> {$toString: NumberInt(2)} </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> "2" </div> </div> </td> </tr> <tr class="leafygreen-ui-15dvrnp"> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> {$toString: NumberLong(1000)} </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> "1000" </div> </div> </td> </tr> <tr class="leafygreen-ui-15dvrnp"> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> {$toString: ObjectId("5ab9c3da31c2ab715d421285")} </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> "5ab9c3da31c2ab715d421285" </div> </div> </td> </tr> <tr class="leafygreen-ui-15dvrnp"> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> {$toString: ISODate("2018-03-27T16:58:51.538Z")} </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> "2018-03-27T16:58:51.538Z" </div> </div> </td> </tr> <tr class="leafygreen-ui-15dvrnp"> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> { $toString: BinData(4, "hn3f") } </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> "hn3f" </div> </div> </td> </tr> </tbody> </table> </div> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Example <a class="headerlink leafygreen-ui-1kepx47" href="#example" 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="example"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> Create a collection <code class="leafygreen-ui-1l06pbn"> orders </code> with the following documents: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.orders.insertMany( [\n { _id: 1, item: \"apple\", qty: 5, zipcode: 93445 },\n { _id: 2, item: \"almonds\", qty: 2, zipcode: \"12345-0030\" },\n { _id: 3, item: \"peaches\", qty: 5, zipcode: 12345 },\n] )","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><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">orders</span>.<span class="lg-highlight-title lg-highlight-function">insertMany</span>( <!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">1</span>, <span class="lg-highlight-attr">item</span>: <span class="lg-highlight-string">"apple"</span>, <span class="lg-highlight-attr">qty</span>: <span class="lg-highlight-number">5</span>, <span class="lg-highlight-attr">zipcode</span>: <span class="lg-highlight-number">93445</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">2</span>, <span class="lg-highlight-attr">item</span>: <span class="lg-highlight-string">"almonds"</span>, <span class="lg-highlight-attr">qty</span>: <span class="lg-highlight-number">2</span>, <span class="lg-highlight-attr">zipcode</span>: <span class="lg-highlight-string">"12345-0030"</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">3</span>, <span class="lg-highlight-attr">item</span>: <span class="lg-highlight-string">"peaches"</span>, <span class="lg-highlight-attr">qty</span>: <span class="lg-highlight-number">5</span>, <span class="lg-highlight-attr">zipcode</span>: <span class="lg-highlight-number">12345</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">] )</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 aggregation operation on the <code class="leafygreen-ui-1l06pbn"> orders </code> collection converts the <code class="leafygreen-ui-1l06pbn"> zipcode </code> to string before sorting by the string value: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"// Define stage to add convertedZipCode field with the converted zipcode value\n\nzipConversionStage = {\n $addFields: {\n convertedZipCode: { $toString: \"$zipcode\" }\n }\n};\n\n// Define stage to sort documents by the converted zipcode\n\nsortStage = {\n $sort: { \"convertedZipCode\": 1 }\n};\n\ndb.orders.aggregate( [\n zipConversionStage,\n sortStage\n] )","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-comment">//</span><span class="lg-highlight-comment"> Define stage to </span><span class="lg-highlight-comment">add convertedZipCode</span><span class="lg-highlight-comment"> field with the </span><span class="lg-highlight-comment">converted zipcode value</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"><div class="leafygreen-ui-ihxujy"></div></td></tr><tr class=""><td class="leafygreen-ui-7razhx">zipConversionStage <!-- -->= <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">$addFields</span>: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">convertedZipCode</span>: <!-- -->{ <span class="lg-highlight-attr">$toString</span>: <span class="lg-highlight-string">"$zipcode"</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">}<!-- -->;</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><div class="leafygreen-ui-ihxujy"></div></td></tr><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-comment">//</span><span class="lg-highlight-comment"> Define stage to </span><span class="lg-highlight-comment">sort documents by the converted zipcode</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"><div class="leafygreen-ui-ihxujy"></div></td></tr><tr class=""><td class="leafygreen-ui-7razhx">sortStage <!-- -->= <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">$sort</span>: <!-- -->{ <span class="lg-highlight-string">"convertedZipCode"</span>: <span class="lg-highlight-number">1</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">}<!-- -->;</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><div class="leafygreen-ui-ihxujy"></div></td></tr><tr class=""><td class="leafygreen-ui-7razhx">db.<span class="lg-highlight-property">orders</span>.<span class="lg-highlight-title lg-highlight-function">aggregate</span>( <!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->zipConversionStage<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->sortStage</td></tr><tr class=""><td class="leafygreen-ui-7razhx">] )</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 operation returns the following documents: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{\n _id: 3,\n item: 'peaches',\n qty: 5,\n zipcode: 12345,\n convertedZipCode: '12345'\n},\n{\n _id: 2,\n item: 'almonds',\n qty: 2,\n zipcode: '12345-0030',\n convertedZipCode: '12345-0030'\n},\n{\n _id: 1,\n item: 'apple',\n qty: 5,\n zipcode: 93445,\n convertedZipCode: '93445'\n}","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">3</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">item</span>: <span class="lg-highlight-string">'peaches'</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">qty</span>: <span class="lg-highlight-number">5</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">zipcode</span>: <span class="lg-highlight-number">12345</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">convertedZipCode</span>: <span class="lg-highlight-string">'12345'</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx">}<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">2</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">item</span>: <span class="lg-highlight-string">'almonds'</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">qty</span>: <span class="lg-highlight-number">2</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">zipcode</span>: <span class="lg-highlight-string">'12345-0030'</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">convertedZipCode</span>: <span class="lg-highlight-string">'12345-0030'</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx">}<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">1</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">item</span>: <span class="lg-highlight-string">'apple'</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">qty</span>: <span class="lg-highlight-number">5</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">zipcode</span>: <span class="lg-highlight-number">93445</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">convertedZipCode</span>: <span class="lg-highlight-string">'93445'</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx">}</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-15mdk4" role="note"> <h2 class="leafygreen-ui-6n7b7d"> Note </h2> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> If the conversion operation encounters an error, the aggregation operation stops and throws an error. To override this behavior, use <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/convert/#mongodb-expression-exp.-convert"> <code class="leafygreen-ui-1l06pbn"> $convert </code> </a> instead. </p> </div> </div> </section> </section>
https://www.mongodb.com/docs/manual/reference/program/mongokerberos/
<section> <h1 class="contains-headerlink leafygreen-ui-41fr9s" weight="medium"> <code class="leafygreen-ui-1l06pbn"> mongokerberos </code> <a class="headerlink leafygreen-ui-1kepx47" href="#mongokerberos" 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="mongokerberos"> </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="#synopsis" target="_self"> <span> Synopsis </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#installation" target="_self"> <span> Installation </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#usage" target="_self"> <span> Usage </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#options" target="_self"> <span> Options </span> </a> </li> </ul> </div> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Synopsis <a class="headerlink leafygreen-ui-1kepx47" href="#synopsis" 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="synopsis"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> MongoDB Enterprise provides <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-binary-bin.mongokerberos" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongokerberos </code> </span> </a> for testing MongoDB's Kerberos and GSSAPI <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/configuration-options/#std-label-security.sasl.options"> configuration options </a> against a running Kerberos deployment. <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-binary-bin.mongokerberos" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongokerberos </code> </span> </a> can be used in one of two modes: <em> server </em> and <em> client </em> . </p> <div class="leafygreen-ui-skkc39" tabindex="0"> <table class="leafygreen-ui-hr8lsv"> <colgroup> <col style="width:30%"/> <col style="width:70%"/> </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> Mode </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> Server </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> In <em> server mode </em> , <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-binary-bin.mongokerberos" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongokerberos </code> </span> </a> analyzes Kerberos-related configurations on the server, and returns a report which includes error messages for any configurations that are problematic. For usage, see <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-mongokeberos-usage-server" target="_self"> <span> Server Mode </span> </a> </div> </div> </td> </tr> <tr class=""> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Client </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> In <em> client mode </em> , <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-binary-bin.mongokerberos" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongokerberos </code> </span> </a> tests Kerberos authentication for a provided username, and returns a report which includes the success or failure of each step in the Kerberos authentication procedure. For usage, see <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-mongokeberos-usage-client" target="_self"> <span> Client Mode </span> </a> </div> </div> </td> </tr> </tbody> </table> </div> <p class="leafygreen-ui-1kp3ins"> Error messages for both modes include information on specific errors encountered and potential advice for resolving the error. </p> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-binary-bin.mongokerberos" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongokerberos </code> </span> </a> supports the following deployment types, in both server and client modes: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Linux MongoDB clients authenticating to MIT Kerberos deployments on <a class="leafygreen-ui-tqgtui" href="/docs/manual/administration/production-notes/#std-label-prod-notes-supported-platforms"> supported Linux platforms <!-- --> . </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Windows MongoDB clients authenticating to Windows Active Directory deployments on <a class="leafygreen-ui-tqgtui" href="/docs/manual/administration/production-notes/#std-label-prod-notes-supported-platforms"> supported Windows platforms <!-- --> . </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Linux MongoDB clients authenticating to Windows Active Directory deployments. </p> </li> </ul> <div class="leafygreen-ui-15mdk4" role="note"> <h2 class="leafygreen-ui-6n7b7d"> Note </h2> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> MongoDB Enterprise and <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-binary-bin.mongokerberos" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongokerberos </code> </span> </a> only support the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://kerberos.org/" rel="noopener noreferrer"> <span> MIT implementation </span> <svg alt="" aria-hidden="true" class="leafygreen-ui-1ie5kuq" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M13.823 2.4491C13.8201 2.30008 13.6999 2.17994 13.5509 2.17704L9.5062 2.09836C9.25654 2.09351 9.12821 2.39519 9.30482 2.5718L10.3856 3.65257L7.93433 6.10383C7.87964 6.15852 7.83047 6.21665 7.78683 6.27752L5.99909 8.06525C5.46457 8.59977 5.46457 9.4664 5.99909 10.0009C6.53361 10.5354 7.40023 10.5354 7.93475 10.0009L9.72249 8.21317C9.78336 8.16953 9.84148 8.12037 9.89618 8.06567L12.3474 5.61441L13.4282 6.69518C13.6048 6.87179 13.9065 6.74347 13.9016 6.4938L13.823 2.4491Z" fill="currentColor"> </path> <path d="M7.25 3.12893C7.66421 3.12893 8 3.46472 8 3.87893C8 4.29315 7.66421 4.62893 7.25 4.62893H4C3.72386 4.62893 3.5 4.85279 3.5 5.12893V11.9929C3.5 12.2691 3.72386 12.4929 4 12.4929H10.864C11.1401 12.4929 11.364 12.2691 11.364 11.9929V8.75C11.364 8.33579 11.6998 8 12.114 8C12.5282 8 12.864 8.33579 12.864 8.75V11.9929C12.864 13.0975 11.9686 13.9929 10.864 13.9929H4C2.89543 13.9929 2 13.0975 2 11.9929V5.12893C2 4.02436 2.89543 3.12893 4 3.12893H7.25Z" fill="currentColor"> </path> </svg> </a> of Kerberos. </p> </div> </div> <p class="leafygreen-ui-1kp3ins"> Generally, when configuring options related to <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/kerberos/#std-label-security-kerberos"> Kerberos authentication </a> , it is good practice to verify your configuration with <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-binary-bin.mongokerberos" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongokerberos </code> . </span> </a> </p> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-binary-bin.mongokerberos" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongokerberos </code> </span> </a> is a testing and verification tool; it does not edit any files or configure any services. For configuring Kerberos on your platform please consult the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://web.mit.edu/kerberos/krb5-latest/doc/" rel="noopener noreferrer"> <span> MIT Kerberos documentation </span> <svg alt="" aria-hidden="true" class="leafygreen-ui-1ie5kuq" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M13.823 2.4491C13.8201 2.30008 13.6999 2.17994 13.5509 2.17704L9.5062 2.09836C9.25654 2.09351 9.12821 2.39519 9.30482 2.5718L10.3856 3.65257L7.93433 6.10383C7.87964 6.15852 7.83047 6.21665 7.78683 6.27752L5.99909 8.06525C5.46457 8.59977 5.46457 9.4664 5.99909 10.0009C6.53361 10.5354 7.40023 10.5354 7.93475 10.0009L9.72249 8.21317C9.78336 8.16953 9.84148 8.12037 9.89618 8.06567L12.3474 5.61441L13.4282 6.69518C13.6048 6.87179 13.9065 6.74347 13.9016 6.4938L13.823 2.4491Z" fill="currentColor"> </path> <path d="M7.25 3.12893C7.66421 3.12893 8 3.46472 8 3.87893C8 4.29315 7.66421 4.62893 7.25 4.62893H4C3.72386 4.62893 3.5 4.85279 3.5 5.12893V11.9929C3.5 12.2691 3.72386 12.4929 4 12.4929H10.864C11.1401 12.4929 11.364 12.2691 11.364 11.9929V8.75C11.364 8.33579 11.6998 8 12.114 8C12.5282 8 12.864 8.33579 12.864 8.75V11.9929C12.864 13.0975 11.9686 13.9929 10.864 13.9929H4C2.89543 13.9929 2 13.0975 2 11.9929V5.12893C2 4.02436 2.89543 3.12893 4 3.12893H7.25Z" fill="currentColor"> </path> </svg> </a> , or your platform's documentation. For configuring MongoDB to authenticate using Kerberos, please reference the following tutorials: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/tutorial/control-access-to-mongodb-with-kerberos-authentication/"> Configure Self-Managed MongoDB with Kerberos Authentication on Linux </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/tutorial/control-access-to-mongodb-windows-with-kerberos-authentication/"> Configure Self-Managed MongoDB with Kerberos Authentication on Windows <!-- --> . </a> </p> </li> </ul> <p class="leafygreen-ui-1kp3ins"> This document provides a complete overview of all command line options for <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-binary-bin.mongokerberos" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongokerberos </code> . </span> </a> </p> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Installation <a class="headerlink leafygreen-ui-1kepx47" href="#installation" 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="installation"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> The <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-binary-bin.mongokerberos" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongokerberos </code> </span> </a> tool is part of the <em> MongoDB Database Tools Extra </em> package, and can be <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-mongokerberos-installed-with-server" target="_self"> <span> installed with the MongoDB Server </span> </a> or as a <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-mongokerberos-standalone-installation" target="_self"> <span> standalone installation <!-- --> . </span> </a> </p> <span class="leafygreen-ui-1qnjd6d" id="std-label-mongokerberos-installed-with-server"> </span> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Install with Server <a class="headerlink leafygreen-ui-1kepx47" href="#install-with-server" 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="install-with-server"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> To install <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-binary-bin.mongokerberos" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongokerberos </code> </span> </a> as part of a MongoDB Enterprise Server installation: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Follow the instructions for your platform: <a class="leafygreen-ui-tqgtui" href="/docs/manual/administration/install-enterprise/#std-label-install-mdb-enterprise"> Install MongoDB Enterprise Server </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> After completing the installation, <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-binary-bin.mongokerberos" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongokerberos </code> </span> </a> and the other included tools are available in the same location as the Server. </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 the Windows <code class="leafygreen-ui-1l06pbn"> .msi </code> installer wizard, the <span class="guilabel css-h15tq0"> Complete </span> installation option includes <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-binary-bin.mongokerberos" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongokerberos </code> </span> </a> . </p> </div> </div> </li> </ul> <span class="leafygreen-ui-1qnjd6d" id="std-label-mongokerberos-standalone-installation"> </span> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Install as Standalone <a class="headerlink leafygreen-ui-1kepx47" href="#install-as-standalone" 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="install-as-standalone"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> To install <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-binary-bin.mongokerberos" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongokerberos </code> </span> </a> as a standalone installation: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Follow the download link for MongoDB Enterprise Edition: <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/try/download/enterprise?tck=docs_server" target="_self"> <span> MongoDB Enterprise Download Center </span> </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Select your <span class="guilabel css-h15tq0"> Platform </span> (operating system) from the dropdown menu, then select the appropriate <span class="guilabel css-h15tq0"> Package </span> for your platform according to the following chart: </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> OS </div> </div> </th> <th class="leafygreen-ui-13uteka" role="columnheader" scope="col"> <div class="leafygreen-ui-ui0te9"> <div> Package </div> </div> </th> </tr> </thead> <tbody> <tr class=""> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Linux </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> tgz </code> package </div> </div> </td> </tr> <tr class=""> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Windows </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> zip </code> package </div> </div> </td> </tr> <tr class=""> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> macOS </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> tgz </code> package </div> </div> </td> </tr> </tbody> </table> </div> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Once downloaded, unpack the archive and copy <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-binary-bin.mongokerberos" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongokerberos </code> </span> </a> to a location on your hard drive. </p> <div class="leafygreen-ui-13vw3ie" role="note"> <h2 class="leafygreen-ui-1fn4p2b"> Tip </h2> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> Linux and macOS users may wish to copy <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-binary-bin.mongokerberos" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongokerberos </code> </span> </a> to a filesystem location that is defined in the <code class="leafygreen-ui-1l06pbn"> $PATH </code> environment variable, such as <code class="leafygreen-ui-1l06pbn"> /usr/bin </code> . Doing so allows referencing <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-binary-bin.mongokerberos" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongokerberos </code> </span> </a> directly on the command line by name, without needing to specify its full path, or first navigating to its parent directory. See the <a class="leafygreen-ui-tqgtui" href="/docs/manual/installation/#std-label-tutorial-installation"> installation guide </a> for your platform for more information. </p> </div> </div> </li> </ul> <span class="leafygreen-ui-1qnjd6d" id="std-label-mongokeberos-usage"> </span> </section> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Usage <a class="headerlink leafygreen-ui-1kepx47" href="#usage" 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="usage"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-binary-bin.mongokerberos" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongokerberos </code> </span> </a> can be run in two modes: <em> server </em> and <em> client </em> . </p> <p class="leafygreen-ui-1kp3ins"> Run <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-binary-bin.mongokerberos" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongokerberos </code> </span> </a> from the system command line, not in the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/mongodb-shell/#mongodb-binary-bin.mongosh" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongosh </code> . </span> </a> </p> <span class="leafygreen-ui-1qnjd6d" id="std-label-mongokeberos-usage-server"> </span> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Server Mode <a class="headerlink leafygreen-ui-1kepx47" href="#server-mode" 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="server-mode"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> Running <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-binary-bin.mongokerberos" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongokerberos </code> </span> </a> in server mode performs a series of verification steps against your system's Kerberos configuration, including checking for proper DNS resolution, validation of the Kerberos system keytab file, and testing against the MongoDB service principal for your <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> or <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongos/#mongodb-binary-bin.mongos"> <code class="leafygreen-ui-1l06pbn"> mongos </code> </a> instance. </p> <p class="leafygreen-ui-1kp3ins"> Before you can use <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-binary-bin.mongokerberos" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongokerberos </code> </span> </a> in server mode, you must: </p> <ol class="leafygreen-ui-rioki0" type="1"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Configure Kerberos on your platform according to your platform's documentation. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Create the MongoDB service principal for use with your <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> or <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongos/#mongodb-binary-bin.mongos"> <code class="leafygreen-ui-1l06pbn"> mongos </code> </a> instance, as described in the following steps: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/tutorial/control-access-to-mongodb-with-kerberos-authentication/#std-label-kerberos-linux-prerequisites"> Configure Service Principal on Linux </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/tutorial/control-access-to-mongodb-windows-with-kerberos-authentication/#std-label-assign-service-principal-name"> Configure Service Principal on Windows </a> </p> </li> </ul> </li> </ol> <p class="leafygreen-ui-1kp3ins"> Once you have completed these steps, you can run <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-binary-bin.mongokerberos" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongokerberos </code> </span> </a> in server mode using the <code class="leafygreen-ui-1l06pbn"> --server </code> flag as follows: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"mongokerberos --server","programmingLanguage":"Bash"} </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 bash leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">mongokerberos --server</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"> If Kerberos has been configured properly on the server, and the service principal created successfully, the output might resemble the following: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"Resolving kerberos environment...\n[OK] Kerberos environment resolved without errors.\n\nVerifying DNS resolution works with Kerberos service at &lt;hostname&gt;...\n[OK] DNS test successful.\n\nGetting MIT Kerberos KRB5 environment variables...\n * KRB5CCNAME: not set.\n * KRB5_CLIENT_KTNAME: not set.\n * KRB5_CONFIG: not set.\n * KRB5_KTNAME: not set.\n * KRB5_TRACE: not set.\n[OK]\n\nVerifying existence of KRB5 keytab FILE:/etc/krb5.keytab...\n[OK] KRB5 keytab exists and is populated.\n\nChecking principal(s) in KRB5 keytab...\nFound the following principals for MongoDB service mongodb:\n * mongodb/[email protected]\nFound the following kvnos in keytab entries for service mongodb:\n * 3\n[OK] KRB5 keytab is valid.\n\nFetching KRB5 Config...\nKRB5 config profile resolved as:\n &lt;your&gt;\n[OK] KRB5 config profile resolved without errors.\n\nAttempting to initiate security context with service credentials...\n[OK] Security context initiated successfully."} </script> <div class="css-1lju8ps"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-tyg50d"> <pre class="leafygreen-ui-1453az5" tabindex="0"><code class="lg-highlight-hljs-light none leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">Resolving kerberos environment...</td></tr><tr class=""><td class="leafygreen-ui-7razhx">[OK] Kerberos environment resolved without errors.</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><div class="leafygreen-ui-ihxujy"></div></td></tr><tr class=""><td class="leafygreen-ui-7razhx">Verifying DNS resolution works with Kerberos service at &lt;hostname&gt;...</td></tr><tr class=""><td class="leafygreen-ui-7razhx">[OK] DNS test successful.</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><div class="leafygreen-ui-ihxujy"></div></td></tr><tr class=""><td class="leafygreen-ui-7razhx">Getting MIT Kerberos KRB5 environment variables...</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> * KRB5CCNAME: not set.</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> * KRB5_CLIENT_KTNAME: not set.</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> * KRB5_CONFIG: not set.</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> * KRB5_KTNAME: not set.</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> * KRB5_TRACE: not set.</td></tr><tr class=""><td class="leafygreen-ui-7razhx">[OK]</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><div class="leafygreen-ui-ihxujy"></div></td></tr><tr class=""><td class="leafygreen-ui-7razhx">Verifying existence of KRB5 keytab FILE:/etc/krb5.keytab...</td></tr><tr class=""><td class="leafygreen-ui-7razhx">[OK] KRB5 keytab exists and is populated.</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><div class="leafygreen-ui-ihxujy"></div></td></tr><tr class=""><td class="leafygreen-ui-7razhx">Checking principal(s) in KRB5 keytab...</td></tr><tr class=""><td class="leafygreen-ui-7razhx">Found the following principals for MongoDB service mongodb:</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> * mongodb/[email protected]</td></tr><tr class=""><td class="leafygreen-ui-7razhx">Found the following kvnos in keytab entries for service mongodb:</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> * 3</td></tr><tr class=""><td class="leafygreen-ui-7razhx">[OK] KRB5 keytab is valid.</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><div class="leafygreen-ui-ihxujy"></div></td></tr><tr class=""><td class="leafygreen-ui-7razhx">Fetching KRB5 Config...</td></tr><tr class=""><td class="leafygreen-ui-7razhx">KRB5 config profile resolved as:</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> &lt;Your Kerberos profile file will be output here&gt;</td></tr><tr class=""><td class="leafygreen-ui-7razhx">[OK] KRB5 config profile resolved without errors.</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><div class="leafygreen-ui-ihxujy"></div></td></tr><tr class=""><td class="leafygreen-ui-7razhx">Attempting to initiate security context with service credentials...</td></tr><tr class=""><td class="leafygreen-ui-7razhx">[OK] Security context initiated successfully.</td></tr></tbody></table></code></pre> </div> </div> </div> <p class="leafygreen-ui-1kp3ins"> The final message indicates that the system's Kerberos configuration is ready to be used with MongoDB. If any errors are encountered with the configuration, they will be presented as part of the above output. </p> <span class="leafygreen-ui-1qnjd6d" id="std-label-mongokeberos-usage-client"> </span> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Client Mode <a class="headerlink leafygreen-ui-1kepx47" href="#client-mode" 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="client-mode"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> Running <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-binary-bin.mongokerberos" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongokerberos </code> </span> </a> in client mode tests authentication against your system's Kerberos environment, performing each step in the Kerberos authentication process, including checking for proper DNS resolution, verification of the Kerberos client keytab file, and testing whether a ticket can be successfully granted. Running <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-binary-bin.mongokerberos" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongokerberos </code> </span> </a> in client mode simulates the client authentication procedure of <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/mongodb-shell/#mongodb-binary-bin.mongosh" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongosh </code> . </span> </a> </p> <p class="leafygreen-ui-1kp3ins"> Before you can use <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-binary-bin.mongokerberos" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongokerberos </code> </span> </a> in client mode, you must first have configured Kerberos on your platform according to your platform's documentation. Optionally, you may also choose to run <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-binary-bin.mongokerberos" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongokerberos </code> </span> </a> in <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-mongokeberos-usage-server" target="_self"> <span> server mode </span> </a> first to verify that your platform's Kerberos configuration is valid before using client mode. </p> <p class="leafygreen-ui-1kp3ins"> Once you have completed these steps, you can run <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-binary-bin.mongokerberos" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongokerberos </code> </span> </a> in client mode to test user authentication, using the <code class="leafygreen-ui-1l06pbn"> --client </code> flag as follows: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"mongokerberos --client --username &lt;username&gt;","programmingLanguage":"Bash"} </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 bash leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">mongokerberos --client --username &lt;username&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"> You must provide a valid username, which is used to request a Kerberos ticket as part of the authentication procedure. Your platform's Kerberos infrastructure must be aware of this user. </p> <p class="leafygreen-ui-1kp3ins"> If the provided credentials are valid, and the Kerberos options in the configuration files are valid, the output might resemble the following: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":" Resolving kerberos environment...\n [OK] Kerberos environment resolved without errors.\n\n Verifying DNS resolution works with Kerberos service at &lt;hostname&gt;...\n [OK] DNS test successful.\n\n Getting MIT Kerberos KRB5 environment variables...\n * KRB5CCNAME: not set.\n * KRB5_CLIENT_KTNAME: not set.\n * KRB5_CONFIG: not set.\n * KRB5_KTNAME: not set.\n * KRB5_TRACE: not set.\n [OK]\n\n Verifying existence of KRB5 client keytab FILE:/path/to/client.keytab...\n [OK] KRB5 client keytab exists and is populated.\n\n Checking principal(s) in KRB5 keytab...\n [OK] KRB5 keytab is valid.\n\n Fetching KRB5 Config...\n KRB5 config profile resolved as:\n &lt;your&gt;\n [OK] KRB5 config profile resolved without errors.\n\n Attempting client half of GSSAPI conversation...\n [OK] Client half of GSSAPI conversation completed successfully."} </script> <div class="css-1lju8ps"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-tyg50d"> <pre class="leafygreen-ui-1453az5" tabindex="0"><code class="lg-highlight-hljs-light none leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx"> Resolving kerberos environment...</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> [OK] Kerberos environment resolved without errors.</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><div class="leafygreen-ui-ihxujy"></div></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> Verifying DNS resolution works with Kerberos service at &lt;hostname&gt;...</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> [OK] DNS test successful.</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><div class="leafygreen-ui-ihxujy"></div></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> Getting MIT Kerberos KRB5 environment variables...</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> * KRB5CCNAME: not set.</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> * KRB5_CLIENT_KTNAME: not set.</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> * KRB5_CONFIG: not set.</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> * KRB5_KTNAME: not set.</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> * KRB5_TRACE: not set.</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> [OK]</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><div class="leafygreen-ui-ihxujy"></div></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> Verifying existence of KRB5 client keytab FILE:/path/to/client.keytab...</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> [OK] KRB5 client keytab exists and is populated.</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><div class="leafygreen-ui-ihxujy"></div></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> Checking principal(s) in KRB5 keytab...</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> [OK] KRB5 keytab is valid.</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><div class="leafygreen-ui-ihxujy"></div></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> Fetching KRB5 Config...</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> KRB5 config profile resolved as:</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> &lt;Your Kerberos profile file will be output here&gt;</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> [OK] KRB5 config profile resolved without errors.</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><div class="leafygreen-ui-ihxujy"></div></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> Attempting client half of GSSAPI conversation...</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> [OK] Client half of GSSAPI conversation completed successfully.</td></tr></tbody></table></code></pre> </div> </div> </div> <p class="leafygreen-ui-1kp3ins"> The final message indicates that client authentication completed successfully for the user provided. If any errors are encountered during the authentication steps, they will be presented as part of the above output. </p> </section> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Options <a class="headerlink leafygreen-ui-1kepx47" href="#options" 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="options"> </div> </a> </h2> <span class="leafygreen-ui-1qnjd6d" id="std-label-mongokeberos-option-server"> </span> <dl class="option"> <dt> <code class="leafygreen-ui-1l06pbn"> --server </code> <a class="headerlink leafygreen-ui-1kepx47" href="#std-option-mongokerberos.--server" title="Permalink to this definition"> <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="std-option-mongokerberos.--server"> </div> </a> </dt> <dd> <p class="leafygreen-ui-1kp3ins"> Runs <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-binary-bin.mongokerberos" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongokerberos </code> </span> </a> in server mode to test that your platform's Kerberos configuration is valid for use with MongoDB. </p> <p class="leafygreen-ui-1kp3ins"> See <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-mongokeberos-usage-server" target="_self"> <span> Server Mode </span> </a> for example usage and expected output. </p> </dd> </dl> <span class="leafygreen-ui-1qnjd6d" id="std-label-mongokeberos-option-client"> </span> <dl class="option"> <dt> <code class="leafygreen-ui-1l06pbn"> --client </code> <a class="headerlink leafygreen-ui-1kepx47" href="#std-option-mongokerberos.--client" title="Permalink to this definition"> <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="std-option-mongokerberos.--client"> </div> </a> </dt> <dd> <p class="leafygreen-ui-1kp3ins"> Runs <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-binary-bin.mongokerberos" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongokerberos </code> </span> </a> in client mode to test client authentication against your system's Kerberos environment. Requires specifying a valid username with <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-option-mongokerberos.--username" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> --username </code> </span> </a> when running in client mode. <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-binary-bin.mongokerberos" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongokerberos </code> </span> </a> will request a Kerberos ticket for this username as part of the validation procedure. Running <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-binary-bin.mongokerberos" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongokerberos </code> </span> </a> in client mode simulates the client authentication procedure of <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/mongodb-shell/#mongodb-binary-bin.mongosh" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongosh </code> . </span> </a> </p> <p class="leafygreen-ui-1kp3ins"> See <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-mongokeberos-usage-client" target="_self"> <span> Client Mode </span> </a> for example usage and expected output. </p> </dd> </dl> <dl class="option"> <dt> <code class="leafygreen-ui-1l06pbn"> --config &lt;filename&gt;, -f &lt;filename&gt; </code> <a class="headerlink leafygreen-ui-1kepx47" href="#std-option-mongokerberos.--config" title="Permalink to this definition"> <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="std-option-mongokerberos.--config"> </div> </a> </dt> <dd> <p class="leafygreen-ui-1kp3ins"> Specifies a configuration file for runtime configuration options. The options are equivalent to the command-line configuration options. See <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/configuration-options/"> Self-Managed Configuration File Options </a> for more information. </p> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-binary-bin.mongokerberos" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongokerberos </code> </span> </a> will read the values for <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/parameters/#mongodb-parameter-param.saslHostName"> <code class="leafygreen-ui-1l06pbn"> saslHostName </code> </a> and <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/parameters/#mongodb-parameter-param.saslServiceName"> <code class="leafygreen-ui-1l06pbn"> saslServiceName </code> </a> from this file if present. These values can alteratively be specified with the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-option-mongokerberos.--setParameter" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> --setParameter </code> </span> </a> option instead. </p> <p class="leafygreen-ui-1kp3ins"> Ensure the configuration file uses ASCII encoding. The <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-binary-bin.mongokerberos" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongokerberos </code> </span> </a> instance does not support configuration files with non-ASCII encoding, including UTF-8. </p> <p class="leafygreen-ui-1kp3ins"> Only valid in <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-mongokeberos-usage-server" target="_self"> <span> server mode <!-- --> . </span> </a> </p> </dd> </dl> <dl class="option"> <dt> <code class="leafygreen-ui-1l06pbn"> --setParameter &lt;options&gt; </code> <a class="headerlink leafygreen-ui-1kepx47" href="#std-option-mongokerberos.--setParameter" title="Permalink to this definition"> <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="std-option-mongokerberos.--setParameter"> </div> </a> </dt> <dd> <p class="leafygreen-ui-1kp3ins"> Sets a configurable parameter. You can specify multiple <code class="leafygreen-ui-1l06pbn"> setParameter </code> fields. </p> <p class="leafygreen-ui-1kp3ins"> While you can use any supported parameters with <code class="leafygreen-ui-1l06pbn"> setParameter </code> , <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-binary-bin.mongokerberos" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongokerberos </code> </span> </a> only checks for the value of the following: </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/parameters/#mongodb-parameter-param.saslHostName"> <code class="leafygreen-ui-1l06pbn"> saslHostName </code> </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/parameters/#mongodb-parameter-param.saslServiceName"> <code class="leafygreen-ui-1l06pbn"> saslServiceName </code> </a> </p> </li> </ul> <p class="leafygreen-ui-1kp3ins"> If using the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-option-mongokerberos.--config" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> --config </code> </span> </a> option with a configuration file that also contains these values, the <code class="leafygreen-ui-1l06pbn"> setParameter </code> values will override the values from the configuration file. </p> <p class="leafygreen-ui-1kp3ins"> Valid in both <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-mongokeberos-usage-server" target="_self"> <span> server mode </span> </a> and <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-mongokeberos-usage-client" target="_self"> <span> client mode <!-- --> . </span> </a> </p> </dd> </dl> <dl class="option"> <dt> <code class="leafygreen-ui-1l06pbn"> --host &lt;hostname&gt; </code> <a class="headerlink leafygreen-ui-1kepx47" href="#std-option-mongokerberos.--host" title="Permalink to this definition"> <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="std-option-mongokerberos.--host"> </div> </a> </dt> <dd> <p class="leafygreen-ui-1kp3ins"> Specify the hostname of the MongoDB server to connect to when testing authentication. </p> <p class="leafygreen-ui-1kp3ins"> If <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-option-mongokerberos.--host" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> --host </code> </span> </a> is not specified, <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-binary-bin.mongokerberos" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongokerberos </code> </span> </a> does not perform any DNS validation of the hostname (i.e. PTR record verification) </p> <p class="leafygreen-ui-1kp3ins"> Only valid in <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-mongokeberos-usage-client" target="_self"> <span> client mode <!-- --> . </span> </a> </p> </dd> </dl> <dl class="option"> <dt> <code class="leafygreen-ui-1l06pbn"> --username &lt;username&gt;, -u &lt;username&gt; </code> <a class="headerlink leafygreen-ui-1kepx47" href="#std-option-mongokerberos.--username" title="Permalink to this definition"> <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="std-option-mongokerberos.--username"> </div> </a> </dt> <dd> <p class="leafygreen-ui-1kp3ins"> Username for <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-binary-bin.mongokerberos" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongokerberos </code> </span> </a> to use when attempting Kerberos authentication. This value is required when running in <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-mongokeberos-usage-client" target="_self"> <span> client mode <!-- --> . </span> </a> </p> <p class="leafygreen-ui-1kp3ins"> Only valid in <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-mongokeberos-usage-client" target="_self"> <span> client mode <!-- --> . </span> </a> </p> </dd> </dl> <dl class="option"> <dt> <code class="leafygreen-ui-1l06pbn"> --gssapiServiceName &lt;servicename&gt; </code> <a class="headerlink leafygreen-ui-1kepx47" href="#std-option-mongokerberos.--gssapiServiceName" title="Permalink to this definition"> <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="std-option-mongokerberos.--gssapiServiceName"> </div> </a> </dt> <dd> <p class="leafygreen-ui-1kp3ins"> <em> default: 'mongodb' </em> </p> <p class="leafygreen-ui-1kp3ins"> Service principal name to use when authenticating using GSSAPI/Kerberos. </p> <p class="leafygreen-ui-1kp3ins"> Only valid in <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-mongokeberos-usage-client" target="_self"> <span> client mode <!-- --> . </span> </a> </p> </dd> </dl> <dl class="option"> <dt> <code class="leafygreen-ui-1l06pbn"> --gssapiHostName &lt;hostname&gt; </code> <a class="headerlink leafygreen-ui-1kepx47" href="#std-option-mongokerberos.--gssapiHostName" title="Permalink to this definition"> <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="std-option-mongokerberos.--gssapiHostName"> </div> </a> </dt> <dd> <p class="leafygreen-ui-1kp3ins"> Remote hostname to use for purpose of GSSAPI/Kerberos authentication. </p> <p class="leafygreen-ui-1kp3ins"> Only valid in <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-mongokeberos-usage-client" target="_self"> <span> client mode <!-- --> . </span> </a> </p> </dd> </dl> </section> </section>
https://www.mongodb.com/docs/manual/reference/method/getKeyVault/
<section> <h1 class="contains-headerlink leafygreen-ui-41fr9s" weight="medium"> getKeyVault() <a class="headerlink leafygreen-ui-1kepx47" href="#getkeyvault--" 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="getkeyvault--"> </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="#behavior" target="_self"> <span> Behavior </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#example" target="_self"> <span> Example </span> </a> </li> </ul> </div> <dl class="method"> <dt> <code class="leafygreen-ui-1l06pbn"> getKeyVault() </code> <a class="headerlink leafygreen-ui-1kepx47" href="#mongodb-method-getKeyVault" title="Permalink to this definition"> <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="mongodb-method-getKeyVault"> </div> </a> </dt> <dd> <p class="leafygreen-ui-1kp3ins"> Returns the <code class="leafygreen-ui-1l06pbn"> KeyVault </code> object for the current database connection. The <code class="leafygreen-ui-1l06pbn"> KeyVault </code> object supports data encryption key management for <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/csfle/#std-label-manual-csfle-feature"> Client-Side Field Level Encryption <!-- --> . </a> </p> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-method-getKeyVault" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> getKeyVault() </code> </span> </a> has the following syntax: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"keyVault = db.getMongo().getKeyVault();","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">keyVault <!-- -->= <!-- -->db.<span class="lg-highlight-title lg-highlight-function">getMongo</span>(<!-- -->).<span class="lg-highlight-title lg-highlight-function">getKeyVault</span>(<!-- -->)<!-- -->;</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> <table class="css-11h39yh e1nex8bq0"> <colgroup> <col class="field-name"/> <col class="field-body"/> </colgroup> <tbody> <tr class="css-x8snli"> <th> Returns <!-- --> : </th> <td> The <code class="leafygreen-ui-1l06pbn"> KeyVault </code> object for current database connection. </td> </tr> </tbody> </table> </dd> </dl> <p class="leafygreen-ui-1kp3ins"> Use the <code class="leafygreen-ui-1l06pbn"> KeyVault </code> object to access the following data encryption key management methods: </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/method/KeyVault.getKey/#mongodb-method-KeyVault.getKey"> <code class="leafygreen-ui-1l06pbn"> getKey() </code> </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/KeyVault.getKeys/#mongodb-method-KeyVault.getKeys"> <code class="leafygreen-ui-1l06pbn"> getKeys() </code> </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/KeyVault.getKeyByAltName/#mongodb-method-KeyVault.getKeyByAltName"> <code class="leafygreen-ui-1l06pbn"> getKeyByAltName() </code> </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/KeyVault.createKey/#mongodb-method-KeyVault.createKey"> <code class="leafygreen-ui-1l06pbn"> createKey() </code> </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/KeyVault.addKeyAlternateName/#mongodb-method-KeyVault.addKeyAlternateName"> <code class="leafygreen-ui-1l06pbn"> addKeyAlternateName() </code> </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/KeyVault.removeKeyAlternateName/#mongodb-method-KeyVault.removeKeyAlternateName"> <code class="leafygreen-ui-1l06pbn"> removeKeyAlternateName() </code> </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/KeyVault.deleteKey/#mongodb-method-KeyVault.deleteKey"> <code class="leafygreen-ui-1l06pbn"> deleteKey() </code> </a> </p> </li> </ul> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Behavior <a class="headerlink leafygreen-ui-1kepx47" href="#behavior" 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="behavior"> </div> </a> </h2> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Requires Configuring Client-Side Field Level Encryption on Database Connection <a class="headerlink leafygreen-ui-1kepx47" href="#requires-configuring-client-side-field-level-encryption-on-database-connection" 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="requires-configuring-client-side-field-level-encryption-on-database-connection"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> The following example uses a <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/queryable-encryption/fundamentals/kms-providers/#std-label-qe-fundamentals-kms-providers-local"> locally managed key </a> for the client-side field level encryption configuration. </p> <p class="leafygreen-ui-1kp3ins"> The <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/mongodb-shell/#mongodb-binary-bin.mongosh" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongosh </code> </span> </a> client-side field level encryption methods require a database connection with client-side field level encryption enabled. If the current database connection was not initiated with client-side field level encryption enabled, either: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Use the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/Mongo/#mongodb-method-Mongo"> <code class="leafygreen-ui-1l06pbn"> Mongo() </code> </a> constructor from the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/mongodb-shell/#mongodb-binary-bin.mongosh" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongosh </code> </span> </a> to establish a connection with the required client-side field level encryption options. The <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/Mongo/#mongodb-method-Mongo"> <code class="leafygreen-ui-1l06pbn"> Mongo() </code> </a> method supports the following Key Management Service (KMS) providers for Customer Master Key (CMK) management: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/queryable-encryption/fundamentals/kms-providers/#std-label-qe-fundamentals-kms-providers-aws"> Amazon Web Services KMS </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/queryable-encryption/fundamentals/kms-providers/#std-label-qe-fundamentals-kms-providers-azure"> Azure Key Vault </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/queryable-encryption/fundamentals/kms-providers/#std-label-qe-fundamentals-kms-providers-gcp"> Google Cloud Platform KMS </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/queryable-encryption/fundamentals/kms-providers/#std-label-qe-fundamentals-kms-providers-local"> Locally Managed Key </a> </p> </li> </ul> <p class="leafygreen-ui-1kp3ins"> <em> or </em> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Use the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/mongodb-shell/#mongodb-binary-bin.mongosh" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongosh </code> </span> </a> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/mongodb-shell/reference/options/#std-label-mongosh-client-side-field-level-encryption-options" target="_self"> <span> command line options </span> </a> to establish a connection with the required options. The command line options only support the <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/queryable-encryption/fundamentals/kms-providers/#std-label-qe-fundamentals-kms-providers-aws"> Amazon Web Services KMS </a> provider for CMK management. </p> </li> </ul> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Unique Partial Index on Key Vault <a class="headerlink leafygreen-ui-1kepx47" href="#unique-partial-index-on-key-vault" 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="unique-partial-index-on-key-vault"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> The <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-method-getKeyVault" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> getKeyVault() </code> </span> </a> method automatically creates a <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/index-unique/#std-label-index-type-unique"> unique index </a> on the <code class="leafygreen-ui-1l06pbn"> keyAltNames </code> field with a <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/index-partial/#std-label-index-type-partial"> partial index </a> filter for only documents where <code class="leafygreen-ui-1l06pbn"> keyAltNames </code> exists. <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-method-getKeyVault" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> getKeyVault() </code> </span> </a> creates this index in the key vault collection. This prevents any two data encryption keys in the same key vault from having the same key alternative name and therefore avoids ambiguity around which data encryption key is appropriate for encryption/decryption. </p> <div class="leafygreen-ui-1sjx7ru" role="note"> <h2 class="leafygreen-ui-29m78u"> Warning </h2> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> Do not drop the unique index created by <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-method-getKeyVault" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> getKeyVault() </code> </span> </a> . Client-Side Field Level Encryption operations depend on server-enforced uniqueness of <code class="leafygreen-ui-1l06pbn"> keyAltNames </code> . Removing the index may lead to unexpected or unpredictable behavior. </p> </div> </div> </section> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Example <a class="headerlink leafygreen-ui-1kepx47" href="#example" 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="example"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> The following example uses a <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/queryable-encryption/fundamentals/kms-providers/#std-label-qe-fundamentals-kms-providers-local"> locally managed key </a> for the client-side field level encryption configuration. </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"HowTo","steps":[{"@type":"HowToStep","text":"Start the mongosh client.","name":"Start mongosh"},{"@type":"HowToStep","text":"To configure client-side field level encryption for a locally\nmanaged key, generate a base64-encoded 96-byte string with no line\nbreaks.","name":"Generate Your Key"},{"@type":"HowToStep","text":"Create the client-side field level encryption options using the\ngenerated local key string:","name":"Create the Client-Side Field Level Encryption Options"},{"@type":"HowToStep","text":"Use the Mongo() constructor with the client-side field level\nencryption options configured to create a database connection. Replace\nthe mongodb://myMongo.example.net URI with the connection\nstring URI of the target cluster.","name":"Create Your Encrypted Client"}],"name":"Example","image":"https://webimages.mongodb.com/_com_assets/cms/kuyj2focmkbxv7gh3-stacked_default_slate_blue.svg?auto=format%252Ccompress"} </script> <div class="css-4nyere eccljxs0"> <div class="css-1nuklj8 e1ckbxcu1"> <div class="css-18fui5z e1ckbxcu0"> <div class="css-19lsqsq e1ckbxcu2"> 1 </div> </div> <div class="css-1ed38mk"> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Start mongosh <a class="headerlink leafygreen-ui-1kepx47" href="#start-mongosh" 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="start-mongosh"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> Start the <code class="leafygreen-ui-1l06pbn"> mongosh </code> client. </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"mongosh --nodb","programmingLanguage":"Bash"} </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 bash leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">mongosh --nodb</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> </section> </div> </div> <div class="css-1nuklj8 e1ckbxcu1"> <div class="css-18fui5z e1ckbxcu0"> <div class="css-19lsqsq e1ckbxcu2"> 2 </div> </div> <div class="css-1ed38mk"> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Generate Your Key <a class="headerlink leafygreen-ui-1kepx47" href="#generate-your-key" 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="generate-your-key"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> To configure client-side field level encryption for a locally managed key, generate a base64-encoded 96-byte string with no line breaks. </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"const TEST_LOCAL_KEY = require(\"crypto\").randomBytes(96).toString(\"base64\")","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-1q4bxgx" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-keyword">const</span> <span class="lg-highlight-variable lg-highlight-constant">TEST_LOCAL_KEY</span> <!-- -->= <span class="lg-highlight-built_in">require</span>(<span class="lg-highlight-string">"crypto"</span>).<span class="lg-highlight-title lg-highlight-function">randomBytes</span>(<span class="lg-highlight-number">96</span>).<span class="lg-highlight-title lg-highlight-function">toString</span>(<span class="lg-highlight-string">"base64"</span>)</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> </section> </div> </div> <div class="css-1nuklj8 e1ckbxcu1"> <div class="css-18fui5z e1ckbxcu0"> <div class="css-19lsqsq e1ckbxcu2"> 3 </div> </div> <div class="css-1ed38mk"> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Create the Client-Side Field Level Encryption Options <a class="headerlink leafygreen-ui-1kepx47" href="#create-the-client-side-field-level-encryption-options" 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="create-the-client-side-field-level-encryption-options"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> Create the client-side field level encryption options using the generated local key string: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":" var autoEncryptionOpts = {\n \"keyVaultNamespace\" : \"encryption.__dataKeys\",\n \"kmsProviders\" : {\n \"local\" : {\n \"key\" : BinData(0, TEST_LOCAL_KEY)\n }\n }\n }","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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"> <span class="lg-highlight-keyword">var</span> autoEncryptionOpts <!-- -->= <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"keyVaultNamespace"</span> <!-- -->: <span class="lg-highlight-string">"encryption.__dataKeys"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"kmsProviders"</span> <!-- -->: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"local"</span> <!-- -->: <!-- -->{</td></tr><tr class="leafygreen-ui-1wr1lm6"><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"key"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">BinData</span>(<span class="lg-highlight-number">0</span>, <span class="lg-highlight-variable lg-highlight-constant">TEST_LOCAL_KEY</span>)</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</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> </section> </div> </div> <div class="css-1nuklj8 e1ckbxcu1"> <div class="css-18fui5z e1ckbxcu0"> <div class="css-19lsqsq e1ckbxcu2"> 4 </div> </div> <div class="css-1ed38mk"> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Create Your Encrypted Client <a class="headerlink leafygreen-ui-1kepx47" href="#create-your-encrypted-client" 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="create-your-encrypted-client"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> Use the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/Mongo/#mongodb-method-Mongo"> <code class="leafygreen-ui-1l06pbn"> Mongo() </code> </a> constructor with the client-side field level encryption options configured to create a database connection. Replace the <code class="leafygreen-ui-1l06pbn"> mongodb://myMongo.example.net </code> URI with the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/connection-string/#std-label-mongodb-uri"> connection string URI </a> of the target cluster. </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"encryptedClient = Mongo(\n \"mongodb://myMongo.example.net:27017/?replSetName=myMongo\",\n autoEncryptionOpts\n)","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">encryptedClient <!-- -->= <span class="lg-highlight-title lg-highlight-class">Mongo</span>(</td></tr><tr class="leafygreen-ui-1wr1lm6"><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"mongodb://myMongo.example.net:27017/?replSetName=myMongo"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->autoEncryptionOpts</td></tr><tr class=""><td class="leafygreen-ui-7razhx">)</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> </section> </div> </div> </div> <p class="leafygreen-ui-1kp3ins"> Use the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-method-getKeyVault" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> getKeyVault() </code> </span> </a> method to retrieve the key vault object: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"keyVault = encryptedClient.getKeyVault()","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">keyVault <!-- -->= <!-- -->encryptedClient.<span class="lg-highlight-title lg-highlight-function">getKeyVault</span>(<!-- -->)</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"> For complete documentation on initiating MongoDB connections with client-side field level encryption enabled, see <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/Mongo/#mongodb-method-Mongo"> <code class="leafygreen-ui-1l06pbn"> Mongo() </code> . </a> </p> </section> </section>
https://www.mongodb.com/docs/manual/introduction/
<section> <h1 class="contains-headerlink leafygreen-ui-41fr9s" weight="medium"> Introduction to MongoDB <a class="headerlink leafygreen-ui-1kepx47" href="#introduction-to-mongodb" 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="introduction-to-mongodb"> </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="#document-database" target="_self"> <span> Document Database </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#key-features" target="_self"> <span> Key Features </span> </a> </li> </ul> </div> <p class="leafygreen-ui-1kp3ins"> You can create a MongoDB database 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> <p class="leafygreen-ui-1kp3ins"> To learn more about creating a MongoDB database with the Atlas UI, see <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/atlas/getting-started/" target="_self"> <span> Get Started with Atlas <!-- --> . </span> </a> </p> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Document Database <a class="headerlink leafygreen-ui-1kepx47" href="#document-database" 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="document-database"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> A record in MongoDB is a document, which is a data structure composed of field and value pairs. MongoDB documents are similar to JSON objects. The values of fields may include other documents, arrays, and arrays of documents. </p> <div class="figure css-5vkxs0" style="width:570px"> <img alt="A MongoDB document." class="leafygreen-ui-1qnf57e" height="170" src="/docs/manual/images/crud-annotated-document.bakedsvg.svg" style="--border-color:#C1C7C6" width="570"/> </div> <p class="leafygreen-ui-1kp3ins"> The advantages of using documents are: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Documents correspond to native data types in many programming languages. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Embedded documents and arrays reduce need for expensive joins. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Dynamic schema supports fluent polymorphism. </p> </li> </ul> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Collections/Views/On-Demand Materialized Views <a class="headerlink leafygreen-ui-1kepx47" href="#collections-views-on-demand-materialized-views" 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="collections-views-on-demand-materialized-views"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> MongoDB stores documents in <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/databases-and-collections/#std-label-collections"> collections </a> . Collections are analogous to tables in relational databases. </p> <p class="leafygreen-ui-1kp3ins"> In addition to collections, MongoDB supports: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Read-only <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/views/"> Views </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/materialized-views/"> On-Demand Materialized Views </a> </p> </li> </ul> </section> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Key Features <a class="headerlink leafygreen-ui-1kepx47" href="#key-features" 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="key-features"> </div> </a> </h2> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> High Performance <a class="headerlink leafygreen-ui-1kepx47" href="#high-performance" 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="high-performance"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> MongoDB provides high performance data persistence. In particular, </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Support for embedded data models reduces I/O activity on database system. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Indexes support faster queries and can include keys from embedded documents and arrays. </p> </li> </ul> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Query API <a class="headerlink leafygreen-ui-1kepx47" href="#query-api" 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="query-api"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> The MongoDB Query API supports <a class="leafygreen-ui-tqgtui" href="/docs/manual/crud/#std-label-crud"> read and write operations (CRUD) </a> as well as: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/aggregation-pipeline/#std-label-aggregation-pipeline"> Data Aggregation </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/text-search/#std-label-text-search"> Text Search </a> and <a class="leafygreen-ui-tqgtui" href="/docs/manual/tutorial/geospatial-tutorial/"> Geospatial Queries <!-- --> . </a> </p> </li> </ul> <div class="leafygreen-ui-13vw3ie" role="note"> <h2 class="leafygreen-ui-1fn4p2b"> Tip </h2> <h3 class="leafygreen-ui-144d5kf"> <strong> See also: </strong> </h3> <div class="leafygreen-ui-9mycqc"> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/sql-comparison/"> SQL to MongoDB Mapping Chart </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/sql-aggregation-comparison/"> SQL to Aggregation Mapping Chart </a> </p> </li> </ul> </div> </div> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> High Availability <a class="headerlink leafygreen-ui-1kepx47" href="#high-availability" 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="high-availability"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> MongoDB's replication facility, called <a class="leafygreen-ui-tqgtui" href="/docs/manual/replication/"> replica set </a> , provides: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <em> automatic </em> failover </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> data redundancy. </p> </li> </ul> <p class="leafygreen-ui-1kp3ins"> A <a class="leafygreen-ui-tqgtui" href="/docs/manual/replication/"> replica set </a> is a group of MongoDB servers that maintain the same data set, providing redundancy and increasing data availability. </p> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Horizontal Scalability <a class="headerlink leafygreen-ui-1kepx47" href="#horizontal-scalability" 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="horizontal-scalability"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> MongoDB provides horizontal scalability as part of its <em> core </em> functionality: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/sharding/#std-label-sharding-introduction"> Sharding </a> distributes data across a cluster of machines. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Starting in 3.4, MongoDB supports creating <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/zone-sharding/#std-label-zone-sharding"> zones </a> of data based on the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-shard-key"> shard key </a> . In a balanced cluster, MongoDB directs reads and writes covered by a zone only to those shards inside the zone. See the <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/zone-sharding/#std-label-zone-sharding"> Zones </a> manual page for more information. </p> </li> </ul> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Support for Multiple Storage Engines <a class="headerlink leafygreen-ui-1kepx47" href="#support-for-multiple-storage-engines" 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="support-for-multiple-storage-engines"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> MongoDB supports <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/storage-engines/"> multiple storage engines <!-- --> : </a> </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/wiredtiger/"> WiredTiger Storage Engine </a> (including support for <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/security-encryption-at-rest/"> Encryption at Rest <!-- --> ) </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/inmemory/"> In-Memory Storage Engine for Self-Managed Deployments <!-- --> . </a> </p> </li> </ul> <p class="leafygreen-ui-1kp3ins"> In addition, MongoDB provides pluggable storage engine API that allows third parties to develop storage engines for MongoDB. </p> </section> </section> </section>
https://www.mongodb.com/docs/manual/reference/command/autoCompact/
<section> <h1 class="contains-headerlink leafygreen-ui-41fr9s" weight="medium"> autoCompact <a class="headerlink leafygreen-ui-1kepx47" href="#autocompact" 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="autocompact"> </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="#definition" target="_self"> <span> Definition </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#syntax" target="_self"> <span> Syntax </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#compatibility" target="_self"> <span> Compatibility </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#command-fields" target="_self"> <span> Command Fields </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#required-privileges" target="_self"> <span> Required Privileges </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#behavior" target="_self"> <span> Behavior </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#learn-more" target="_self"> <span> Learn More </span> </a> </li> </ul> </div> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Definition <a class="headerlink leafygreen-ui-1kepx47" href="#definition" 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="definition"> </div> </a> </h2> <dl class="dbcommand"> <dt> <code class="leafygreen-ui-1l06pbn"> autoCompact </code> <a class="headerlink leafygreen-ui-1kepx47" href="#mongodb-dbcommand-dbcmd.autoCompact" title="Permalink to this definition"> <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="mongodb-dbcommand-dbcmd.autoCompact"> </div> </a> </dt> <dd> <div> <p> <em> New <!-- --> in version <!-- --> 8.0 </em> . </p> </div> <p class="leafygreen-ui-1kp3ins"> Enables or disables background <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/command/compact/#std-label-compact"> compaction </a> . When enabled, <code class="leafygreen-ui-1l06pbn"> autoCompact </code> periodically iterates through all available files and continuously runs compaction if there is enough free storage space available. </p> <p class="leafygreen-ui-1kp3ins"> Before you enable <code class="leafygreen-ui-1l06pbn"> autoCompact </code> , run the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/command/dbStats/#mongodb-dbcommand-dbcmd.dbStats"> <code class="leafygreen-ui-1l06pbn"> dbStats </code> </a> command to see if you have enough available storage space for compaction to proceed. If the amount of available space returned by <code class="leafygreen-ui-1l06pbn"> dbStats </code> is less than <code class="leafygreen-ui-1l06pbn"> freeSpaceTargetMB </code> , background compaction has no effect. </p> </dd> </dl> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Syntax <a class="headerlink leafygreen-ui-1kepx47" href="#syntax" 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="syntax"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> The command has the following syntax: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.runCommand(\n {\n autoCompact: &lt;boolean&gt;,\n freeSpaceTargetMB: &lt;int&gt;, // Optional\n runOnce: &lt;boolean&gt;, // Optional\n }\n)","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">runCommand</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">autoCompact</span>: &lt;<!-- -->boolean<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">freeSpaceTargetMB</span>: &lt;<!-- -->int<!-- -->&gt;<!-- -->,<!-- --> <span class="lg-highlight-comment">// Optional</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">runOnce</span>: &lt;<!-- -->boolean<!-- -->&gt;<!-- -->,<!-- --> <span class="lg-highlight-comment">// Optional</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->}</td></tr><tr class=""><td class="leafygreen-ui-7razhx">)</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> </section> <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"> This command is available in deployments hosted in the following environments: </p> <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> <div class="leafygreen-ui-15mdk4" role="note"> <h2 class="leafygreen-ui-6n7b7d"> Note </h2> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> This command is currently not supported in MongoDB Atlas clusters. </p> </div> </div> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Command Fields <a class="headerlink leafygreen-ui-1kepx47" href="#command-fields" 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="command-fields"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> The command can take the following optional fields: </p> <div class="leafygreen-ui-skkc39" tabindex="0"> <table class="leafygreen-ui-hr8lsv"> <colgroup> <col style="width:20%"/> <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> Field </div> </div> </th> <th class="leafygreen-ui-13uteka" role="columnheader" scope="col"> <div class="leafygreen-ui-ui0te9"> <div> Type </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> <code class="leafygreen-ui-1l06pbn"> freeSpaceTargetMB </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Integer </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <p class="leafygreen-ui-1kp3ins"> Optional. Specifies the minimum amount of storage space, in megabytes, that must be recoverable for compaction to proceed. </p> <p class="leafygreen-ui-1kp3ins"> <em> Default: </em> 20 </p> </div> </div> </td> </tr> <tr class=""> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> runOnce </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> boolean </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <p class="leafygreen-ui-1kp3ins"> Optional. If <code class="leafygreen-ui-1l06pbn"> runOnce </code> is set to <code class="leafygreen-ui-1l06pbn"> true </code> , background compaction runs only once through every collection on the node. </p> <p class="leafygreen-ui-1kp3ins"> If <code class="leafygreen-ui-1l06pbn"> runOnce </code> is set to <code class="leafygreen-ui-1l06pbn"> false </code> , background compaction runs continuously on all collections in the database. If a collection fails to compact while <code class="leafygreen-ui-1l06pbn"> runOnce </code> is <code class="leafygreen-ui-1l06pbn"> false </code> , MongoDB temporarily skips that collection and continues compacting the remaining collections. MongoDB attempts to compact the failed collection again after approximately one day. </p> </div> </div> </td> </tr> </tbody> </table> </div> <span class="leafygreen-ui-1qnjd6d" id="std-label-autocompact-authentication"> </span> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Required Privileges <a class="headerlink leafygreen-ui-1kepx47" href="#required-privileges" 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="required-privileges"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> For clusters enforcing <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/authentication/#std-label-authentication"> authentication </a> , you must authenticate as a user with the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/privilege-actions/#mongodb-authaction-compact"> <code class="leafygreen-ui-1l06pbn"> compact </code> </a> privilege action on the cluster. The <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/built-in-roles/#mongodb-authrole-hostManager"> <code class="leafygreen-ui-1l06pbn"> hostManager </code> </a> role provides the required privileges for running <code class="leafygreen-ui-1l06pbn"> autoCompact </code> . </p> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Behavior <a class="headerlink leafygreen-ui-1kepx47" href="#behavior" 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="behavior"> </div> </a> </h2> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Blocking <a class="headerlink leafygreen-ui-1kepx47" href="#blocking" 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="blocking"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> Although the <code class="leafygreen-ui-1l06pbn"> autoCompact </code> command itself doesn't block reads and writes, background compaction applies the same blocking behavior as the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/command/compact/#mongodb-dbcommand-dbcmd.compact"> <code class="leafygreen-ui-1l06pbn"> compact </code> </a> command. </p> <p class="leafygreen-ui-1kp3ins"> Additionally, MongoDB returns an error if you call <code class="leafygreen-ui-1l06pbn"> autoCompact </code> while background compaction is active. If you need to restart <code class="leafygreen-ui-1l06pbn"> autoCompact </code> or run it again with different options, you must first stop the current background compaction operation: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.runCommand( { autoCompact: false } )","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">runCommand</span>( <!-- -->{ <span class="lg-highlight-attr">autoCompact</span>: <span class="lg-highlight-literal">false</span> } )</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"> Once the current background compaction is disabled, you can restart <code class="leafygreen-ui-1l06pbn"> autoCompact </code> with the new configuration. </p> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Excluded Collections <a class="headerlink leafygreen-ui-1kepx47" href="#excluded-collections" 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="excluded-collections"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> If an <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-oplog"> oplog </a> exists, MongoDB excludes it from background compaction. </p> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Performance Considerations <a class="headerlink leafygreen-ui-1kepx47" href="#performance-considerations" 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="performance-considerations"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> We recommend running <code class="leafygreen-ui-1l06pbn"> autoCompact </code> during periods of low traffic. </p> <p class="leafygreen-ui-1kp3ins"> Compaction regularly checkpoints the database, which can lead to synchronization overhead. On high-traffic databases, this can potentially delay or prevent operational tasks such as taking backups. To avoid unexpected disruptions, disable compaction before taking a backup. </p> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Replica Sets <a class="headerlink leafygreen-ui-1kepx47" href="#replica-sets" 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="replica-sets"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> You can run background compaction on collections and indexes that are stored in a replica set. However, note the following considerations: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> The primary node does not replicate the <code class="leafygreen-ui-1l06pbn"> autoCompact </code> command to the secondary nodes. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> A secondary node can replicate data while background compaction is running. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Reads and writes are permitted while background compaction is running. </p> </li> </ul> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Sharded Clusters <a class="headerlink leafygreen-ui-1kepx47" href="#sharded-clusters" 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="sharded-clusters"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> <code class="leafygreen-ui-1l06pbn"> autoCompact </code> only applies to <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> instances. In a sharded environment, run <code class="leafygreen-ui-1l06pbn"> autoCompact </code> on each shard separately. </p> <p class="leafygreen-ui-1kp3ins"> You cannot run <code class="leafygreen-ui-1l06pbn"> autoCompact </code> against a <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongos/#mongodb-binary-bin.mongos"> <code class="leafygreen-ui-1l06pbn"> mongos </code> </a> instance. </p> </section> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Learn More <a class="headerlink leafygreen-ui-1kepx47" href="#learn-more" 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="learn-more"> </div> </a> </h2> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/command/compact/#mongodb-dbcommand-dbcmd.compact"> <code class="leafygreen-ui-1l06pbn"> compact </code> </a> </p> </li> </ul> </section> </section>
https://www.mongodb.com/docs/manual/reference/command/fsyncUnlock/
<section> <h1 class="contains-headerlink leafygreen-ui-41fr9s" weight="medium"> fsyncUnlock <a class="headerlink leafygreen-ui-1kepx47" href="#fsyncunlock" 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="fsyncunlock"> </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="#definition" target="_self"> <span> Definition </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#compatibility" target="_self"> <span> Compatibility </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#syntax" target="_self"> <span> Syntax </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#results" target="_self"> <span> Results </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#examples" target="_self"> <span> Examples </span> </a> </li> </ul> </div> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Definition <a class="headerlink leafygreen-ui-1kepx47" href="#definition" 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="definition"> </div> </a> </h2> <dl class="dbcommand"> <dt> <code class="leafygreen-ui-1l06pbn"> fsyncUnlock </code> <a class="headerlink leafygreen-ui-1kepx47" href="#mongodb-dbcommand-dbcmd.fsyncUnlock" title="Permalink to this definition"> <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="mongodb-dbcommand-dbcmd.fsyncUnlock"> </div> </a> </dt> <dd> <p class="leafygreen-ui-1kp3ins"> Reduces the lock count on the server or cluster. To enable write operations, the lock count must be zero. </p> <p class="leafygreen-ui-1kp3ins"> Starting in MongoDB 7.1 (also available starting in 7.0.2, 6.0.11, and 5.0.22) <!-- --> the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/command/fsync/#mongodb-dbcommand-dbcmd.fsync"> <code class="leafygreen-ui-1l06pbn"> fsync </code> </a> and <code class="leafygreen-ui-1l06pbn"> fsyncUnlock </code> commands <!-- --> can run on <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongos/#std-program-mongos"> <code class="leafygreen-ui-1l06pbn"> mongos </code> </a> to lock and unlock a sharded cluster. </p> <p class="leafygreen-ui-1kp3ins"> Use this command to unblock writes after you finish a backup operation. </p> <div class="leafygreen-ui-85da11" role="note"> <h2 class="leafygreen-ui-1ac4g5h"> Important </h2> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> Servers maintain an fsync lock count. The <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/command/fsync/#mongodb-dbcommand-dbcmd.fsync"> <code class="leafygreen-ui-1l06pbn"> fsync </code> </a> command with the <code class="leafygreen-ui-1l06pbn"> lock </code> field set to <code class="leafygreen-ui-1l06pbn"> true </code> increments the lock count while the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-dbcommand-dbcmd.fsyncUnlock" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> fsyncUnlock </code> </span> </a> command decrements it. To enable writes on a locked server or cluster, call the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-dbcommand-dbcmd.fsyncUnlock" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> fsyncUnlock </code> </span> </a> command until the lock count reaches zero. </p> </div> </div> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-dbcommand-dbcmd.fsyncUnlock" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> fsyncUnlock </code> </span> </a> is an administrative operation. Typically you will use <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-dbcommand-dbcmd.fsyncUnlock" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> fsyncUnlock </code> </span> </a> following a database <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/backups/#std-label-backup-methods"> backup operation <!-- --> . </a> </p> <div class="leafygreen-ui-13vw3ie" role="note"> <h2 class="leafygreen-ui-1fn4p2b"> Tip </h2> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> In <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/mongodb-shell/#std-program-mongosh" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongosh </code> </span> </a> , this command can also be run through the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/db.fsyncUnlock/#mongodb-method-db.fsyncUnlock"> <code class="leafygreen-ui-1l06pbn"> db.fsyncUnlock() </code> </a> helper method <!-- --> . </p> <p class="leafygreen-ui-1kp3ins"> Helper methods are convenient for <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/mongodb-shell/#std-program-mongosh" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongosh </code> </span> </a> users, but they may not return the same level of information as database commands. In cases where the convenience is not needed or the additional return fields are required, use the database command. </p> </div> </div> </dd> </dl> </section> <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"> This command is available in 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> <div class="leafygreen-ui-85da11" role="note"> <h2 class="leafygreen-ui-1ac4g5h"> Important </h2> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> This command is not supported in M0, M2, and M5 clusters. For more information, see <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/atlas/unsupported-commands/" target="_self"> <span> Unsupported Commands <!-- --> . </span> </a> </p> </div> </div> <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"> Syntax <a class="headerlink leafygreen-ui-1kepx47" href="#syntax" 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="syntax"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> The command has the following syntax: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.adminCommand(\n {\n fsyncUnlock: 1,\n comment: &lt;any&gt;\n }\n)","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">adminCommand</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">fsyncUnlock</span>: <span class="lg-highlight-number">1</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">comment</span>: &lt;<!-- -->any<!-- -->&gt;</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->}</td></tr><tr class=""><td class="leafygreen-ui-7razhx">)</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 <code class="leafygreen-ui-1l06pbn"> comment </code> field is optional and may contain a comment of any data type. </p> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Results <a class="headerlink leafygreen-ui-1kepx47" href="#results" 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="results"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> The operation returns a document with the following fields: </p> <div class="leafygreen-ui-skkc39" tabindex="0"> <table class="leafygreen-ui-hr8lsv"> <colgroup> <col style="width:30%"/> <col style="width:70%"/> </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> Field </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> <code class="leafygreen-ui-1l06pbn"> info </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Information on the status of the operation </div> </div> </td> </tr> <tr class=""> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> lockCount </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> The number of locks remaining on the instance after the operation. </div> </div> </td> </tr> <tr class=""> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> ok </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> The status code. </div> </div> </td> </tr> </tbody> </table> </div> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Examples <a class="headerlink leafygreen-ui-1kepx47" href="#examples" 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="examples"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> Consider a situation where <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/db.fsyncLock/#mongodb-method-db.fsyncLock"> <code class="leafygreen-ui-1l06pbn"> db.fsyncLock() </code> </a> has been issued two times. The following <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-dbcommand-dbcmd.fsyncUnlock" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> fsyncUnlock </code> </span> </a> operation reduces the locks taken by <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/db.fsyncLock/#mongodb-method-db.fsyncLock"> <code class="leafygreen-ui-1l06pbn"> db.fsyncLock() </code> </a> by 1: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.adminCommand( { fsyncUnlock: 1 } )","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">adminCommand</span>( <!-- -->{ <span class="lg-highlight-attr">fsyncUnlock</span>: <span class="lg-highlight-number">1</span> } )</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 operation returns the following document: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ \"info\" : \"fsyncUnlock completed\", \"lockCount\" : NumberLong(1), \"ok\" : 1 }","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-1q4bxgx" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"info"</span> <!-- -->: <span class="lg-highlight-string">"fsyncUnlock completed"</span>, <span class="lg-highlight-string">"lockCount"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">NumberLong</span>(<span class="lg-highlight-number">1</span>)<!-- -->, <span class="lg-highlight-string">"ok"</span> <!-- -->: <span class="lg-highlight-number">1</span> }</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"> As the <code class="leafygreen-ui-1l06pbn"> lockCount </code> is greater than 0, the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> instance is locked against writes. To unlock the instance for writes, run the unlock operation again: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.adminCommand( { fsyncUnlock: 1 } )","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">adminCommand</span>( <!-- -->{ <span class="lg-highlight-attr">fsyncUnlock</span>: <span class="lg-highlight-number">1</span> } )</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 operation returns the following document: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ \"info\" : \"fsyncUnlock completed\", \"lockCount\" : NumberLong(0), \"ok\" : 1 }","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-1q4bxgx" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"info"</span> <!-- -->: <span class="lg-highlight-string">"fsyncUnlock completed"</span>, <span class="lg-highlight-string">"lockCount"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">NumberLong</span>(<span class="lg-highlight-number">0</span>)<!-- -->, <span class="lg-highlight-string">"ok"</span> <!-- -->: <span class="lg-highlight-number">1</span> }</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 <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> instance is unlocked for writes. </p> </section> </section>
https://www.mongodb.com/docs/manual/reference/operator/aggregation/indexStats/
<section> <h1 class="contains-headerlink leafygreen-ui-41fr9s" weight="medium"> $indexStats (aggregation) <a class="headerlink leafygreen-ui-1kepx47" href="#-indexstats--aggregation-" 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="-indexstats--aggregation-"> </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="#definition" target="_self"> <span> Definition </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#behavior" target="_self"> <span> Behavior </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#example" target="_self"> <span> Example </span> </a> </li> </ul> </div> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Definition <a class="headerlink leafygreen-ui-1kepx47" href="#definition" 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="definition"> </div> </a> </h2> <dl class="pipeline"> <dt> <code class="leafygreen-ui-1l06pbn"> $indexStats </code> <a class="headerlink leafygreen-ui-1kepx47" href="#mongodb-pipeline-pipe.-indexStats" title="Permalink to this definition"> <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="mongodb-pipeline-pipe.-indexStats"> </div> </a> </dt> <dd> <p class="leafygreen-ui-1kp3ins"> Returns statistics regarding the use of each index for the collection. If running with <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/authorization/#std-label-authorization"> access control </a> , authenticate as a user with at least the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/built-in-roles/#mongodb-authrole-clusterMonitor"> <code class="leafygreen-ui-1l06pbn"> clusterMonitor </code> </a> role. </p> <p class="leafygreen-ui-1kp3ins"> The <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-pipeline-pipe.-indexStats" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $indexStats </code> </span> </a> stage takes an empty document and has the following syntax: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ $indexStats: { } }","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">{ <span class="lg-highlight-attr">$indexStats</span>: <!-- -->{ <!-- -->} }</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"> For each index, the return document includes the following fields: </p> <div class="leafygreen-ui-skkc39" tabindex="0"> <table class="leafygreen-ui-hr8lsv"> <colgroup> <col style="width:30%"/> <col style="width:70%"/> </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> Output Field </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> <code class="leafygreen-ui-1l06pbn"> name </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Index name. </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="#std-label-indexStats-output-key" target="_self"> <span> key </span> </a> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <span class="leafygreen-ui-1qnjd6d" id="std-label-indexStats-output-key"> </span> <p class="leafygreen-ui-1kp3ins"> Index key specification. </p> <p class="leafygreen-ui-1kp3ins"> See also: <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-indexStats-output-spec" target="_self"> <span> spec <!-- --> . </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="#std-label-indexStats-output-host" target="_self"> <span> host </span> </a> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <span class="leafygreen-ui-1qnjd6d" id="std-label-indexStats-output-host"> </span> <p class="leafygreen-ui-1kp3ins"> The hostname and port of the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> process. </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="#std-label-indexStats-output-accesses" target="_self"> <span> accesses </span> </a> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <span class="leafygreen-ui-1qnjd6d" id="std-label-indexStats-output-accesses"> </span> <p class="leafygreen-ui-1kp3ins"> Statistics on the index use: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <code class="leafygreen-ui-1l06pbn"> ops </code> is the number of operations that used the index. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <code class="leafygreen-ui-1l06pbn"> since </code> is the time from which MongoDB gathered the statistics. </p> </li> </ul> </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="#std-label-indexStats-output-shard" target="_self"> <span> shard </span> </a> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <span class="leafygreen-ui-1qnjd6d" id="std-label-indexStats-output-shard"> </span> <p class="leafygreen-ui-1kp3ins"> The name of the shard associated with the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-indexStats-output-host" target="_self"> <span> host </span> </a> </p> <p class="leafygreen-ui-1kp3ins"> Only available for a sharded cluster. </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="#std-label-indexStats-output-spec" target="_self"> <span> spec </span> </a> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <span class="leafygreen-ui-1qnjd6d" id="std-label-indexStats-output-spec"> </span> <p class="leafygreen-ui-1kp3ins"> The full specification document for the index, which includes the index key and index properties. </p> <p class="leafygreen-ui-1kp3ins"> The index option <code class="leafygreen-ui-1l06pbn"> hidden </code> is only included if the value is <code class="leafygreen-ui-1l06pbn"> true </code> . </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="#std-label-indexStats-output-building" target="_self"> <span> building </span> </a> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <span class="leafygreen-ui-1qnjd6d" id="std-label-indexStats-output-building"> </span> <p class="leafygreen-ui-1kp3ins"> Indicates if the index is currently being built. </p> <p class="leafygreen-ui-1kp3ins"> Only available if <code class="leafygreen-ui-1l06pbn"> true </code> . </p> </div> </div> </td> </tr> </tbody> </table> </div> </dd> </dl> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Behavior <a class="headerlink leafygreen-ui-1kepx47" href="#behavior" 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="behavior"> </div> </a> </h2> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Accesses Field <a class="headerlink leafygreen-ui-1kepx47" href="#accesses-field" 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="accesses-field"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> The statistics reported by the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-indexStats-output-accesses" target="_self"> <span> accesses </span> </a> field only apply to the node where the query is being run and only include index access driven by user requests. It does not include internal operations like deletion via <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/index-ttl/"> TTL Indexes </a> or chunk split and migration operations. </p> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Restrictions <a class="headerlink leafygreen-ui-1kepx47" href="#restrictions" 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="restrictions"> </div> </a> </h3> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <code class="leafygreen-ui-1l06pbn"> $indexStats </code> must be the first stage in an aggregation pipeline. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <code class="leafygreen-ui-1l06pbn"> $indexStats </code> is not allowed in <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/transactions/"> transactions <!-- --> . </a> </p> </li> </ul> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Index Statistics Reset Considerations <a class="headerlink leafygreen-ui-1kepx47" href="#index-statistics-reset-considerations" 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="index-statistics-reset-considerations"> </div> </a> </h3> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Statistics for an index reset on <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> restart or index drop and recreation. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Modification of an existing index (see <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/command/collMod/#mongodb-collflag-index"> <code class="leafygreen-ui-1l06pbn"> collMod </code> </a> command) resets the statistics for that index. </p> </li> </ul> </section> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Example <a class="headerlink leafygreen-ui-1kepx47" href="#example" 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="example"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> For example, a collection <code class="leafygreen-ui-1l06pbn"> orders </code> contains the following documents: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.orders.insertMany( [\n { _id : 1, item : \"abc\", price : 12, quantity : 2, type: \"apparel\" },\n { _id : 2, item : \"jkl\", price : 20, quantity : 1, type: \"electronics\" },\n { _id : 3, item : \"abc\", price : 10, quantity : 5, type: \"apparel\" }\n] )","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><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">orders</span>.<span class="lg-highlight-title lg-highlight-function">insertMany</span>( <!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <!-- -->_id <!-- -->: <span class="lg-highlight-number">1</span>, <!-- -->item <!-- -->: <span class="lg-highlight-string">"abc"</span>, <!-- -->price <!-- -->: <span class="lg-highlight-number">12</span>, <!-- -->quantity <!-- -->: <span class="lg-highlight-number">2</span>, <span class="lg-highlight-attr">type</span>: <span class="lg-highlight-string">"apparel"</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <!-- -->_id <!-- -->: <span class="lg-highlight-number">2</span>, <!-- -->item <!-- -->: <span class="lg-highlight-string">"jkl"</span>, <!-- -->price <!-- -->: <span class="lg-highlight-number">20</span>, <!-- -->quantity <!-- -->: <span class="lg-highlight-number">1</span>, <span class="lg-highlight-attr">type</span>: <span class="lg-highlight-string">"electronics"</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <!-- -->_id <!-- -->: <span class="lg-highlight-number">3</span>, <!-- -->item <!-- -->: <span class="lg-highlight-string">"abc"</span>, <!-- -->price <!-- -->: <span class="lg-highlight-number">10</span>, <!-- -->quantity <!-- -->: <span class="lg-highlight-number">5</span>, <span class="lg-highlight-attr">type</span>: <span class="lg-highlight-string">"apparel"</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">] )</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"> Create the following two indexes on the collection: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.orders.createIndex( { item: 1, quantity: 1 } )\n\ndb.orders.createIndex( { type: 1, item: 1 } )\n\ndb.orders.createIndex(\n { price: 1 },\n { partialFilterExpression: { type: \"apparel\" } }\n)","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">orders</span>.<span class="lg-highlight-title lg-highlight-function">createIndex</span>( <!-- -->{ <span class="lg-highlight-attr">item</span>: <span class="lg-highlight-number">1</span>, <span class="lg-highlight-attr">quantity</span>: <span class="lg-highlight-number">1</span> } )</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><div class="leafygreen-ui-ihxujy"></div></td></tr><tr class=""><td class="leafygreen-ui-7razhx">db.<span class="lg-highlight-property">orders</span>.<span class="lg-highlight-title lg-highlight-function">createIndex</span>( <!-- -->{ <span class="lg-highlight-attr">type</span>: <span class="lg-highlight-number">1</span>, <span class="lg-highlight-attr">item</span>: <span class="lg-highlight-number">1</span> } )</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><div class="leafygreen-ui-ihxujy"></div></td></tr><tr class=""><td class="leafygreen-ui-7razhx">db.<span class="lg-highlight-property">orders</span>.<span class="lg-highlight-title lg-highlight-function">createIndex</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">price</span>: <span class="lg-highlight-number">1</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">partialFilterExpression</span>: <!-- -->{ <span class="lg-highlight-attr">type</span>: <span class="lg-highlight-string">"apparel"</span> } }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">)</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"> Run some queries against the collection: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.orders.find( { type: \"apparel\"} )\ndb.orders.find( { item: \"abc\" } ).sort( { quantity: 1 } )\ndb.orders.find( { price: { $gt: 10 } } )","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">orders</span>.<span class="lg-highlight-title lg-highlight-function">find</span>( <!-- -->{ <span class="lg-highlight-attr">type</span>: <span class="lg-highlight-string">"apparel"</span>} )</td></tr><tr class=""><td class="leafygreen-ui-7razhx">db.<span class="lg-highlight-property">orders</span>.<span class="lg-highlight-title lg-highlight-function">find</span>( <!-- -->{ <span class="lg-highlight-attr">item</span>: <span class="lg-highlight-string">"abc"</span> } ).<span class="lg-highlight-title lg-highlight-function">sort</span>( <!-- -->{ <span class="lg-highlight-attr">quantity</span>: <span class="lg-highlight-number">1</span> } )</td></tr><tr class=""><td class="leafygreen-ui-7razhx">db.<span class="lg-highlight-property">orders</span>.<span class="lg-highlight-title lg-highlight-function">find</span>( <!-- -->{ <span class="lg-highlight-attr">price</span>: <!-- -->{ <span class="lg-highlight-attr">$gt</span>: <span class="lg-highlight-number">10</span> } } )</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"> To view statistics on the index use on the <code class="leafygreen-ui-1l06pbn"> orders </code> collection, run the following aggregation operation: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.orders.aggregate( [ { $indexStats: { } } ] )","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">orders</span>.<span class="lg-highlight-title lg-highlight-function">aggregate</span>( <!-- -->[ <!-- -->{ <span class="lg-highlight-attr">$indexStats</span>: <!-- -->{ <!-- -->} } ] )</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 operation returns a document that contains usage statistics for each index: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"[\n {\n name: 'type_1_item_1',\n key: { type: 1, item: 1 },\n host: 'examplehost.local:27018',\n accesses: { ops: Long(\"1\"), since: ISODate(\"2024-05-02T15:07:21.420Z\") },\n shard: \"shardA\",\n spec: { v: 2, key: { type: 1, item: 1 }, name: 'type_1_item_1' }\n },\n {\n name: 'item_1_quantity_1',\n key: { item: 1, quantity: 1 },\n host: 'examplehost.local:27018',\n accesses: { ops: Long(\"1\"), since: ISODate(\"2024-05-02T15:07:21.254Z\") },\n shard: \"shardA\",\n spec: { v: 2, key: { item: 1, quantity: 1 }, name: 'item_1_quantity_1' }\n },\n {\n name: '_id_',\n key: { _id: 1 },\n host: 'examplehost.local:27018',\n accesses: { ops: Long(\"0\"), since: ISODate(\"2024-05-02T15:07:13.274Z\") },\n shard: \"shardA\",\n spec: { v: 2, key: { _id: 1 }, name: '_id_' }\n },\n {\n name: 'price_1',\n key: { price: 1 },\n host: 'examplehost.local:27018',\n accesses: { ops: Long(\"0\"), since: ISODate(\"2024-05-02T15:07:54.847Z\") },\n shard: \"shardA\",\n spec: {\n v: 2,\n key: { price: 1 },\n name: 'price_1',\n partialFilterExpression: { type: 'apparel' }\n }\n }\n]","programmingLanguage":"JavaScript"} </script> <div class="css-1lju8ps"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-tyg50d"> <pre class="leafygreen-ui-1453az5" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">name</span>: <span class="lg-highlight-string">'type_1_item_1'</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">key</span>: <!-- -->{ <span class="lg-highlight-attr">type</span>: <span class="lg-highlight-number">1</span>, <span class="lg-highlight-attr">item</span>: <span class="lg-highlight-number">1</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">host</span>: <span class="lg-highlight-string">'examplehost.local:27018'</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">accesses</span>: <!-- -->{ <span class="lg-highlight-attr">ops</span>: <span class="lg-highlight-title lg-highlight-class">Long</span>(<span class="lg-highlight-string">"1"</span>)<!-- -->, <span class="lg-highlight-attr">since</span>: <span class="lg-highlight-title lg-highlight-class">ISODate</span>(<span class="lg-highlight-string">"2024-05-02T15:07:21.420Z"</span>) }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">shard</span>: <span class="lg-highlight-string">"shardA"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">spec</span>: <!-- -->{ <span class="lg-highlight-attr">v</span>: <span class="lg-highlight-number">2</span>, <span class="lg-highlight-attr">key</span>: <!-- -->{ <span class="lg-highlight-attr">type</span>: <span class="lg-highlight-number">1</span>, <span class="lg-highlight-attr">item</span>: <span class="lg-highlight-number">1</span> }<!-- -->, <span class="lg-highlight-attr">name</span>: <span class="lg-highlight-string">'type_1_item_1'</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">name</span>: <span class="lg-highlight-string">'item_1_quantity_1'</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">key</span>: <!-- -->{ <span class="lg-highlight-attr">item</span>: <span class="lg-highlight-number">1</span>, <span class="lg-highlight-attr">quantity</span>: <span class="lg-highlight-number">1</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">host</span>: <span class="lg-highlight-string">'examplehost.local:27018'</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">accesses</span>: <!-- -->{ <span class="lg-highlight-attr">ops</span>: <span class="lg-highlight-title lg-highlight-class">Long</span>(<span class="lg-highlight-string">"1"</span>)<!-- -->, <span class="lg-highlight-attr">since</span>: <span class="lg-highlight-title lg-highlight-class">ISODate</span>(<span class="lg-highlight-string">"2024-05-02T15:07:21.254Z"</span>) }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">shard</span>: <span class="lg-highlight-string">"shardA"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">spec</span>: <!-- -->{ <span class="lg-highlight-attr">v</span>: <span class="lg-highlight-number">2</span>, <span class="lg-highlight-attr">key</span>: <!-- -->{ <span class="lg-highlight-attr">item</span>: <span class="lg-highlight-number">1</span>, <span class="lg-highlight-attr">quantity</span>: <span class="lg-highlight-number">1</span> }<!-- -->, <span class="lg-highlight-attr">name</span>: <span class="lg-highlight-string">'item_1_quantity_1'</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">name</span>: <span class="lg-highlight-string">'_id_'</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">key</span>: <!-- -->{ <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">1</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">host</span>: <span class="lg-highlight-string">'examplehost.local:27018'</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">accesses</span>: <!-- -->{ <span class="lg-highlight-attr">ops</span>: <span class="lg-highlight-title lg-highlight-class">Long</span>(<span class="lg-highlight-string">"0"</span>)<!-- -->, <span class="lg-highlight-attr">since</span>: <span class="lg-highlight-title lg-highlight-class">ISODate</span>(<span class="lg-highlight-string">"2024-05-02T15:07:13.274Z"</span>) }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">shard</span>: <span class="lg-highlight-string">"shardA"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">spec</span>: <!-- -->{ <span class="lg-highlight-attr">v</span>: <span class="lg-highlight-number">2</span>, <span class="lg-highlight-attr">key</span>: <!-- -->{ <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">1</span> }<!-- -->, <span class="lg-highlight-attr">name</span>: <span class="lg-highlight-string">'_id_'</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">name</span>: <span class="lg-highlight-string">'price_1'</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">key</span>: <!-- -->{ <span class="lg-highlight-attr">price</span>: <span class="lg-highlight-number">1</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">host</span>: <span class="lg-highlight-string">'examplehost.local:27018'</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">accesses</span>: <!-- -->{ <span class="lg-highlight-attr">ops</span>: <span class="lg-highlight-title lg-highlight-class">Long</span>(<span class="lg-highlight-string">"0"</span>)<!-- -->, <span class="lg-highlight-attr">since</span>: <span class="lg-highlight-title lg-highlight-class">ISODate</span>(<span class="lg-highlight-string">"2024-05-02T15:07:54.847Z"</span>) }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">shard</span>: <span class="lg-highlight-string">"shardA"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">spec</span>: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">v</span>: <span class="lg-highlight-number">2</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">key</span>: <!-- -->{ <span class="lg-highlight-attr">price</span>: <span class="lg-highlight-number">1</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">name</span>: <span class="lg-highlight-string">'price_1'</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">partialFilterExpression</span>: <!-- -->{ <span class="lg-highlight-attr">type</span>: <span class="lg-highlight-string">'apparel'</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">]</td></tr></tbody></table></code></pre> </div> </div> </div> </section> </section>
https://www.mongodb.com/docs/manual/core/replica-set-elections/
<section> <h1 class="contains-headerlink leafygreen-ui-41fr9s" weight="medium"> Replica Set Elections <a class="headerlink leafygreen-ui-1kepx47" href="#replica-set-elections" 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="replica-set-elections"> </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="#factors-and-conditions-that-affect-elections" target="_self"> <span> Factors and Conditions that Affect Elections </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#voting-members" target="_self"> <span> Voting Members </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#non-voting-members" target="_self"> <span> Non-Voting Members </span> </a> </li> </ul> </div> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-replica-set"> Replica sets </a> use elections to determine which set member will become <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-primary"> primary </a> . Replica sets can trigger an election in response to a variety of events, such as: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Adding a new node to the replica set, </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/rs.initiate/#mongodb-method-rs.initiate"> <code class="leafygreen-ui-1l06pbn"> initiating a replica set </code> , </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> performing replica set maintenance using methods such as <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/rs.stepDown/#mongodb-method-rs.stepDown"> <code class="leafygreen-ui-1l06pbn"> rs.stepDown() </code> </a> or <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/rs.reconfig/#mongodb-method-rs.reconfig"> <code class="leafygreen-ui-1l06pbn"> rs.reconfig() </code> </a> , and </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-secondary"> secondary </a> members losing connectivity to the primary for more than the configured <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/replica-configuration/#mongodb-rsconf-rsconf.settings.electionTimeoutMillis"> <code class="leafygreen-ui-1l06pbn"> timeout </code> </a> (10 seconds by default). </p> </li> </ul> <p class="leafygreen-ui-1kp3ins"> In the following diagram, the primary node was unavailable for longer than the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/replica-configuration/#mongodb-rsconf-rsconf.settings.electionTimeoutMillis"> <code class="leafygreen-ui-1l06pbn"> configured timeout </code> </a> and triggers the <a class="leafygreen-ui-tqgtui" href="/docs/manual/replication/#std-label-replication-auto-failover"> automatic failover </a> process. One of the remaining secondaries calls for an election to select a new primary and automatically resume normal operations. </p> <div class="css-18h91be ej97su30"> <div role="button" tabindex="-1"> <img alt="Diagram of an election of a new primary. In a three member replica set with two secondaries, the primary becomes unreachable. The loss of a primary triggers an election where one of the secondaries becomes the new primary" class="leafygreen-ui-1qnf57e" height="500" src="/docs/manual/images/replica-set-trigger-election.bakedsvg.svg" style="--border-color:#C1C7C6" width="660"/> <div class="css-19pi7x2 ej97su31" style="--color:#444"> click to enlarge </div> </div> </div> <p class="leafygreen-ui-1kp3ins"> The replica set cannot process write operations until the election completes successfully. The replica set can continue to serve read queries if such queries are configured to <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/read-preference/#std-label-replica-set-read-preference"> run on secondaries <!-- --> . </a> </p> <p class="leafygreen-ui-1kp3ins"> The median time before a cluster elects a new primary should not typically exceed 12 seconds, assuming default <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/replica-configuration/#mongodb-rsconf-rsconf.settings"> <code class="leafygreen-ui-1l06pbn"> replica configuration settings </code> </a> . This includes time required to mark the primary as <a class="leafygreen-ui-tqgtui" href="/docs/manual/replication/#std-label-replication-auto-failover"> unavailable </a> and call and complete an <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-replica-set-elections" target="_self"> <span> election </span> </a> . You can tune this time period by modifying the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/replica-configuration/#mongodb-rsconf-rsconf.settings.electionTimeoutMillis"> <code class="leafygreen-ui-1l06pbn"> settings.electionTimeoutMillis </code> </a> replication configuration option. Factors such as network latency may extend the time required for replica set elections to complete, which in turn affects the amount of time your cluster may operate without a primary. These factors are dependent on your particular cluster architecture. </p> <p class="leafygreen-ui-1kp3ins"> Your application connection logic should include tolerance for automatic failovers and the subsequent elections. MongoDB drivers can detect the loss of the primary and automatically <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/retryable-writes/#std-label-retryable-writes"> retry certain write operations </a> a single time, providing additional built-in handling of automatic failovers and elections: </p> <p class="leafygreen-ui-1kp3ins"> Compatible drivers enable retryable writes by default </p> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Factors and Conditions that Affect Elections <a class="headerlink leafygreen-ui-1kepx47" href="#factors-and-conditions-that-affect-elections" 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="factors-and-conditions-that-affect-elections"> </div> </a> </h2> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Replication Election Protocol <a class="headerlink leafygreen-ui-1kepx47" href="#replication-election-protocol" 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="replication-election-protocol"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> Replication <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/replica-configuration/#mongodb-rsconf-rsconf.protocolVersion"> <code class="leafygreen-ui-1l06pbn"> protocolVersion: 1 </code> </a> reduces replica set failover time and accelerate the detection of multiple simultaneous primaries. </p> <p class="leafygreen-ui-1kp3ins"> You can use <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/replica-configuration/#mongodb-rsconf-rsconf.settings.catchUpTimeoutMillis"> <code class="leafygreen-ui-1l06pbn"> catchUpTimeoutMillis </code> </a> to prioritize between faster failovers and preservation of <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/write-concern/#mongodb-writeconcern-writeconcern.-number-"> <code class="leafygreen-ui-1l06pbn"> w:1 </code> </a> writes. </p> <p class="leafygreen-ui-1kp3ins"> For more information on <code class="leafygreen-ui-1l06pbn"> pv1 </code> , see <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/replica-set-protocol-versions/"> Self-Managed Replica Set Protocol Version <!-- --> . </a> </p> <span class="leafygreen-ui-1qnjd6d" id="std-label-replica-set-heartbeats"> </span> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Heartbeats <a class="headerlink leafygreen-ui-1kepx47" href="#heartbeats" 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="heartbeats"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> Replica set members send heartbeats (pings) to each other every two seconds. If a heartbeat does not return within 10 seconds, the other members mark the delinquent member as inaccessible. </p> <span class="leafygreen-ui-1qnjd6d" id="std-label-rs-election-priority"> </span> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Member Priority <a class="headerlink leafygreen-ui-1kepx47" href="#member-priority" 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="member-priority"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> After a replica set has a stable primary, the election algorithm will make a "best-effort" attempt to have the secondary with the highest <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/replica-configuration/#mongodb-rsconf-rsconf.members-n-.priority"> <code class="leafygreen-ui-1l06pbn"> priority </code> </a> available call an election. Member priority affects both the timing and the outcome of elections; secondaries with higher priority call elections relatively sooner than secondaries with lower priority, and are also more likely to win. However, a lower priority instance can be elected as primary for brief periods, even if a higher priority secondary is available. Replica set members continue to call elections until the highest priority member available becomes primary. </p> <p class="leafygreen-ui-1kp3ins"> Members with a priority value of <code class="leafygreen-ui-1l06pbn"> 0 </code> cannot become primary and do not seek election. For details, see <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/replica-set-priority-0-member/"> Priority 0 Replica Set Members <!-- --> . </a> </p> <span class="leafygreen-ui-1qnjd6d" id="std-label-rs-election-mirrored-reads"> </span> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Mirrored Reads <a class="headerlink leafygreen-ui-1kepx47" href="#mirrored-reads" 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="mirrored-reads"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> MongoDB provides <a class="leafygreen-ui-tqgtui" href="/docs/manual/replication/#std-label-mirrored-reads"> mirrored reads </a> to pre-warm electable secondary members' cache with the most recently accessed data. With mirrored reads, the primary can mirror a subset of <a class="leafygreen-ui-tqgtui" href="/docs/manual/replication/#std-label-mirrored-reads-supported-operations"> operations </a> that it receives and send them to a subset of electable secondaries. Pre-warming the cache of a secondary can help restore performance more quickly after an election. </p> <p class="leafygreen-ui-1kp3ins"> For details, see <a class="leafygreen-ui-tqgtui" href="/docs/manual/replication/#std-label-mirrored-reads"> Mirrored Reads <!-- --> . </a> </p> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Loss of a Data Center <a class="headerlink leafygreen-ui-1kepx47" href="#loss-of-a-data-center" 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="loss-of-a-data-center"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> With a distributed replica set, the loss of a data center may affect the ability of the remaining members in other data center or data centers to elect a primary. </p> <p class="leafygreen-ui-1kp3ins"> If possible, distribute the replica set members across data centers to maximize the likelihood that even with a loss of a data center, one of the remaining replica set members can become the new primary. </p> <div class="leafygreen-ui-13vw3ie" role="note"> <h2 class="leafygreen-ui-1fn4p2b"> Tip </h2> <h3 class="leafygreen-ui-144d5kf"> <strong> See also: </strong> </h3> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/replica-set-architecture-geographically-distributed/"> Replica Sets Distributed Across Two or More Data Centers </a> </p> </div> </div> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Network Partition <a class="headerlink leafygreen-ui-1kepx47" href="#network-partition" 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="network-partition"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> A <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-network-partition"> network partition </a> may segregate a primary into a partition with a minority of nodes. When the primary detects that it can only see a minority of voting nodes in the replica set, the primary steps down and becomes a secondary. Independently, a member in the partition that can communicate with a <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/command/replSetGetStatus/#mongodb-data-replSetGetStatus.majorityVoteCount"> <code class="leafygreen-ui-1l06pbn"> majority </code> </a> of the voting nodes (including itself) holds an election to become the new primary. </p> </section> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Voting Members <a class="headerlink leafygreen-ui-1kepx47" href="#voting-members" 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="voting-members"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> The replica set member configuration setting <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/replica-configuration/#mongodb-rsconf-rsconf.members-n-.votes"> <code class="leafygreen-ui-1l06pbn"> members[n].votes </code> </a> and member <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/command/replSetGetStatus/#mongodb-data-replSetGetStatus.members-n-.state"> <code class="leafygreen-ui-1l06pbn"> state </code> </a> determine whether a member votes in an election. </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> All replica set members that have their <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/replica-configuration/#mongodb-rsconf-rsconf.members-n-.votes"> <code class="leafygreen-ui-1l06pbn"> members[n].votes </code> </a> setting equal to 1 vote in elections. To exclude a member from voting in an <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-election"> election </a> , change the value of the member's <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/replica-configuration/#mongodb-rsconf-rsconf.members-n-.votes"> <code class="leafygreen-ui-1l06pbn"> members[n].votes </code> </a> configuration to <code class="leafygreen-ui-1l06pbn"> 0 </code> . </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Non-voting (i.e. <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/replica-configuration/#mongodb-rsconf-rsconf.members-n-.votes"> <code class="leafygreen-ui-1l06pbn"> votes </code> </a> is <code class="leafygreen-ui-1l06pbn"> 0 </code> ) members must have <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/replica-configuration/#mongodb-rsconf-rsconf.members-n-.priority"> <code class="leafygreen-ui-1l06pbn"> priority </code> </a> of 0. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Members with <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/replica-configuration/#mongodb-rsconf-rsconf.members-n-.priority"> <code class="leafygreen-ui-1l06pbn"> priority </code> </a> greater than 0 cannot have 0 <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/replica-configuration/#mongodb-rsconf-rsconf.members-n-.votes"> <code class="leafygreen-ui-1l06pbn"> votes </code> . </a> </p> </li> </ul> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Only voting members in the following states are eligible to vote: </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/replica-states/#mongodb-replstate-replstate.PRIMARY"> <code class="leafygreen-ui-1l06pbn"> PRIMARY </code> </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/replica-states/#mongodb-replstate-replstate.SECONDARY"> <code class="leafygreen-ui-1l06pbn"> SECONDARY </code> </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/replica-states/#mongodb-replstate-replstate.STARTUP2"> <code class="leafygreen-ui-1l06pbn"> STARTUP2 </code> </a> (unless the member was newly added to the replica set) </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/replica-states/#mongodb-replstate-replstate.RECOVERING"> <code class="leafygreen-ui-1l06pbn"> RECOVERING </code> </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/replica-states/#mongodb-replstate-replstate.ARBITER"> <code class="leafygreen-ui-1l06pbn"> ARBITER </code> </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/replica-states/#mongodb-replstate-replstate.ROLLBACK"> <code class="leafygreen-ui-1l06pbn"> ROLLBACK </code> </a> </p> </li> </ul> </li> </ul> <div class="leafygreen-ui-13vw3ie" role="note"> <h2 class="leafygreen-ui-1fn4p2b"> Tip </h2> <h3 class="leafygreen-ui-144d5kf"> <strong> See also: </strong> </h3> <div class="leafygreen-ui-9mycqc"> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/command/replSetGetStatus/#mongodb-data-replSetGetStatus.votingMembersCount"> <code class="leafygreen-ui-1l06pbn"> replSetGetStatus.votingMembersCount </code> </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/command/replSetGetStatus/#mongodb-data-replSetGetStatus.writableVotingMembersCount"> <code class="leafygreen-ui-1l06pbn"> replSetGetStatus.writableVotingMembersCount </code> </a> </p> </li> </ul> </div> </div> <span class="leafygreen-ui-1qnjd6d" id="std-label-replica-set-non-voting-configuration"> </span> <span class="leafygreen-ui-1qnjd6d" id="std-label-replica-set-non-voting-members"> </span> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Non-Voting Members <a class="headerlink leafygreen-ui-1kepx47" href="#non-voting-members" 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="non-voting-members"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> Although non-voting members do not vote in elections, these members hold copies of the replica set's data and can accept read operations from client applications. </p> <p class="leafygreen-ui-1kp3ins"> Because a replica set can have up to <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/limits/#mongodb-limit-Number-of-Members-of-a-Replica-Set"> 50 members </a> , but only <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/limits/#mongodb-limit-Number-of-Voting-Members-of-a-Replica-Set"> 7 voting members </a> , non-voting members allow a replica set to have more than seven members. </p> <p class="leafygreen-ui-1kp3ins"> Non-voting (i.e. <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/replica-configuration/#mongodb-rsconf-rsconf.members-n-.votes"> <code class="leafygreen-ui-1l06pbn"> votes </code> </a> is <code class="leafygreen-ui-1l06pbn"> 0 </code> ) members must have <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/replica-configuration/#mongodb-rsconf-rsconf.members-n-.priority"> <code class="leafygreen-ui-1l06pbn"> priority </code> </a> of 0. </p> <p class="leafygreen-ui-1kp3ins"> For instance, the following nine-member replica set has seven voting members and two non-voting members. </p> <div class="figure css-5vkxs0" style="width:700px"> <img alt="Diagram of a 9 member replica set with the maximum of 7 voting members." class="leafygreen-ui-1qnf57e" height="280" src="/docs/manual/images/replica-set-only-seven-voting-members.bakedsvg.svg" style="--border-color:#C1C7C6" width="740"/> </div> <p class="leafygreen-ui-1kp3ins"> A non-voting member has both <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/replica-configuration/#mongodb-rsconf-rsconf.members-n-.votes"> <code class="leafygreen-ui-1l06pbn"> votes </code> </a> and <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/replica-configuration/#mongodb-rsconf-rsconf.members-n-.priority"> <code class="leafygreen-ui-1l06pbn"> priority </code> </a> equal to <code class="leafygreen-ui-1l06pbn"> 0 </code> : </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{\n \"_id\" : &lt;num&gt;,\n \"host\" : &lt;hostname:port&gt;,\n \"arbiterOnly\" : false,\n \"buildIndexes\" : true,\n \"hidden\" : false,\n \"priority\" : 0,\n \"tags\" : {\n\n },\n \"secondaryDelaySecs\" : NumberLong(0),\n \"votes\" : 0\n}","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"_id"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"host"</span> <!-- -->: &lt;<span class="lg-highlight-attr">hostname</span>:<!-- -->port<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"arbiterOnly"</span> <!-- -->: <span class="lg-highlight-literal">false</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"buildIndexes"</span> <!-- -->: <span class="lg-highlight-literal">true</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"hidden"</span> <!-- -->: <span class="lg-highlight-literal">false</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"priority"</span> <!-- -->: <span class="lg-highlight-number">0</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"tags"</span> <!-- -->: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><div class="leafygreen-ui-ihxujy"></div></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->}<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"secondaryDelaySecs"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">NumberLong</span>(<span class="lg-highlight-number">0</span>)<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"votes"</span> <!-- -->: <span class="lg-highlight-number">0</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx">}</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-85da11" role="note"> <h2 class="leafygreen-ui-1ac4g5h"> Important </h2> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> Do <strong> not </strong> alter the number of votes to control which members will become primary. Instead, modify the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/replica-configuration/#mongodb-rsconf-rsconf.members-n-.priority"> <code class="leafygreen-ui-1l06pbn"> members[n].priority </code> </a> option. <em> Only </em> alter the number of votes in exceptional cases. For example, to permit more than seven members. </p> </div> </div> <p class="leafygreen-ui-1kp3ins"> To configure a non-voting member, see <a class="leafygreen-ui-tqgtui" href="/docs/manual/tutorial/configure-a-non-voting-replica-set-member/"> Configure a Non-Voting Self-Managed Replica Set Member <!-- --> . </a> </p> </section> </section>
https://www.mongodb.com/docs/manual/reference/method/db.fsyncUnlock/
<section> <h1 class="contains-headerlink leafygreen-ui-41fr9s" weight="medium"> db.fsyncUnlock() <a class="headerlink leafygreen-ui-1kepx47" href="#db.fsyncunlock--" 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.fsyncunlock--"> </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="#definition" target="_self"> <span> Definition </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#compatibility" target="_self"> <span> Compatibility </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#compatibility-with-wiredtiger" target="_self"> <span> Compatibility with WiredTiger </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#example" target="_self"> <span> Example </span> </a> </li> </ul> </div> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Definition <a class="headerlink leafygreen-ui-1kepx47" href="#definition" 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="definition"> </div> </a> </h2> <dl class="method"> <dt> <code class="leafygreen-ui-1l06pbn"> db.fsyncUnlock() </code> <a class="headerlink leafygreen-ui-1kepx47" href="#mongodb-method-db.fsyncUnlock" title="Permalink to this definition"> <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="mongodb-method-db.fsyncUnlock"> </div> </a> </dt> <dd> <p class="leafygreen-ui-1kp3ins"> Reduces the lock count on the server to renable write operations. </p> <p class="leafygreen-ui-1kp3ins"> Starting in MongoDB 7.1 (also available starting in 7.0.2, 6.0.11, and 5.0.22) <!-- --> the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/db.fsyncLock/#mongodb-method-db.fsyncLock"> <code class="leafygreen-ui-1l06pbn"> db.fsyncLock() </code> </a> and <code class="leafygreen-ui-1l06pbn"> db.fsyncUnlock() </code> methods <!-- --> can run on <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongos/#std-program-mongos"> <code class="leafygreen-ui-1l06pbn"> mongos </code> </a> to lock and unlock a sharded cluster. </p> <div class="leafygreen-ui-85da11" role="note"> <h2 class="leafygreen-ui-1ac4g5h"> Important </h2> <h3 class="leafygreen-ui-144d5kf"> <strong> mongosh Method </strong> </h3> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> This page documents a <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/mongodb-shell/#mongodb-binary-bin.mongosh" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongosh </code> </span> </a> method. This is <em> not </em> the documentation for database commands or language-specific drivers, such as Node.js. </p> <p class="leafygreen-ui-1kp3ins"> For the database command, see the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/command/fsyncUnlock/#mongodb-dbcommand-dbcmd.fsyncUnlock"> <code class="leafygreen-ui-1l06pbn"> fsyncUnlock </code> </a> command <!-- --> . </p> <p class="leafygreen-ui-1kp3ins"> For MongoDB API drivers, refer to the language-specific <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/drivers/" target="_self"> <span> MongoDB driver documentation <!-- --> . </span> </a> </p> </div> </div> <p class="leafygreen-ui-1kp3ins"> Servers maintain an fsync lock count. The <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/db.fsyncLock/#mongodb-method-db.fsyncLock"> <code class="leafygreen-ui-1l06pbn"> fsyncLock() </code> </a> method increments the lock count while the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-method-db.fsyncUnlock" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> fsyncUnlock() </code> </span> </a> method decrements it. To unlock writes on a server or cluster, call the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-method-db.fsyncUnlock" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> fsyncUnlock() </code> </span> </a> method until the lock count reaches zero. </p> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-method-db.fsyncUnlock" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> db.fsyncUnlock() </code> </span> </a> is an administrative operation. Use this method to unlock a server or cluster after a <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/backups/#std-label-backup-methods"> backup operation </a> </p> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-method-db.fsyncUnlock" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> db.fsyncUnlock() </code> </span> </a> has the syntax: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.fsyncUnlock()","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">fsyncUnlock</span>(<!-- -->)</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 operation returns a document with the following fields: </p> <div class="leafygreen-ui-skkc39" tabindex="0"> <table class="leafygreen-ui-hr8lsv"> <colgroup> <col style="width:30%"/> <col style="width:70%"/> </colgroup> <thead class="leafygreen-ui-a9ho40"> </thead> <tbody> <tr class=""> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> info </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Information on the status of the operation. </div> </div> </td> </tr> <tr class=""> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> lockCount </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> The number of locks remaining on the instance after the operation. </div> </div> </td> </tr> <tr class=""> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> ok </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> The status code. </div> </div> </td> </tr> </tbody> </table> </div> <p class="leafygreen-ui-1kp3ins"> The <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-method-db.fsyncUnlock" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> db.fsyncUnlock() </code> </span> </a> method wraps the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/command/fsyncUnlock/#mongodb-dbcommand-dbcmd.fsyncUnlock"> <code class="leafygreen-ui-1l06pbn"> fsyncUnlock </code> </a> command. </p> </dd> </dl> </section> <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"> This method is available in 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> <div class="leafygreen-ui-85da11" role="note"> <h2 class="leafygreen-ui-1ac4g5h"> Important </h2> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> This command is not supported in M0, M2, and M5 clusters. For more information, see <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/atlas/unsupported-commands/" target="_self"> <span> Unsupported Commands <!-- --> . </span> </a> </p> </div> </div> <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"> Compatibility with WiredTiger <a class="headerlink leafygreen-ui-1kepx47" href="#compatibility-with-wiredtiger" 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-with-wiredtiger"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/db.fsyncLock/#mongodb-method-db.fsyncLock"> <code class="leafygreen-ui-1l06pbn"> db.fsyncLock() </code> </a> ensures that the data files are safe to copy using low-level backup utilities such as <code class="leafygreen-ui-1l06pbn"> cp </code> , <code class="leafygreen-ui-1l06pbn"> scp </code> , or <code class="leafygreen-ui-1l06pbn"> tar </code> . A <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> started using the copied files contains user-written data that is indistinguishable from the user-written data on the locked <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> . </a> </p> <p class="leafygreen-ui-1kp3ins"> The data files of a locked <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> may change due to operations such as <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/journaling/#std-label-journal-process"> journaling syncs </a> or <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/wiredtiger/#std-label-storage-wiredtiger-checkpoints"> WiredTiger snapshots </a> . While this has no affect on the logical data (e.g. data accessed by clients), some backup utilities may detect these changes and emit warnings or fail with errors. For more information on MongoDB- recommended backup utilities and procedures, see <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/backups/"> Backup Methods for a Self-Managed Deployment <!-- --> . </a> </p> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Example <a class="headerlink leafygreen-ui-1kepx47" href="#example" 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="example"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> Consider a situation where <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/db.fsyncLock/#mongodb-method-db.fsyncLock"> <code class="leafygreen-ui-1l06pbn"> db.fsyncLock() </code> </a> has been issued two times. The following <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-method-db.fsyncUnlock" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> db.fsyncUnlock() </code> </span> </a> operation reduces the locks taken by <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/db.fsyncLock/#mongodb-method-db.fsyncLock"> <code class="leafygreen-ui-1l06pbn"> db.fsyncLock() </code> </a> by 1: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.fsyncUnlock()","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">fsyncUnlock</span>(<!-- -->)</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 operation returns the following document: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ \"info\" : \"fsyncUnlock completed\", \"lockCount\" : NumberLong(1), \"ok\" : 1 }","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-1q4bxgx" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"info"</span> <!-- -->: <span class="lg-highlight-string">"fsyncUnlock completed"</span>, <span class="lg-highlight-string">"lockCount"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">NumberLong</span>(<span class="lg-highlight-number">1</span>)<!-- -->, <span class="lg-highlight-string">"ok"</span> <!-- -->: <span class="lg-highlight-number">1</span> }</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"> As the <code class="leafygreen-ui-1l06pbn"> lockCount </code> is greater than 0, the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> instance is locked against writes. To unlock the instance for writes, run <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/db.fsyncLock/#mongodb-method-db.fsyncLock"> <code class="leafygreen-ui-1l06pbn"> db.fsyncLock() </code> </a> again: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.fsyncUnlock()","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">fsyncUnlock</span>(<!-- -->)</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 operation returns the following document: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ \"info\" : \"fsyncUnlock completed\", \"lockCount\" : NumberLong(0), \"ok\" : 1 }","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-1q4bxgx" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"info"</span> <!-- -->: <span class="lg-highlight-string">"fsyncUnlock completed"</span>, <span class="lg-highlight-string">"lockCount"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">NumberLong</span>(<span class="lg-highlight-number">0</span>)<!-- -->, <span class="lg-highlight-string">"ok"</span> <!-- -->: <span class="lg-highlight-number">1</span> }</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 <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#std-program-mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> instance is unlocked for writes. </p> </section> </section>
https://www.mongodb.com/docs/manual/reference/operator/aggregation/in/
<section> <h1 class="contains-headerlink leafygreen-ui-41fr9s" weight="medium"> $in (aggregation) <a class="headerlink leafygreen-ui-1kepx47" href="#-in--aggregation-" 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="-in--aggregation-"> </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="#definition" target="_self"> <span> Definition </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#behavior" target="_self"> <span> Behavior </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#example" target="_self"> <span> Example </span> </a> </li> </ul> </div> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Definition <a class="headerlink leafygreen-ui-1kepx47" href="#definition" 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="definition"> </div> </a> </h2> <dl class="expression"> <dt> <code class="leafygreen-ui-1l06pbn"> $in </code> <a class="headerlink leafygreen-ui-1kepx47" href="#mongodb-expression-exp.-in" title="Permalink to this definition"> <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="mongodb-expression-exp.-in"> </div> </a> </dt> <dd> <p class="leafygreen-ui-1kp3ins"> Returns a boolean indicating whether a specified value is in an array. </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"> This document describes the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-expression-exp.-in" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $in </code> </span> </a> aggregation operator. For the <code class="leafygreen-ui-1l06pbn"> $in </code> query operator, see <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/query/in/"> $in <!-- --> . </a> </p> </div> </div> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-expression-exp.-in" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $in </code> </span> </a> has the following <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/#std-label-agg-quick-ref-operator-expressions"> operator expression syntax <!-- --> : </a> </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ $in: [ &lt;expression&gt;, &lt;array&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">{ <span class="lg-highlight-attr">$in</span>: <!-- -->[ &lt;<!-- -->expression<!-- -->&gt;<!-- -->,<!-- --> <span class="lg-highlight-tag lg-highlight-xml">&lt;</span><span class="lg-highlight-name lg-highlight-tag lg-highlight-xml">array</span><span class="lg-highlight-tag lg-highlight-xml"> </span><span class="lg-highlight-attr lg-highlight-tag lg-highlight-xml">expression</span><span class="lg-highlight-tag lg-highlight-xml">&gt;</span><span class="lg-highlight-xml"> ] }</span></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:40%"/> <col style="width:60%"/> </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> Operand </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> <code class="leafygreen-ui-1l06pbn"> &lt;expression&gt; </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Any valid expression <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/#std-label-aggregation-expressions"> expression <!-- --> . </a> </div> </div> </td> </tr> <tr class=""> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> &lt;array expression&gt; </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Any valid <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/#std-label-aggregation-expressions"> expression </a> that resolves to an array. </div> </div> </td> </tr> </tbody> </table> </div> <p class="leafygreen-ui-1kp3ins"> Unlike the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/query/in/#mongodb-query-op.-in"> <code class="leafygreen-ui-1l06pbn"> $in </code> </a> query operator, the aggregation <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-expression-exp.-in" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $in </code> </span> </a> operator does not support matching by <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/query/in/#std-label-query-in-regex"> regular expressions <!-- --> . </a> </p> <div class="leafygreen-ui-skkc39" tabindex="0"> <table class="leafygreen-ui-hr8lsv"> <colgroup> <col style="width:95%"/> <col style="width:5%"/> </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> Example </div> </div> </th> <th class="leafygreen-ui-13uteka" role="columnheader" scope="col"> <div class="leafygreen-ui-ui0te9"> <div> Results </div> </div> </th> </tr> </thead> <tbody> <tr class="leafygreen-ui-15dvrnp"> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> { $in: [ 2, [ 1, 2, 3 ] ] } </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> true </code> </div> </div> </td> </tr> <tr class="leafygreen-ui-15dvrnp"> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> { $in: [ "abc", [ "xyz", "abc" ] ] } </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> true </code> </div> </div> </td> </tr> <tr class="leafygreen-ui-15dvrnp"> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> { $in: [ "xy", [ "xyz", "abc" ] ] } </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> false </code> </div> </div> </td> </tr> <tr class="leafygreen-ui-15dvrnp"> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> { $in: [ [ "a" ], [ "a" ] ] } </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> false </code> </div> </div> </td> </tr> <tr class="leafygreen-ui-15dvrnp"> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> { $in: [ [ "a" ], [ [ "a" ] ] ] } </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> true </code> </div> </div> </td> </tr> <tr class="leafygreen-ui-15dvrnp"> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> { $in: [ /^a/, [ "a" ] ] } </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> false </code> </div> </div> </td> </tr> <tr class="leafygreen-ui-15dvrnp"> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> { $in: [ /^a/, [ /^a/ ] ] } </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> true </code> </div> </div> </td> </tr> </tbody> </table> </div> </dd> </dl> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Behavior <a class="headerlink leafygreen-ui-1kepx47" href="#behavior" 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="behavior"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-expression-exp.-in" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $in </code> </span> </a> fails with an error in either of the following cases: if the $in expression is not given exactly two arguments, or if the second argument does not resolve to an array. </p> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Example <a class="headerlink leafygreen-ui-1kepx47" href="#example" 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="example"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> A collection named <code class="leafygreen-ui-1l06pbn"> fruit </code> has the following documents: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ \"_id\" : 1, \"location\" : \"24th Street\",\n \"in_stock\" : [ \"apples\", \"oranges\", \"bananas\" ] }\n{ \"_id\" : 2, \"location\" : \"36th Street\",\n \"in_stock\" : [ \"bananas\", \"pears\", \"grapes\" ] }\n{ \"_id\" : 3, \"location\" : \"82nd Street\",\n \"in_stock\" : [ \"cantaloupes\", \"watermelons\", \"apples\" ] }","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">1</span>, <span class="lg-highlight-string">"location"</span> <!-- -->: <span class="lg-highlight-string">"24th Street"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"in_stock"</span> <!-- -->: <!-- -->[ <span class="lg-highlight-string">"apples"</span>, <span class="lg-highlight-string">"oranges"</span>, <span class="lg-highlight-string">"bananas"</span> ] }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">2</span>, <span class="lg-highlight-string">"location"</span> <!-- -->: <span class="lg-highlight-string">"36th Street"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"in_stock"</span> <!-- -->: <!-- -->[ <span class="lg-highlight-string">"bananas"</span>, <span class="lg-highlight-string">"pears"</span>, <span class="lg-highlight-string">"grapes"</span> ] }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">3</span>, <span class="lg-highlight-string">"location"</span> <!-- -->: <span class="lg-highlight-string">"82nd Street"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"in_stock"</span> <!-- -->: <!-- -->[ <span class="lg-highlight-string">"cantaloupes"</span>, <span class="lg-highlight-string">"watermelons"</span>, <span class="lg-highlight-string">"apples"</span> ] }</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 aggregation operation looks at the <code class="leafygreen-ui-1l06pbn"> in_stock </code> array in each document and determines whether the string <code class="leafygreen-ui-1l06pbn"> bananas </code> is present. </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.fruit.aggregate([\n {\n $project: {\n \"store location\" : \"$location\",\n \"has bananas\" : {\n $in: [ \"bananas\", \"$in_stock\" ]\n }\n }\n }\n])","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">fruit</span>.<span class="lg-highlight-title lg-highlight-function">aggregate</span>(<!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">$project</span>: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"store location"</span> <!-- -->: <span class="lg-highlight-string">"$location"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"has bananas"</span> <!-- -->: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">$in</span>: <!-- -->[ <span class="lg-highlight-string">"bananas"</span>, <span class="lg-highlight-string">"$in_stock"</span> ]</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">])</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 operation returns the following results: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ \"_id\" : 1, \"store location\" : \"24th Street\", \"has bananas\" : true }\n{ \"_id\" : 2, \"store location\" : \"36th Street\", \"has bananas\" : true }\n{ \"_id\" : 3, \"store location\" : \"82nd Street\", \"has bananas\" : false }","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">1</span>, <span class="lg-highlight-string">"store location"</span> <!-- -->: <span class="lg-highlight-string">"24th Street"</span>, <span class="lg-highlight-string">"has bananas"</span> <!-- -->: <span class="lg-highlight-literal">true</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">2</span>, <span class="lg-highlight-string">"store location"</span> <!-- -->: <span class="lg-highlight-string">"36th Street"</span>, <span class="lg-highlight-string">"has bananas"</span> <!-- -->: <span class="lg-highlight-literal">true</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">3</span>, <span class="lg-highlight-string">"store location"</span> <!-- -->: <span class="lg-highlight-string">"82nd Street"</span>, <span class="lg-highlight-string">"has bananas"</span> <!-- -->: <span class="lg-highlight-literal">false</span> }</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> </section> </section>
https://www.mongodb.com/docs/manual/tutorial/force-member-to-be-primary/
<section> <h1 class="contains-headerlink leafygreen-ui-41fr9s" weight="medium"> Force a Self-Managed Replica Set Member to Become Primary <a class="headerlink leafygreen-ui-1kepx47" href="#force-a-self-managed-replica-set-member-to-become-primary" 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="force-a-self-managed-replica-set-member-to-become-primary"> </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="#overview" target="_self"> <span> Overview </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#consideration" target="_self"> <span> Consideration </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#procedures" target="_self"> <span> Procedures </span> </a> </li> </ul> </div> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Overview <a class="headerlink leafygreen-ui-1kepx47" href="#overview" 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="overview"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> You can force a <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-replica-set"> replica set </a> member to become <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-primary"> primary </a> by giving it a higher <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/replica-configuration/#mongodb-rsconf-rsconf.members-n-.priority"> <code class="leafygreen-ui-1l06pbn"> members[n].priority </code> </a> value than any other member in the set. </p> <p class="leafygreen-ui-1kp3ins"> Optionally, you also can force a member never to become primary by setting its <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/replica-configuration/#mongodb-rsconf-rsconf.members-n-.priority"> <code class="leafygreen-ui-1l06pbn"> members[n].priority </code> </a> value to <code class="leafygreen-ui-1l06pbn"> 0 </code> , which means the member can never seek <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/replica-set-elections/#std-label-replica-set-elections"> election </a> as primary. For more information, see <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/replica-set-priority-0-member/#std-label-replica-set-secondary-only-members"> Priority 0 Replica Set Members <!-- --> . </a> </p> <p class="leafygreen-ui-1kp3ins"> For more information on priorities, see <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/replica-configuration/#mongodb-rsconf-rsconf.members-n-.priority"> <code class="leafygreen-ui-1l06pbn"> members[n].priority </code> . </a> </p> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Consideration <a class="headerlink leafygreen-ui-1kepx47" href="#consideration" 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="consideration"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> A majority of the configured members of a replica set <em> must </em> be available for a set to reconfigure a set or elect a primary. See <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/replica-set-elections/"> Replica Set Elections </a> for more information. </p> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Procedures <a class="headerlink leafygreen-ui-1kepx47" href="#procedures" 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="procedures"> </div> </a> </h2> <div class="leafygreen-ui-15mdk4" role="note"> <h2 class="leafygreen-ui-6n7b7d"> Note </h2> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> When you step down a primary using <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/rs.stepDown/#mongodb-method-rs.stepDown"> <code class="leafygreen-ui-1l06pbn"> rs.stepDown() </code> </a> or <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/command/replSetStepDown/#mongodb-dbcommand-dbcmd.replSetStepDown"> <code class="leafygreen-ui-1l06pbn"> replSetStepDown </code> </a> without setting the <code class="leafygreen-ui-1l06pbn"> force </code> field to <code class="leafygreen-ui-1l06pbn"> true </code> , the stepped-down primary nominates an eligible secondary to call an election immediately. </p> </div> </div> <span class="leafygreen-ui-1qnjd6d" id="std-label-replica-set-force-member-to-be-primary-via-priority-setting"> </span> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Force a Member to be Primary by Setting its Priority High <a class="headerlink leafygreen-ui-1kepx47" href="#force-a-member-to-be-primary-by-setting-its-priority-high" 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="force-a-member-to-be-primary-by-setting-its-priority-high"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> This procedure assumes your current <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-primary"> primary </a> is <code class="leafygreen-ui-1l06pbn"> m1.example.net </code> and that you'd like to instead make <code class="leafygreen-ui-1l06pbn"> m3.example.net </code> primary. The procedure also assumes you have a three-member <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-replica-set"> replica set </a> with the configuration below. For more information on configurations, see <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/rs.reconfig/#std-label-replica-set-reconfiguration-usage"> Replica Set Configuration Use <!-- --> . </a> </p> <p class="leafygreen-ui-1kp3ins"> This procedure assumes this configuration: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{\n \"_id\" : \"rs\",\n \"version\" : 7,\n \"members\" : [\n {\n \"_id\" : 0,\n \"host\" : \"m1.example.net:27017\"\n },\n {\n \"_id\" : 1,\n \"host\" : \"m2.example.net:27017\"\n },\n {\n \"_id\" : 2,\n \"host\" : \"m3.example.net:27017\"\n }\n ]\n}","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-string">"rs"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"version"</span> <!-- -->: <span class="lg-highlight-number">7</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"members"</span> <!-- -->: <!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">0</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"host"</span> <!-- -->: <span class="lg-highlight-string">"m1.example.net:27017"</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">1</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"host"</span> <!-- -->: <span class="lg-highlight-string">"m2.example.net:27017"</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">2</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"host"</span> <!-- -->: <span class="lg-highlight-string">"m3.example.net:27017"</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> ]</td></tr><tr class=""><td class="leafygreen-ui-7razhx">}</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> <ol class="leafygreen-ui-rioki0" type="1"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> In a <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/mongodb-shell/#mongodb-binary-bin.mongosh" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongosh </code> </span> </a> session that is connected to the primary, use the following sequence of operations to make <code class="leafygreen-ui-1l06pbn"> m3.example.net </code> the primary: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"cfg = rs.conf()\ncfg.members[0].priority = 0.5\ncfg.members[1].priority = 0.5\ncfg.members[2].priority = 1\nrs.reconfig(cfg)","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">cfg <!-- -->= <!-- -->rs.<span class="lg-highlight-title lg-highlight-function">conf</span>(<!-- -->)</td></tr><tr class=""><td class="leafygreen-ui-7razhx">cfg.<span class="lg-highlight-property">members</span>[<span class="lg-highlight-number">0</span>].<span class="lg-highlight-property">priority</span> <!-- -->= <span class="lg-highlight-number">0.5</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx">cfg.<span class="lg-highlight-property">members</span>[<span class="lg-highlight-number">1</span>].<span class="lg-highlight-property">priority</span> <!-- -->= <span class="lg-highlight-number">0.5</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx">cfg.<span class="lg-highlight-property">members</span>[<span class="lg-highlight-number">2</span>].<span class="lg-highlight-property">priority</span> <!-- -->= <span class="lg-highlight-number">1</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx">rs.<span class="lg-highlight-title lg-highlight-function">reconfig</span>(<!-- -->cfg)</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 last statement calls <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/rs.reconfig/#mongodb-method-rs.reconfig"> <code class="leafygreen-ui-1l06pbn"> rs.reconfig() </code> </a> with the modified configuration document to configure <code class="leafygreen-ui-1l06pbn"> m3.example.net </code> to have a higher <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/replica-configuration/#mongodb-rsconf-rsconf.members-n-.priority"> <code class="leafygreen-ui-1l06pbn"> members[n].priority </code> </a> value than the other <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> instances. </p> <p class="leafygreen-ui-1kp3ins"> The following sequence of events occur: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <code class="leafygreen-ui-1l06pbn"> m3.example.net </code> and <code class="leafygreen-ui-1l06pbn"> m2.example.net </code> sync with <code class="leafygreen-ui-1l06pbn"> m1.example.net </code> (typically within 10 seconds). </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <code class="leafygreen-ui-1l06pbn"> m1.example.net </code> sees that it no longer has highest priority and, in most cases, steps down. <code class="leafygreen-ui-1l06pbn"> m1.example.net </code> <em> does not </em> step down if <code class="leafygreen-ui-1l06pbn"> m3.example.net </code> 's sync is far behind. In that case, <code class="leafygreen-ui-1l06pbn"> m1.example.net </code> waits until <code class="leafygreen-ui-1l06pbn"> m3.example.net </code> is within 10 seconds of its optime and then steps down. This minimizes the amount of time with no primary following failover. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> The step down forces an election in which <code class="leafygreen-ui-1l06pbn"> m3.example.net </code> becomes primary based on its <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/replica-configuration/#mongodb-rsconf-rsconf.members-n-.priority"> <code class="leafygreen-ui-1l06pbn"> priority </code> </a> setting. </p> </li> </ul> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Optionally, if <code class="leafygreen-ui-1l06pbn"> m3.example.net </code> is more than 10 seconds behind <code class="leafygreen-ui-1l06pbn"> m1.example.net </code> 's optime, and if you don't need to have a primary designated within 10 seconds, you can force <code class="leafygreen-ui-1l06pbn"> m1.example.net </code> to step down by running: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.adminCommand({replSetStepDown: 86400, force: 1})","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">adminCommand</span>(<!-- -->{<span class="lg-highlight-attr">replSetStepDown</span>: <span class="lg-highlight-number">86400</span>, <span class="lg-highlight-attr">force</span>: <span class="lg-highlight-number">1</span>})</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"> This prevents <code class="leafygreen-ui-1l06pbn"> m1.example.net </code> from being primary for 86,400 seconds (24 hours), even if there is no other member that can become primary. When <code class="leafygreen-ui-1l06pbn"> m3.example.net </code> catches up with <code class="leafygreen-ui-1l06pbn"> m1.example.net </code> it will become primary. </p> <p class="leafygreen-ui-1kp3ins"> If you later want to make <code class="leafygreen-ui-1l06pbn"> m1.example.net </code> primary again while it waits for <code class="leafygreen-ui-1l06pbn"> m3.example.net </code> to catch up, issue the following command to make <code class="leafygreen-ui-1l06pbn"> m1.example.net </code> seek election again: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"rs.freeze()","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">rs.<span class="lg-highlight-title lg-highlight-function">freeze</span>(<!-- -->)</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 <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/rs.freeze/#mongodb-method-rs.freeze"> <code class="leafygreen-ui-1l06pbn"> rs.freeze() </code> </a> provides a wrapper around the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/command/replSetFreeze/#mongodb-dbcommand-dbcmd.replSetFreeze"> <code class="leafygreen-ui-1l06pbn"> replSetFreeze </code> </a> database command. </p> </li> </ol> <span class="leafygreen-ui-1qnjd6d" id="std-label-replica-set-force-member-to-be-primary-via-dbcommands"> </span> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Force a Member to be Primary Using Database Commands <a class="headerlink leafygreen-ui-1kepx47" href="#force-a-member-to-be-primary-using-database-commands" 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="force-a-member-to-be-primary-using-database-commands"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> Consider a <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-replica-set"> replica set </a> with the following members: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <code class="leafygreen-ui-1l06pbn"> mdb0.example.net </code> - the current <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-primary"> primary <!-- --> . </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <code class="leafygreen-ui-1l06pbn"> mdb1.example.net </code> - a <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-secondary"> secondary <!-- --> . </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <code class="leafygreen-ui-1l06pbn"> mdb2.example.net </code> - a secondary . </p> </li> </ul> <p class="leafygreen-ui-1kp3ins"> To force a member to become primary use the following procedure: </p> <ol class="leafygreen-ui-rioki0" type="1"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> In <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/mongodb-shell/#mongodb-binary-bin.mongosh" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongosh </code> </span> </a> , run <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/rs.status/#mongodb-method-rs.status"> <code class="leafygreen-ui-1l06pbn"> rs.status() </code> </a> to ensure your replica set is running as expected. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> In a <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/mongodb-shell/#mongodb-binary-bin.mongosh" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongosh </code> </span> </a> session that is connected to the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> instance running on <code class="leafygreen-ui-1l06pbn"> mdb2.example.net </code> , freeze <code class="leafygreen-ui-1l06pbn"> mdb2.example.net </code> so that it does not attempt to become primary for 120 seconds. </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"rs.freeze(120)","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">rs.<span class="lg-highlight-title lg-highlight-function">freeze</span>(<span class="lg-highlight-number">120</span>)</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> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> In a <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/mongodb-shell/#mongodb-binary-bin.mongosh" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongosh </code> </span> </a> session that is connected to the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> running on <code class="leafygreen-ui-1l06pbn"> mdb0.example.net </code> , step down this instance that the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> is not eligible to become primary for 120 seconds: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"rs.stepDown(120)","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">rs.<span class="lg-highlight-title lg-highlight-function">stepDown</span>(<span class="lg-highlight-number">120</span>)</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"> <code class="leafygreen-ui-1l06pbn"> mdb1.example.net </code> becomes primary. </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"> During the transition, there is a short window where the set does not have a primary. </p> </div> </div> </li> </ol> <p class="leafygreen-ui-1kp3ins"> For more information, consider the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/rs.freeze/#mongodb-method-rs.freeze"> <code class="leafygreen-ui-1l06pbn"> rs.freeze() </code> </a> and <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/rs.stepDown/#mongodb-method-rs.stepDown"> <code class="leafygreen-ui-1l06pbn"> rs.stepDown() </code> </a> methods that wrap the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/command/replSetFreeze/#mongodb-dbcommand-dbcmd.replSetFreeze"> <code class="leafygreen-ui-1l06pbn"> replSetFreeze </code> </a> and <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/command/replSetStepDown/#mongodb-dbcommand-dbcmd.replSetStepDown"> <code class="leafygreen-ui-1l06pbn"> replSetStepDown </code> </a> commands. </p> </section> </section> </section>
https://www.mongodb.com/docs/manual/reference/method/rs.status/
<section> <h1 class="contains-headerlink leafygreen-ui-41fr9s" weight="medium"> rs.status() <a class="headerlink leafygreen-ui-1kepx47" href="#rs.status--" 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="rs.status--"> </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="#definition" target="_self"> <span> Definition </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#output" target="_self"> <span> Output </span> </a> </li> </ul> </div> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Definition <a class="headerlink leafygreen-ui-1kepx47" href="#definition" 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="definition"> </div> </a> </h2> <dl class="method"> <dt> <code class="leafygreen-ui-1l06pbn"> rs.status() </code> <a class="headerlink leafygreen-ui-1kepx47" href="#mongodb-method-rs.status" title="Permalink to this definition"> <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="mongodb-method-rs.status"> </div> </a> </dt> <dd> <p class="leafygreen-ui-1kp3ins"> Returns the replica set status from the point of view of the member where the method is run. </p> <div class="leafygreen-ui-85da11" role="note"> <h2 class="leafygreen-ui-1ac4g5h"> Important </h2> <h3 class="leafygreen-ui-144d5kf"> <strong> mongosh Method </strong> </h3> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> This page documents a <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/mongodb-shell/#mongodb-binary-bin.mongosh" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongosh </code> </span> </a> method. This is <em> not </em> the documentation for database commands or language-specific drivers, such as Node.js. </p> <p class="leafygreen-ui-1kp3ins"> For the database command, see the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/command/replSetGetStatus/#mongodb-dbcommand-dbcmd.replSetGetStatus"> <code class="leafygreen-ui-1l06pbn"> replSetGetStatus </code> </a> command <!-- --> . </p> <p class="leafygreen-ui-1kp3ins"> For MongoDB API drivers, refer to the language-specific <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/drivers/" target="_self"> <span> MongoDB driver documentation <!-- --> . </span> </a> </p> </div> </div> <p class="leafygreen-ui-1kp3ins"> This output reflects the current status of the replica set, using data derived from the heartbeat packets sent by the other members of the replica set. </p> </dd> </dl> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Output <a class="headerlink leafygreen-ui-1kepx47" href="#output" 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="output"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> For an example and details on the output, see <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/command/replSetGetStatus/#std-label-rs-status-output"> replSetGetStatus <!-- --> . </a> </p> <p class="leafygreen-ui-1kp3ins"> If you run the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/mongodb-shell/#mongodb-binary-bin.mongosh" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongosh </code> </span> </a> helper method <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-method-rs.status" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> rs.status() </code> </span> </a> (or the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/command/replSetGetStatus/#mongodb-dbcommand-dbcmd.replSetGetStatus"> <code class="leafygreen-ui-1l06pbn"> replSetGetStatus </code> </a> command) on a member during its <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/replica-set-sync/#std-label-replica-set-initial-sync"> initial sync </a> (i.e. <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/replica-states/#mongodb-replstate-replstate.STARTUP2"> <code class="leafygreen-ui-1l06pbn"> STARTUP2 </code> </a> state), the command returns <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/command/replSetGetStatus/#mongodb-data-replSetGetStatus.initialSyncStatus"> <code class="leafygreen-ui-1l06pbn"> replSetGetStatus.initialSyncStatus </code> </a> metrics. </p> <p class="leafygreen-ui-1kp3ins"> Once the member completes its initial sync, the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/command/replSetGetStatus/#mongodb-data-replSetGetStatus.initialSyncStatus"> <code class="leafygreen-ui-1l06pbn"> replSetGetStatus.initialSyncStatus </code> </a> metrics becomes unavailable. </p> </section> </section>
https://www.mongodb.com/docs/manual/reference/operator/projection/slice/
<section> <h1 class="contains-headerlink leafygreen-ui-41fr9s" weight="medium"> $slice (projection) <a class="headerlink leafygreen-ui-1kepx47" href="#-slice--projection-" 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="-slice--projection-"> </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="#definition" target="_self"> <span> Definition </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#syntax" target="_self"> <span> Syntax </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#behavior" target="_self"> <span> Behavior </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#examples" target="_self"> <span> Examples </span> </a> </li> </ul> </div> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Definition <a class="headerlink leafygreen-ui-1kepx47" href="#definition" 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="definition"> </div> </a> </h2> <dl class="projection"> <dt> <code class="leafygreen-ui-1l06pbn"> $slice </code> <a class="headerlink leafygreen-ui-1kepx47" href="#mongodb-projection-proj.-slice" title="Permalink to this definition"> <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="mongodb-projection-proj.-slice"> </div> </a> </dt> <dd> <p class="leafygreen-ui-1kp3ins"> The <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-projection-proj.-slice" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $slice </code> </span> </a> projection operator specifies the number of elements in an array to return in the query result. </p> <div class="leafygreen-ui-15mdk4" role="note"> <h2 class="leafygreen-ui-6n7b7d"> Note </h2> <h3 class="leafygreen-ui-144d5kf"> <strong> Disambiguation </strong> </h3> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> For information on limiting the size of an array during an update with <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/update/push/#mongodb-update-up.-push"> <code class="leafygreen-ui-1l06pbn"> $push </code> </a> , see the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/update/slice/#mongodb-update-up.-slice"> <code class="leafygreen-ui-1l06pbn"> $slice </code> </a> modifier instead. </p> <p class="leafygreen-ui-1kp3ins"> For aggregation operator, see <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/slice/#mongodb-expression-exp.-slice"> <code class="leafygreen-ui-1l06pbn"> $slice </code> </a> aggregation operator instead. </p> </div> </div> </dd> </dl> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Syntax <a class="headerlink leafygreen-ui-1kepx47" href="#syntax" 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="syntax"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> The <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-projection-proj.-slice" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $slice </code> </span> </a> has one of the following syntax forms: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.collection.find(\n &lt;query&gt;,\n { &lt;arrayfield&gt;: { $slice: &lt;number&gt; } }\n);","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">find</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> &lt;<!-- -->query<!-- -->&gt;<!-- -->,</td></tr><tr class="leafygreen-ui-1wr1lm6"><td class="leafygreen-ui-7razhx"> <!-- -->{ &lt;<!-- -->arrayField<!-- -->&gt;<!-- -->: <!-- -->{ <span class="lg-highlight-attr">$slice</span>: &lt;<!-- -->number<!-- -->&gt; <!-- -->} }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">)<!-- -->;</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"> or </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.collection.find(\n &lt;query&gt;,\n { &lt;arrayfield&gt;: { $slice: [ &lt;number&gt;, &lt;number&gt; ] } }\n);","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">find</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> &lt;<!-- -->query<!-- -->&gt;<!-- -->,</td></tr><tr class="leafygreen-ui-1wr1lm6"><td class="leafygreen-ui-7razhx"> <!-- -->{ &lt;<!-- -->arrayField<!-- -->&gt;<!-- -->: <!-- -->{ <span class="lg-highlight-attr">$slice</span>: <!-- -->[ &lt;<!-- -->number<!-- -->&gt;<!-- -->,<!-- --> <!-- -->&lt;<!-- -->number<!-- -->&gt; <!-- -->] } }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">)<!-- -->;</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"> <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> Value </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> <code class="leafygreen-ui-1l06pbn"> $slice: &lt;number&gt; </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <p class="leafygreen-ui-1kp3ins"> Specifies the number of elements to return in the <code class="leafygreen-ui-1l06pbn"> &lt;arrayField&gt; </code> . For <code class="leafygreen-ui-1l06pbn"> &lt;number&gt; </code> : </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Specify a positive number <code class="leafygreen-ui-1l06pbn"> n </code> to return the first <code class="leafygreen-ui-1l06pbn"> n </code> elements. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Specify a negative number <code class="leafygreen-ui-1l06pbn"> n </code> to return the last <code class="leafygreen-ui-1l06pbn"> n </code> elements. </p> </li> </ul> <p class="leafygreen-ui-1kp3ins"> If the <code class="leafygreen-ui-1l06pbn"> &lt;number&gt; </code> is greater than the number of array elements, the query returns all array elements. </p> </div> </div> </td> </tr> <tr class=""> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> $slice: [ &lt;number to skip&gt;, &lt;number to return&gt; ] </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <p class="leafygreen-ui-1kp3ins"> Specifies the number of elements to return in the <code class="leafygreen-ui-1l06pbn"> &lt;arrayField&gt; </code> after skipping the specified number of elements starting from the first element. You must specify both elements. </p> <p class="leafygreen-ui-1kp3ins"> For the <code class="leafygreen-ui-1l06pbn"> &lt;number to skip&gt; </code> : </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Specify a positive number <code class="leafygreen-ui-1l06pbn"> n </code> to skip <code class="leafygreen-ui-1l06pbn"> n </code> elements from the start of the array; i.e. 0th index position. Based on a zero-based array index, <code class="leafygreen-ui-1l06pbn"> 1 </code> indicates the starting position of the 2nd element, etc. If <code class="leafygreen-ui-1l06pbn"> n </code> is greater than the number of array elements, the query returns an empty array for the <code class="leafygreen-ui-1l06pbn"> &lt;arrayField&gt; </code> . </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Specify a negative number <code class="leafygreen-ui-1l06pbn"> n </code> to skip backward <code class="leafygreen-ui-1l06pbn"> n </code> elements from the start of the array; i.e. 0th index position Based on a zero-based array index (i.e. the first element is at index 0), <code class="leafygreen-ui-1l06pbn"> -1 </code> indicates the starting position of the last element, etc. If the absolute value of the negative number is greater than the number of array elements, the starting position is the start of the array. </p> </li> </ul> <p class="leafygreen-ui-1kp3ins"> For the <code class="leafygreen-ui-1l06pbn"> &lt;number to return&gt; </code> , you must specify a <em> positive </em> number <code class="leafygreen-ui-1l06pbn"> n </code> to return the next <code class="leafygreen-ui-1l06pbn"> n </code> elements, starting after skipping the specified number. </p> </div> </div> </td> </tr> </tbody> </table> </div> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Behavior <a class="headerlink leafygreen-ui-1kepx47" href="#behavior" 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="behavior"> </div> </a> </h2> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> <code class="leafygreen-ui-1l06pbn"> $slice </code> of Embedded Array <a class="headerlink leafygreen-ui-1kepx47" href="#-slice-of-embedded-array" 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="-slice-of-embedded-array"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> The <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-projection-proj.-slice" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $slice </code> </span> </a> projection of an array in an nested document no longer returns the other fields in the nested document when the projection is part of an inclusion projection. </p> <p class="leafygreen-ui-1kp3ins"> For example, consider a collection <code class="leafygreen-ui-1l06pbn"> inventory </code> with documents that contain a <code class="leafygreen-ui-1l06pbn"> size </code> field: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ item: \"socks\", qty: 100, details: { colors: [ \"blue\", \"red\" ], sizes: [ \"S\", \"M\", \"L\"] } }","programmingLanguage":"JavaScript"} </script> <div class="css-1lju8ps"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-tyg50d"> <pre class="leafygreen-ui-1agdxuk" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-attr">item</span>: <span class="lg-highlight-string">"socks"</span>, <span class="lg-highlight-attr">qty</span>: <span class="lg-highlight-number">100</span>, <span class="lg-highlight-attr">details</span>: <!-- -->{ <span class="lg-highlight-attr">colors</span>: <!-- -->[ <span class="lg-highlight-string">"blue"</span>, <span class="lg-highlight-string">"red"</span> ]<!-- -->, <span class="lg-highlight-attr">sizes</span>: <!-- -->[ <span class="lg-highlight-string">"S"</span>, <span class="lg-highlight-string">"M"</span>, <span class="lg-highlight-string">"L"</span>] } }</td></tr></tbody></table></code></pre> </div> </div> </div> <p class="leafygreen-ui-1kp3ins"> The following operation projects the <code class="leafygreen-ui-1l06pbn"> _id </code> field (by default), the <code class="leafygreen-ui-1l06pbn"> qty </code> field, and the <code class="leafygreen-ui-1l06pbn"> details </code> field with just the specified slice of the <code class="leafygreen-ui-1l06pbn"> colors </code> array: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.inventory.find( { }, { qty: 1, \"details.colors\": { $slice: 1 } } )","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-1q4bxgx" tabindex="0"><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">inventory</span>.<span class="lg-highlight-title lg-highlight-function">find</span>( <!-- -->{ <!-- -->}<!-- -->, <!-- -->{ <span class="lg-highlight-attr">qty</span>: <span class="lg-highlight-number">1</span>, <span class="lg-highlight-string">"details.colors"</span>: <!-- -->{ <span class="lg-highlight-attr">$slice</span>: <span class="lg-highlight-number">1</span> } } )</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"> That is, the operation returns the following document: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ \"_id\" : ObjectId(\"5ee92a6ec644acb6d13eedb1\"), \"qty\" : 100, \"details\" : { \"colors\" : [ \"blue\" ] } }","programmingLanguage":"JavaScript"} </script> <div class="css-1lju8ps"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-tyg50d"> <pre class="leafygreen-ui-1agdxuk" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">ObjectId</span>(<span class="lg-highlight-string">"5ee92a6ec644acb6d13eedb1"</span>)<!-- -->, <span class="lg-highlight-string">"qty"</span> <!-- -->: <span class="lg-highlight-number">100</span>, <span class="lg-highlight-string">"details"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-string">"colors"</span> <!-- -->: <!-- -->[ <span class="lg-highlight-string">"blue"</span> ] } }</td></tr></tbody></table></code></pre> </div> </div> </div> <p class="leafygreen-ui-1kp3ins"> If the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-projection-proj.-slice" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $slice </code> </span> </a> projection is part of an exclusion projection, the operation continues to return the other fields in the nested document. That is, the following projection is an exclusion projection. The projection excludes the <code class="leafygreen-ui-1l06pbn"> _id </code> field and the elements in the <code class="leafygreen-ui-1l06pbn"> colors </code> array that fall outside the specified slice and returns all other fields. </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.inventory.find( { }, { _id: 0, \"details.colors\": { $slice: 1 } } )","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-1q4bxgx" tabindex="0"><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">inventory</span>.<span class="lg-highlight-title lg-highlight-function">find</span>( <!-- -->{ <!-- -->}<!-- -->, <!-- -->{ <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">0</span>, <span class="lg-highlight-string">"details.colors"</span>: <!-- -->{ <span class="lg-highlight-attr">$slice</span>: <span class="lg-highlight-number">1</span> } } )</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> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ \"item\" : \"socks\", \"qty\" : 100, \"details\" : { \"colors\" : [ \"blue\" ], \"sizes\" : [ \"S\", \"M\", \"L\" ] } }","programmingLanguage":"JavaScript"} </script> <div class="css-1lju8ps"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-tyg50d"> <pre class="leafygreen-ui-1agdxuk" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"item"</span> <!-- -->: <span class="lg-highlight-string">"socks"</span>, <span class="lg-highlight-string">"qty"</span> <!-- -->: <span class="lg-highlight-number">100</span>, <span class="lg-highlight-string">"details"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-string">"colors"</span> <!-- -->: <!-- -->[ <span class="lg-highlight-string">"blue"</span> ]<!-- -->, <span class="lg-highlight-string">"sizes"</span> <!-- -->: <!-- -->[ <span class="lg-highlight-string">"S"</span>, <span class="lg-highlight-string">"M"</span>, <span class="lg-highlight-string">"L"</span> ] } }</td></tr></tbody></table></code></pre> </div> </div> </div> <p class="leafygreen-ui-1kp3ins"> The <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-projection-proj.-slice" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $slice </code> </span> </a> projection by itself is considered an exclusion. </p> <p class="leafygreen-ui-1kp3ins"> In previous versions, the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-projection-proj.-slice" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $slice </code> </span> </a> projection also include the other fields in the nested document regardless of whether the projection is an inclusion or an exclusion. </p> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> View Restriction <a class="headerlink leafygreen-ui-1kepx47" href="#view-restriction" 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="view-restriction"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/db.collection.find/#mongodb-method-db.collection.find"> <code class="leafygreen-ui-1l06pbn"> db.collection.find() </code> </a> operations on <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/views/#std-label-views-landing-page"> views </a> do not support <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-projection-proj.-slice" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $slice </code> </span> </a> projection operator. </p> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> <code class="leafygreen-ui-1l06pbn"> $ </code> Positional Operator and <code class="leafygreen-ui-1l06pbn"> $slice </code> Restriction <a class="headerlink leafygreen-ui-1kepx47" href="#--positional-operator-and--slice-restriction" 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="--positional-operator-and--slice-restriction"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/db.collection.find/#mongodb-method-db.collection.find"> <code class="leafygreen-ui-1l06pbn"> find </code> </a> and <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/db.collection.findAndModify/#mongodb-method-db.collection.findAndModify"> <code class="leafygreen-ui-1l06pbn"> findAndModify </code> </a> projection cannot include <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-projection-proj.-slice" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $slice </code> </span> </a> projection expression as part of a <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/projection/positional/#mongodb-projection-proj.-"> <code class="leafygreen-ui-1l06pbn"> $ </code> </a> projection expression. </p> <p class="leafygreen-ui-1kp3ins"> For example, the following operation is invalid: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.inventory.find( { \"instock.qty\": { $gt: 25 } }, { \"instock.$\": { $slice: 1 } } )","programmingLanguage":"JavaScript"} </script> <div class="css-1lju8ps"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-tyg50d"> <pre class="leafygreen-ui-1agdxuk" tabindex="0"><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">inventory</span>.<span class="lg-highlight-title lg-highlight-function">find</span>( <!-- -->{ <span class="lg-highlight-string">"instock.qty"</span>: <!-- -->{ <span class="lg-highlight-attr">$gt</span>: <span class="lg-highlight-number">25</span> } }<!-- -->, <!-- -->{ <span class="lg-highlight-string">"instock.$"</span>: <!-- -->{ <span class="lg-highlight-attr">$slice</span>: <span class="lg-highlight-number">1</span> } } )</td></tr></tbody></table></code></pre> </div> </div> </div> <p class="leafygreen-ui-1kp3ins"> In previous versions, MongoDB returns the first element ( <code class="leafygreen-ui-1l06pbn"> instock.$ </code> ) in the <code class="leafygreen-ui-1l06pbn"> instock </code> array that matches the query condition; i.e. the positional projection <code class="leafygreen-ui-1l06pbn"> "instock.$" </code> takes precedence and the <code class="leafygreen-ui-1l06pbn"> $slice:1 </code> is a no-op. The <code class="leafygreen-ui-1l06pbn"> "instock.$": { $slice: 1 } </code> does not exclude any other document field. </p> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Path Collision: <code class="leafygreen-ui-1l06pbn"> $slice </code> of an Array and Embedded Fields <a class="headerlink leafygreen-ui-1kepx47" href="#path-collision---slice-of-an-array-and-embedded-fields" 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="path-collision---slice-of-an-array-and-embedded-fields"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/db.collection.find/#mongodb-method-db.collection.find"> <code class="leafygreen-ui-1l06pbn"> find </code> </a> and <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/db.collection.findAndModify/#mongodb-method-db.collection.findAndModify"> <code class="leafygreen-ui-1l06pbn"> findAndModify </code> </a> projection cannot contain both a <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-projection-proj.-slice" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $slice </code> </span> </a> of an array and a field embedded in the array. </p> <p class="leafygreen-ui-1kp3ins"> For example, consider a collection <code class="leafygreen-ui-1l06pbn"> inventory </code> that contains an array field <code class="leafygreen-ui-1l06pbn"> instock </code> : </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ ..., instock: [ { warehouse: \"A\", qty: 35 }, { warehouse: \"B\", qty: 15 }, { warehouse: \"C\", qty: 35 } ], ... }","programmingLanguage":"JavaScript"} </script> <div class="css-1lju8ps"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-tyg50d"> <pre class="leafygreen-ui-1agdxuk" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">{ <!-- -->...<!-- -->, <span class="lg-highlight-attr">instock</span>: <!-- -->[ <!-- -->{ <span class="lg-highlight-attr">warehouse</span>: <span class="lg-highlight-string">"A"</span>, <span class="lg-highlight-attr">qty</span>: <span class="lg-highlight-number">35</span> }<!-- -->, <!-- -->{ <span class="lg-highlight-attr">warehouse</span>: <span class="lg-highlight-string">"B"</span>, <span class="lg-highlight-attr">qty</span>: <span class="lg-highlight-number">15</span> }<!-- -->, <!-- -->{ <span class="lg-highlight-attr">warehouse</span>: <span class="lg-highlight-string">"C"</span>, <span class="lg-highlight-attr">qty</span>: <span class="lg-highlight-number">35</span> } ]<!-- -->, <!-- -->...<!-- --> }</td></tr></tbody></table></code></pre> </div> </div> </div> <p class="leafygreen-ui-1kp3ins"> The following operation fails with a <code class="leafygreen-ui-1l06pbn"> Path collision </code> error: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.inventory.find( {}, { \"instock\": { $slice: 1 }, \"instock.warehouse\": 0 } )","programmingLanguage":"JavaScript"} </script> <div class="css-1lju8ps"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-tyg50d"> <pre class="leafygreen-ui-1agdxuk" tabindex="0"><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">inventory</span>.<span class="lg-highlight-title lg-highlight-function">find</span>( <!-- -->{<!-- -->}<!-- -->, <!-- -->{ <span class="lg-highlight-string">"instock"</span>: <!-- -->{ <span class="lg-highlight-attr">$slice</span>: <span class="lg-highlight-number">1</span> }<!-- -->, <span class="lg-highlight-string">"instock.warehouse"</span>: <span class="lg-highlight-number">0</span> } )</td></tr></tbody></table></code></pre> </div> </div> </div> <p class="leafygreen-ui-1kp3ins"> In previous versions, the projection applies both projections and returns the first element ( <code class="leafygreen-ui-1l06pbn"> $slice: 1 </code> ) in the <code class="leafygreen-ui-1l06pbn"> instock </code> array but suppresses the <code class="leafygreen-ui-1l06pbn"> warehouse </code> field in the projected element. Starting in MongoDB 4.4, to achieve the same result, use 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 with two separate <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/project/#mongodb-pipeline-pipe.-project"> <code class="leafygreen-ui-1l06pbn"> $project </code> </a> stages. </p> <div class="leafygreen-ui-13vw3ie" role="note"> <h2 class="leafygreen-ui-1fn4p2b"> Tip </h2> <h3 class="leafygreen-ui-144d5kf"> <strong> See also: </strong> </h3> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/db.collection.find/#std-label-find-projection"> Projection </a> </p> </div> </div> </section> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Examples <a class="headerlink leafygreen-ui-1kepx47" href="#examples" 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="examples"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> Create an example collection <code class="leafygreen-ui-1l06pbn"> posts </code> with the following documents: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.posts.insertMany([\n {\n _id: 1,\n title: \"Bagels are not croissants.\",\n comments: [ { comment: \"0. true\" }, { comment: \"1. croissants aren't bagels.\"} ]\n },\n {\n _id: 2,\n title: \"Coffee please.\",\n comments: [ { comment: \"0. fooey\" }, { comment: \"1. tea please\" }, { comment: \"2. iced coffee\" }, { comment: \"3. cappuccino\" }, { comment: \"4. whatever\" } ]\n }\n])","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><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">posts</span>.<span class="lg-highlight-title lg-highlight-function">insertMany</span>(<!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">1</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">title</span>: <span class="lg-highlight-string">"Bagels are not croissants."</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">comments</span>: <!-- -->[ <!-- -->{ <span class="lg-highlight-attr">comment</span>: <span class="lg-highlight-string">"0. true"</span> }<!-- -->, <!-- -->{ <span class="lg-highlight-attr">comment</span>: <span class="lg-highlight-string">"1. croissants aren't bagels."</span>} ]</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">2</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">title</span>: <span class="lg-highlight-string">"Coffee please."</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">comments</span>: <!-- -->[ <!-- -->{ <span class="lg-highlight-attr">comment</span>: <span class="lg-highlight-string">"0. fooey"</span> }<!-- -->, <!-- -->{ <span class="lg-highlight-attr">comment</span>: <span class="lg-highlight-string">"1. tea please"</span> }<!-- -->, <!-- -->{ <span class="lg-highlight-attr">comment</span>: <span class="lg-highlight-string">"2. iced coffee"</span> }<!-- -->, <!-- -->{ <span class="lg-highlight-attr">comment</span>: <span class="lg-highlight-string">"3. cappuccino"</span> }<!-- -->, <!-- -->{ <span class="lg-highlight-attr">comment</span>: <span class="lg-highlight-string">"4. whatever"</span> } ]</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">])</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> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Return an Array with Its First 3 Elements <a class="headerlink leafygreen-ui-1kepx47" href="#return-an-array-with-its-first-3-elements" 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="return-an-array-with-its-first-3-elements"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> The following operation uses the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-projection-proj.-slice" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $slice </code> </span> </a> projection operator on the <code class="leafygreen-ui-1l06pbn"> comments </code> array to return the array with its first three elements. If the array has less than three elements, all elements in the array are returned. </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.posts.find( {}, { comments: { $slice: 3 } } )","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">posts</span>.<span class="lg-highlight-title lg-highlight-function">find</span>( <!-- -->{<!-- -->}<!-- -->, <!-- -->{ <span class="lg-highlight-attr">comments</span>: <!-- -->{ <span class="lg-highlight-attr">$slice</span>: <span class="lg-highlight-number">3</span> } } )</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 operation returns the following documents: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{\n \"_id\" : 1,\n \"title\" : \"Bagels are not croissants.\",\n \"comments\" : [ { \"comment\" : \"0. true\" }, { \"comment\" : \"1. croissants aren't bagels.\" } ]\n}\n{\n \"_id\" : 2,\n \"title\" : \"Coffee please.\",\n \"comments\" : [ { \"comment\" : \"0. fooey\" }, { \"comment\" : \"1. tea please\" }, { \"comment\" : \"2. iced coffee\" } ]\n}","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">1</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"title"</span> <!-- -->: <span class="lg-highlight-string">"Bagels are not croissants."</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"comments"</span> <!-- -->: <!-- -->[ <!-- -->{ <span class="lg-highlight-string">"comment"</span> <!-- -->: <span class="lg-highlight-string">"0. true"</span> }<!-- -->, <!-- -->{ <span class="lg-highlight-string">"comment"</span> <!-- -->: <span class="lg-highlight-string">"1. croissants aren't bagels."</span> } ]</td></tr><tr class=""><td class="leafygreen-ui-7razhx">}</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">2</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"title"</span> <!-- -->: <span class="lg-highlight-string">"Coffee please."</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"comments"</span> <!-- -->: <!-- -->[ <!-- -->{ <span class="lg-highlight-string">"comment"</span> <!-- -->: <span class="lg-highlight-string">"0. fooey"</span> }<!-- -->, <!-- -->{ <span class="lg-highlight-string">"comment"</span> <!-- -->: <span class="lg-highlight-string">"1. tea please"</span> }<!-- -->, <!-- -->{ <span class="lg-highlight-string">"comment"</span> <!-- -->: <span class="lg-highlight-string">"2. iced coffee"</span> } ]</td></tr><tr class=""><td class="leafygreen-ui-7razhx">}</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> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Return an Array with Its Last 3 Elements <a class="headerlink leafygreen-ui-1kepx47" href="#return-an-array-with-its-last-3-elements" 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="return-an-array-with-its-last-3-elements"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> The following operation uses the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-projection-proj.-slice" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $slice </code> </span> </a> projection operator on the <code class="leafygreen-ui-1l06pbn"> comments </code> array to return the array with its last three elements. If the array has less than three elements, all elements in the array are returned. </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.posts.find( {}, { comments: { $slice: -3 } } )","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">posts</span>.<span class="lg-highlight-title lg-highlight-function">find</span>( <!-- -->{<!-- -->}<!-- -->, <!-- -->{ <span class="lg-highlight-attr">comments</span>: <!-- -->{ <span class="lg-highlight-attr">$slice</span>: <!-- -->-<span class="lg-highlight-number">3</span> } } )</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 operation returns the following documents: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{\n \"_id\" : 1,\n \"title\" : \"Bagels are not croissants.\",\n \"comments\" : [ { \"comment\" : \"0. true\" }, { \"comment\" : \"1. croissants aren't bagels.\" } ]\n}\n{\n \"_id\" : 2,\n \"title\" : \"Coffee please.\",\n \"comments\" : [ { \"comment\" : \"2. iced coffee\" }, { \"comment\" : \"3. cappuccino\" }, { \"comment\" : \"4. whatever\" } ]\n}","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">1</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"title"</span> <!-- -->: <span class="lg-highlight-string">"Bagels are not croissants."</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"comments"</span> <!-- -->: <!-- -->[ <!-- -->{ <span class="lg-highlight-string">"comment"</span> <!-- -->: <span class="lg-highlight-string">"0. true"</span> }<!-- -->, <!-- -->{ <span class="lg-highlight-string">"comment"</span> <!-- -->: <span class="lg-highlight-string">"1. croissants aren't bagels."</span> } ]</td></tr><tr class=""><td class="leafygreen-ui-7razhx">}</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">2</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"title"</span> <!-- -->: <span class="lg-highlight-string">"Coffee please."</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"comments"</span> <!-- -->: <!-- -->[ <!-- -->{ <span class="lg-highlight-string">"comment"</span> <!-- -->: <span class="lg-highlight-string">"2. iced coffee"</span> }<!-- -->, <!-- -->{ <span class="lg-highlight-string">"comment"</span> <!-- -->: <span class="lg-highlight-string">"3. cappuccino"</span> }<!-- -->, <!-- -->{ <span class="lg-highlight-string">"comment"</span> <!-- -->: <span class="lg-highlight-string">"4. whatever"</span> } ]</td></tr><tr class=""><td class="leafygreen-ui-7razhx">}</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> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Return an Array with 3 Elements After Skipping the First Element <a class="headerlink leafygreen-ui-1kepx47" href="#return-an-array-with-3-elements-after-skipping-the-first-element" 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="return-an-array-with-3-elements-after-skipping-the-first-element"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> The following operation uses the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-projection-proj.-slice" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $slice </code> </span> </a> projection operator on the <code class="leafygreen-ui-1l06pbn"> comments </code> array to: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Skip the first element such that the second element is the starting point. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Then, return three elements from the starting point. </p> </li> </ul> <p class="leafygreen-ui-1kp3ins"> If the array has less than three elements after the skip, all remaining elements are returned. </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.posts.find( {}, { comments: { $slice: [ 1, 3 ] } } )","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">posts</span>.<span class="lg-highlight-title lg-highlight-function">find</span>( <!-- -->{<!-- -->}<!-- -->, <!-- -->{ <span class="lg-highlight-attr">comments</span>: <!-- -->{ <span class="lg-highlight-attr">$slice</span>: <!-- -->[ <span class="lg-highlight-number">1</span>, <span class="lg-highlight-number">3</span> ] } } )</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 operation returns the following documents: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{\n \"_id\" : 1,\n \"title\" : \"Bagels are not croissants.\",\n \"comments\" : [ { \"comment\" : \"1. croissants aren't bagels.\" } ]\n}\n\n{\n \"_id\" : 2,\n \"title\" : \"Coffee please.\",\n \"comments\" : [ { \"comment\" : \"1. tea please\" }, { \"comment\" : \"2. iced coffee\" }, { \"comment\" : \"3. cappuccino\" } ]\n}","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">1</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"title"</span> <!-- -->: <span class="lg-highlight-string">"Bagels are not croissants."</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"comments"</span> <!-- -->: <!-- -->[ <!-- -->{ <span class="lg-highlight-string">"comment"</span> <!-- -->: <span class="lg-highlight-string">"1. croissants aren't bagels."</span> } ]</td></tr><tr class=""><td class="leafygreen-ui-7razhx">}</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><div class="leafygreen-ui-ihxujy"></div></td></tr><tr class=""><td class="leafygreen-ui-7razhx">{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">2</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"title"</span> <!-- -->: <span class="lg-highlight-string">"Coffee please."</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"comments"</span> <!-- -->: <!-- -->[ <!-- -->{ <span class="lg-highlight-string">"comment"</span> <!-- -->: <span class="lg-highlight-string">"1. tea please"</span> }<!-- -->, <!-- -->{ <span class="lg-highlight-string">"comment"</span> <!-- -->: <span class="lg-highlight-string">"2. iced coffee"</span> }<!-- -->, <!-- -->{ <span class="lg-highlight-string">"comment"</span> <!-- -->: <span class="lg-highlight-string">"3. cappuccino"</span> } ]</td></tr><tr class=""><td class="leafygreen-ui-7razhx">}</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> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Return an Array with 3 Elements After Skipping the Last Element <a class="headerlink leafygreen-ui-1kepx47" href="#return-an-array-with-3-elements-after-skipping-the-last-element" 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="return-an-array-with-3-elements-after-skipping-the-last-element"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> The following operation uses the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-projection-proj.-slice" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $slice </code> </span> </a> projection operator on the <code class="leafygreen-ui-1l06pbn"> comments </code> array to </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Skip backwards from the first element such that the last element is the starting point. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Then, return three elements from the starting point. </p> </li> </ul> <p class="leafygreen-ui-1kp3ins"> If the array has less than three elements after the skip, all remaining elements in the array are returned. </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.posts.find( {}, { comments: { $slice: [ -1, 3 ] } } )","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">posts</span>.<span class="lg-highlight-title lg-highlight-function">find</span>( <!-- -->{<!-- -->}<!-- -->, <!-- -->{ <span class="lg-highlight-attr">comments</span>: <!-- -->{ <span class="lg-highlight-attr">$slice</span>: <!-- -->[ <!-- -->-<span class="lg-highlight-number">1</span>, <span class="lg-highlight-number">3</span> ] } } )</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 operation returns the following documents: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{\n \"_id\" : 1,\n \"title\" : \"Bagels are not croissants.\",\n \"comments\" : [ { \"comment\" : \"1. croissants aren't bagels.\" } ]\n}\n{\n \"_id\" : 2,\n \"title\" : \"Coffee please.\",\n \"comments\" : [ { \"comment\" : \"4. whatever\" } ]\n}","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">1</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"title"</span> <!-- -->: <span class="lg-highlight-string">"Bagels are not croissants."</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"comments"</span> <!-- -->: <!-- -->[ <!-- -->{ <span class="lg-highlight-string">"comment"</span> <!-- -->: <span class="lg-highlight-string">"1. croissants aren't bagels."</span> } ]</td></tr><tr class=""><td class="leafygreen-ui-7razhx">}</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">2</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"title"</span> <!-- -->: <span class="lg-highlight-string">"Coffee please."</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"comments"</span> <!-- -->: <!-- -->[ <!-- -->{ <span class="lg-highlight-string">"comment"</span> <!-- -->: <span class="lg-highlight-string">"4. whatever"</span> } ]</td></tr><tr class=""><td class="leafygreen-ui-7razhx">}</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> </section> </section> </section>
https://www.mongodb.com/docs/manual/reference/operator/query/nearSphere/
<section> <h1 class="contains-headerlink leafygreen-ui-41fr9s" weight="medium"> $nearSphere <a class="headerlink leafygreen-ui-1kepx47" href="#-nearsphere" 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="-nearsphere"> </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="#definition" target="_self"> <span> Definition </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#behavior" target="_self"> <span> Behavior </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#examples" target="_self"> <span> Examples </span> </a> </li> </ul> </div> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Definition <a class="headerlink leafygreen-ui-1kepx47" href="#definition" 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="definition"> </div> </a> </h2> <dl class="query"> <dt> <code class="leafygreen-ui-1l06pbn"> $nearSphere </code> <a class="headerlink leafygreen-ui-1kepx47" href="#mongodb-query-op.-nearSphere" title="Permalink to this definition"> <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="mongodb-query-op.-nearSphere"> </div> </a> </dt> <dd> <p class="leafygreen-ui-1kp3ins"> Specifies a point for which a <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-geospatial"> geospatial </a> query returns the documents from nearest to farthest. MongoDB calculates distances for <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-query-op.-nearSphere" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $nearSphere </code> </span> </a> using spherical geometry. </p> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-query-op.-nearSphere" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $nearSphere </code> </span> </a> <em> requires </em> a geospatial index: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/indexes/index-types/geospatial/2dsphere/#std-label-2dsphere-index"> 2dsphere </a> index for location data defined as GeoJSON points. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/indexes/index-types/geospatial/2d/#std-label-2d-index"> 2d </a> index for location data defined as legacy coordinate pairs. To use a <code class="leafygreen-ui-1l06pbn"> 2d </code> index on <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/geojson/#std-label-geojson-point"> GeoJSON points </a> , create the index on the <code class="leafygreen-ui-1l06pbn"> coordinates </code> field of the GeoJSON object. </p> </li> </ul> <p class="leafygreen-ui-1kp3ins"> The <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-query-op.-nearSphere" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $nearSphere </code> </span> </a> operator can specify either a <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-GeoJSON"> GeoJSON </a> point or legacy coordinate point. </p> <p class="leafygreen-ui-1kp3ins"> To specify a <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/geojson/#std-label-geojson-point"> GeoJSON Point </a> , use the following syntax: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{\n $nearSphere: {\n $geometry: {\n type : \"Point\",\n coordinates : [ &lt;longitude&gt;, &lt;latitude&gt; ]\n },\n $minDistance: &lt;distance&gt;,\n $maxDistance: &lt;distance&gt;\n }\n}","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">$nearSphere</span>: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">$geometry</span>: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->type <!-- -->: <span class="lg-highlight-string">"Point"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->coordinates <!-- -->: <!-- -->[ &lt;<!-- -->longitude<!-- -->&gt;<!-- -->,<!-- --> <!-- -->&lt;<!-- -->latitude<!-- -->&gt; <!-- -->]</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">$minDistance</span>: <!-- -->&lt;distance in meters&gt;,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> $maxDistance: &lt;distance in meters&gt;</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">}</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> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> The <em> optional </em> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/query/minDistance/#mongodb-query-op.-minDistance"> <code class="leafygreen-ui-1l06pbn"> $minDistance </code> </a> limits the results to those documents that are <em> at least </em> the specified distance from the center point. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> The <em> optional </em> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/query/maxDistance/#mongodb-query-op.-maxDistance"> <code class="leafygreen-ui-1l06pbn"> $maxDistance </code> </a> is available for either index. </p> </li> </ul> <p class="leafygreen-ui-1kp3ins"> To specify a point using legacy coordinates, use the following syntax: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{\n $nearSphere: [ &lt;x&gt;, &lt;y&gt; ],\n $minDistance: &lt;distance&gt;,\n $maxDistance: &lt;distance&gt;\n}","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">$nearSphere</span>: <!-- -->[ &lt;<!-- -->x<!-- -->&gt;<!-- -->,<!-- --> <!-- -->&lt;<!-- -->y<!-- -->&gt; <!-- -->]<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">$minDistance</span>: <!-- -->&lt;distance in radians&gt;,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> $maxDistance: &lt;distance in radians&gt;</td></tr><tr class=""><td class="leafygreen-ui-7razhx">}</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> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> The <em> optional </em> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/query/minDistance/#mongodb-query-op.-minDistance"> <code class="leafygreen-ui-1l06pbn"> $minDistance </code> </a> is available only if the query uses the <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/indexes/index-types/geospatial/2dsphere/#std-label-2dsphere-index"> 2dsphere </a> index. <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/query/minDistance/#mongodb-query-op.-minDistance"> <code class="leafygreen-ui-1l06pbn"> $minDistance </code> </a> limits the results to those documents that are <em> at least </em> the specified distance from the center point. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> The <em> optional </em> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/query/maxDistance/#mongodb-query-op.-maxDistance"> <code class="leafygreen-ui-1l06pbn"> $maxDistance </code> </a> is available for either index. </p> </li> </ul> <p class="leafygreen-ui-1kp3ins"> If you use longitude and latitude for legacy coordinates, specify the longitude first, then latitude. </p> </dd> </dl> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Behavior <a class="headerlink leafygreen-ui-1kepx47" href="#behavior" 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="behavior"> </div> </a> </h2> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Special Indexes Restriction <a class="headerlink leafygreen-ui-1kepx47" href="#special-indexes-restriction" 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="special-indexes-restriction"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> You cannot combine the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-query-op.-nearSphere" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $nearSphere </code> </span> </a> operator, which requires a special <a class="leafygreen-ui-tqgtui" href="/docs/manual/geospatial-queries/#std-label-index-feature-geospatial"> geospatial index </a> , with a query operator or command that requires another special index. For example you cannot combine <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-query-op.-nearSphere" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $nearSphere </code> </span> </a> with the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/query/text/#mongodb-query-op.-text"> <code class="leafygreen-ui-1l06pbn"> $text </code> </a> query. </p> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Sort Operation <a class="headerlink leafygreen-ui-1kepx47" href="#sort-operation" 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="sort-operation"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> The <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-query-op.-nearSphere" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $nearSphere </code> </span> </a> operator sorts documents by distance. </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> If you use the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/cursor.sort/#mongodb-method-cursor.sort"> <code class="leafygreen-ui-1l06pbn"> sort() </code> </a> method in your query, MongoDB performs a second sort operation, re-ordering the matching documents. When querying large collections, this can negatively affect query performance. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> If the order of the documents is not important to you, consider using the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/query/geoWithin/#mongodb-query-op.-geoWithin"> <code class="leafygreen-ui-1l06pbn"> $geoWithin </code> </a> operator instead, as it returns unsorted results. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-query-op.-nearSphere" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $nearSphere </code> </span> </a> is a Match Execution operator and is not permitted in aggregation pipelines. </p> </li> </ul> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Validation <a class="headerlink leafygreen-ui-1kepx47" href="#validation" 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="validation"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> Starting in MongoDB 8.0, <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/query/near/#mongodb-query-op.-near"> <code class="leafygreen-ui-1l06pbn"> $near </code> </a> , <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-query-op.-nearSphere" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $nearSphere </code> </span> </a> , and <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/geoNear/#mongodb-pipeline-pipe.-geoNear"> <code class="leafygreen-ui-1l06pbn"> $geoNear </code> </a> validate that the type of the specified <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/geojson/#std-label-geojson-point"> GeoJSON points </a> is <code class="leafygreen-ui-1l06pbn"> Point </code> . Any other input type returns an error. </p> </section> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Examples <a class="headerlink leafygreen-ui-1kepx47" href="#examples" 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="examples"> </div> </a> </h2> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Specify Center Point Using GeoJSON <a class="headerlink leafygreen-ui-1kepx47" href="#specify-center-point-using-geojson" 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="specify-center-point-using-geojson"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> Consider a collection <code class="leafygreen-ui-1l06pbn"> places </code> that contains documents with a <code class="leafygreen-ui-1l06pbn"> location </code> field and has a <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/indexes/index-types/geospatial/2dsphere/#std-label-2dsphere-index"> 2dsphere </a> index. </p> <p class="leafygreen-ui-1kp3ins"> Then, the following example returns whose <code class="leafygreen-ui-1l06pbn"> location </code> is at least <code class="leafygreen-ui-1l06pbn"> 1000 </code> meters from and at most <code class="leafygreen-ui-1l06pbn"> 5000 </code> meters from the specified point, ordered from nearest to farthest: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.places.find(\n {\n location: {\n $nearSphere: {\n $geometry: {\n type : \"Point\",\n coordinates : [ -73.9667, 40.78 ]\n },\n $minDistance: 1000,\n $maxDistance: 5000\n }\n }\n }\n)","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">places</span>.<span class="lg-highlight-title lg-highlight-function">find</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">location</span>: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">$nearSphere</span>: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">$geometry</span>: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->type <!-- -->: <span class="lg-highlight-string">"Point"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->coordinates <!-- -->: <!-- -->[ <!-- -->-<span class="lg-highlight-number">73.9667</span>, <span class="lg-highlight-number">40.78</span> ]</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">$minDistance</span>: <span class="lg-highlight-number">1000</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">$maxDistance</span>: <span class="lg-highlight-number">5000</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">)</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> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Specify Center Point Using Legacy Coordinates <a class="headerlink leafygreen-ui-1kepx47" href="#specify-center-point-using-legacy-coordinates" 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="specify-center-point-using-legacy-coordinates"> </div> </a> </h3> <section> <h4 class="contains-headerlink leafygreen-ui-1vzlt5f"> <code class="leafygreen-ui-1l06pbn"> 2d </code> Index <a class="headerlink leafygreen-ui-1kepx47" href="#2d-index" 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="2d-index"> </div> </a> </h4> <p class="leafygreen-ui-1kp3ins"> Consider a collection <code class="leafygreen-ui-1l06pbn"> legacyPlaces </code> that contains documents with legacy coordinates pairs in the <code class="leafygreen-ui-1l06pbn"> location </code> field and has a <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/indexes/index-types/geospatial/2d/#std-label-2d-index"> 2d </a> index. </p> <p class="leafygreen-ui-1kp3ins"> Then, the following example returns those documents whose <code class="leafygreen-ui-1l06pbn"> location </code> is at most <code class="leafygreen-ui-1l06pbn"> 0.10 </code> radians from the specified point, ordered from nearest to farthest: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.legacyPlaces.find(\n { location : { $nearSphere : [ -73.9667, 40.78 ], $maxDistance: 0.10 } }\n)","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><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">legacyPlaces</span>.<span class="lg-highlight-title lg-highlight-function">find</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <!-- -->location <!-- -->: <!-- -->{ <!-- -->$nearSphere<!-- --> <!-- -->: <!-- -->[ <!-- -->-<span class="lg-highlight-number">73.9667</span>, <span class="lg-highlight-number">40.78</span> ]<!-- -->, <span class="lg-highlight-attr">$maxDistance</span>: <span class="lg-highlight-number">0.10</span> } }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">)</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> </section> <section> <h4 class="contains-headerlink leafygreen-ui-1vzlt5f"> <code class="leafygreen-ui-1l06pbn"> 2dsphere </code> Index <a class="headerlink leafygreen-ui-1kepx47" href="#2dsphere-index" 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="2dsphere-index"> </div> </a> </h4> <p class="leafygreen-ui-1kp3ins"> If the collection has a <code class="leafygreen-ui-1l06pbn"> 2dsphere </code> index instead, you can also specify the optional <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/query/minDistance/#mongodb-query-op.-minDistance"> <code class="leafygreen-ui-1l06pbn"> $minDistance </code> </a> specification. For example, the following example returns the documents whose <code class="leafygreen-ui-1l06pbn"> location </code> is at least <code class="leafygreen-ui-1l06pbn"> 0.0004 </code> radians from the specified point, ordered from nearest to farthest: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.legacyPlaces.find(\n { location : { $nearSphere : [ -73.9667, 40.78 ], $minDistance: 0.0004 } }\n)","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><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">legacyPlaces</span>.<span class="lg-highlight-title lg-highlight-function">find</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <!-- -->location <!-- -->: <!-- -->{ <!-- -->$nearSphere<!-- --> <!-- -->: <!-- -->[ <!-- -->-<span class="lg-highlight-number">73.9667</span>, <span class="lg-highlight-number">40.78</span> ]<!-- -->, <span class="lg-highlight-attr">$minDistance</span>: <span class="lg-highlight-number">0.0004</span> } }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">)</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> </section> </section> </section> </section>
https://www.mongodb.com/docs/manual/core/materialized-views/
<section> <h1 class="contains-headerlink leafygreen-ui-41fr9s" weight="medium"> On-Demand Materialized Views <a class="headerlink leafygreen-ui-1kepx47" href="#on-demand-materialized-views" 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="on-demand-materialized-views"> </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="#comparison-with-standard-views" target="_self"> <span> Comparison with Standard Views </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#create-a-materialized-view-in-the-mongodb-atlas-ui" target="_self"> <span> Create a Materialized View in the MongoDB Atlas UI </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#example" target="_self"> <span> Example </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#additional-information" target="_self"> <span> Additional Information </span> </a> </li> </ul> </div> <div class="leafygreen-ui-15mdk4" role="note"> <h2 class="leafygreen-ui-6n7b7d"> Note </h2> <h3 class="leafygreen-ui-144d5kf"> <strong> Disambiguation </strong> </h3> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> This page discusses on-demand materialized views. For discussion of standard views, see <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/views/#std-label-views-landing-page"> Views <!-- --> . </a> </p> <p class="leafygreen-ui-1kp3ins"> To understand the differences between the view types, see <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-materialized-view-compare" target="_self"> <span> Comparison with Standard Views <!-- --> . </span> </a> </p> </div> </div> <p class="leafygreen-ui-1kp3ins"> An on-demand materialized view is a pre-computed aggregation pipeline result that is stored on and read from disk. On-demand materialized views are typically the results of 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> or <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. </p> <span class="leafygreen-ui-1qnjd6d" id="std-label-materialized-view-compare"> </span> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Comparison with Standard Views <a class="headerlink leafygreen-ui-1kepx47" href="#comparison-with-standard-views" 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="comparison-with-standard-views"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> MongoDB provides two different view types: <strong> standard views </strong> and <strong> on-demand materialized views </strong> . Both view types return the results from an aggregation pipeline. </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Standard views are computed when you read the view, and are not stored to disk. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> On-demand materialized views are stored on and read from disk. They use 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> or <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 to update the saved data. </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"> When using <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/merge/#mongodb-pipeline-pipe.-merge"> <code class="leafygreen-ui-1l06pbn"> $merge </code> </a> , you can use <a class="leafygreen-ui-tqgtui" href="/docs/manual/changeStreams/#std-label-changeStreams"> change streams </a> to watch for changes on the materialized view. When using <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/out/#mongodb-pipeline-pipe.-out"> <code class="leafygreen-ui-1l06pbn"> $out </code> </a> , you can't watch for changes on the materialized view. </p> </div> </div> </li> </ul> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Indexes <a class="headerlink leafygreen-ui-1kepx47" href="#indexes" 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="indexes"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> Standard views use the indexes of the underlying collection. As a result, you cannot create, drop or re-build indexes on a standard view directly, nor get a list of indexes on the view. </p> <p class="leafygreen-ui-1kp3ins"> You can create indexes directly on on-demand materialized views because they are stored on disk. </p> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Performance <a class="headerlink leafygreen-ui-1kepx47" href="#performance" 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="performance"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> On-demand materialized views provide better read performance than standard views because they are read from disk instead of computed as part of the query. This performance benefit increases based on the complexity of the pipeline and size of the data being aggregated. </p> </section> <span class="leafygreen-ui-1qnjd6d" id="std-label-create-view-atlas"> </span> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Create a Materialized View in the MongoDB Atlas UI <a class="headerlink leafygreen-ui-1kepx47" href="#create-a-materialized-view-in-the-mongodb-atlas-ui" 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="create-a-materialized-view-in-the-mongodb-atlas-ui"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> The example in this section uses the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/atlas/sample-data/sample-mflix/" target="_self"> <span> sample movies dataset </span> </a> . To learn how to load the sample dataset into your MongoDB Atlas deployment, see <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/atlas/sample-data/#std-label-load-sample-data" target="_self"> <span> Load Sample Data <!-- --> . </span> </a> </p> <p class="leafygreen-ui-1kp3ins"> To create a materialized view in the MongoDB Atlas UI, follow these steps: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"HowTo","steps":[{"@type":"HowToStep","text":"If it's not already displayed, select the organization that\ncontains your desired project from the Organizations menu in the\nnavigation bar.If it's not already displayed, select your project\nfrom the Projects menu in the navigation bar.If it's not already displayed, click Clusters in the\nsidebar.The Clusters page displays.","name":"In the MongoDB Atlas UI, go to the Clusters page for your project."},{"@type":"HowToStep","text":"For the cluster that contains the sample data,\nclick Browse Collections.In the left navigation pane, select the\nsample_training database.Select the grades collection.","name":"Navigate to the collection"},{"@type":"HowToStep","text":"Click the Aggregation tab"},{"@type":"HowToStep","text":"Click Add Stage"},{"@type":"HowToStep","text":"The aggregation stage transforms the data that you want to save as\na view. To learn more about available aggregation stages, see\nAggregation Stages.For this example, add a new field with the $set stage:Select $set from the Select drop-down\nmenu.Add the following syntax to the aggregation pipeline\neditor to create an average score across all score\nvalues in the scores array within the grades\ncollection:MongoDB Atlas adds the averageScore value to each document.","name":"Select an aggregation stage from the Select drop-down menu"},{"@type":"HowToStep","text":"Click Add Stage"},{"@type":"HowToStep","text":"Select the $out stage from the Select\ndrop-down menu.Add the following syntax to the aggregation pipeline\nto write the results of the pipeline to the myView\ncollection in the sample_training database:Click Save Documents.The $out stage writes the results of the\naggregation pipeline to the specified collection, which creates\nthe view. To learn more, see $out.Refresh the list of collections to see the myView collection.To learn how to query the myView collection in the MongoDB Atlas\nUI, see View, Filter, and Sort Documents in the\nMongoDB Atlas documentation.","name":"Add the $out stage"}],"name":"Create a Materialized View in the MongoDB Atlas UI","image":"https://webimages.mongodb.com/_com_assets/cms/kuyj2focmkbxv7gh3-stacked_default_slate_blue.svg?auto=format%252Ccompress"} </script> <div class="css-4nyere eccljxs0"> <div class="css-1nuklj8 e1ckbxcu1"> <div class="css-18fui5z e1ckbxcu0"> <div class="css-19lsqsq e1ckbxcu2"> 1 </div> </div> <div class="css-1ed38mk"> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> In the MongoDB Atlas UI, go to the <span class="guilabel css-h15tq0"> Clusters </span> page for your project. <a class="headerlink leafygreen-ui-1kepx47" href="#in-the-mongodb-atlas-ui--go-to-the-clusters-page-for-your-project." 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="in-the-mongodb-atlas-ui--go-to-the-clusters-page-for-your-project."> </div> </a> </h3> <ol class="leafygreen-ui-rioki0" type="a"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> If it's not already displayed, select the organization that contains your desired project from the <i class="mms-icon-office mms-icon"> </i> <span class="guilabel css-h15tq0"> Organizations </span> menu <!-- --> in the navigation bar. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> If it's not already displayed, select your project from the <span class="guilabel css-h15tq0"> Projects </span> menu in the navigation bar. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> If it's not already displayed, click <span class="guilabel css-h15tq0"> Clusters </span> in the sidebar. </p> <p class="leafygreen-ui-1kp3ins"> The <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://cloud.mongodb.com/go?l=https%3A%2F%2Fcloud.mongodb.com%2Fv2%2F%3Cproject%3E%23%2Fclusters" target="_self"> <span> Clusters </span> </a> page displays. </p> </li> </ol> </section> </div> </div> <div class="css-1nuklj8 e1ckbxcu1"> <div class="css-18fui5z e1ckbxcu0"> <div class="css-19lsqsq e1ckbxcu2"> 2 </div> </div> <div class="css-1ed38mk"> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Navigate to the collection <a class="headerlink leafygreen-ui-1kepx47" href="#navigate-to-the-collection" 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="navigate-to-the-collection"> </div> </a> </h3> <ol class="leafygreen-ui-rioki0" type="a"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> For the cluster that contains the sample data, click <span class="guilabel css-h15tq0"> Browse Collections </span> . </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> In the left navigation pane, select the <span class="guilabel css-h15tq0"> sample_training </span> database. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Select the <span class="guilabel css-h15tq0"> grades </span> collection. </p> </li> </ol> </section> </div> </div> <div class="css-1nuklj8 e1ckbxcu1"> <div class="css-18fui5z e1ckbxcu0"> <div class="css-19lsqsq e1ckbxcu2"> 3 </div> </div> <div class="css-1ed38mk"> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Click the <span class="guilabel css-h15tq0"> Aggregation </span> tab <a class="headerlink leafygreen-ui-1kepx47" href="#click-the-aggregation-tab" 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="click-the-aggregation-tab"> </div> </a> </h3> </section> </div> </div> <div class="css-1nuklj8 e1ckbxcu1"> <div class="css-18fui5z e1ckbxcu0"> <div class="css-19lsqsq e1ckbxcu2"> 4 </div> </div> <div class="css-1ed38mk"> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Click <span class="guilabel css-h15tq0"> Add Stage </span> <a class="headerlink leafygreen-ui-1kepx47" href="#click-add-stage" 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="click-add-stage"> </div> </a> </h3> </section> </div> </div> <div class="css-1nuklj8 e1ckbxcu1"> <div class="css-18fui5z e1ckbxcu0"> <div class="css-19lsqsq e1ckbxcu2"> 5 </div> </div> <div class="css-1ed38mk"> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Select an aggregation stage from the <span class="guilabel css-h15tq0"> Select </span> drop-down menu <a class="headerlink leafygreen-ui-1kepx47" href="#select-an-aggregation-stage-from-the-select-drop-down-menu" 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="select-an-aggregation-stage-from-the-select-drop-down-menu"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> The aggregation stage transforms the data that you want to save as a view. To learn more about available aggregation stages, see <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation-pipeline/#std-label-aggregation-pipeline-operator-reference"> Aggregation Stages <!-- --> . </a> </p> <p class="leafygreen-ui-1kp3ins"> For this example, add a new field with the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/set/#mongodb-pipeline-pipe.-set"> <code class="leafygreen-ui-1l06pbn"> $set </code> </a> stage: </p> <ol class="leafygreen-ui-rioki0" type="a"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Select <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/set/#mongodb-pipeline-pipe.-set"> <code class="leafygreen-ui-1l06pbn"> $set </code> </a> from the <span class="guilabel css-h15tq0"> Select </span> drop-down menu. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Add the following syntax to the aggregation pipeline editor to create an average score across all <code class="leafygreen-ui-1l06pbn"> score </code> values in the <code class="leafygreen-ui-1l06pbn"> scores </code> array within the <code class="leafygreen-ui-1l06pbn"> grades </code> collection: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{\n averageScore: { $avg: \"$scores.score\" }\n}"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" tabindex="-1"><code class="lg-highlight-hljs-light none leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> averageScore: { $avg: "$scores.score" }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">}</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"> MongoDB Atlas adds the <code class="leafygreen-ui-1l06pbn"> averageScore </code> value to each document. </p> </li> </ol> </section> </div> </div> <div class="css-1nuklj8 e1ckbxcu1"> <div class="css-18fui5z e1ckbxcu0"> <div class="css-19lsqsq e1ckbxcu2"> 6 </div> </div> <div class="css-1ed38mk"> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Click <span class="guilabel css-h15tq0"> Add Stage </span> <a class="headerlink leafygreen-ui-1kepx47" href="#click-add-stage-1" 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="click-add-stage-1"> </div> </a> </h3> </section> </div> </div> <div class="css-1nuklj8 e1ckbxcu1"> <div class="css-18fui5z e1ckbxcu0"> <div class="css-19lsqsq e1ckbxcu2"> 7 </div> </div> <div class="css-1ed38mk"> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Add the <code class="leafygreen-ui-1l06pbn"> $out </code> stage <a class="headerlink leafygreen-ui-1kepx47" href="#add-the--out-stage" 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="add-the--out-stage"> </div> </a> </h3> <ol class="leafygreen-ui-rioki0" type="a"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Select 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 from the <span class="guilabel css-h15tq0"> Select </span> drop-down menu. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Add the following syntax to the aggregation pipeline to write the results of the pipeline to the <code class="leafygreen-ui-1l06pbn"> myView </code> collection in the <code class="leafygreen-ui-1l06pbn"> sample_training </code> database: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"'myView'"} </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 none leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">'myView'</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> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Click <span class="guilabel css-h15tq0"> Save Documents </span> . </p> </li> </ol> <p class="leafygreen-ui-1kp3ins"> 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 writes the results of the aggregation pipeline to the specified collection, which creates the view. To learn more, see <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/out/#mongodb-pipeline-pipe.-out"> <code class="leafygreen-ui-1l06pbn"> $out </code> . </a> </p> <p class="leafygreen-ui-1kp3ins"> Refresh the list of collections to see the <code class="leafygreen-ui-1l06pbn"> myView </code> collection. </p> <p class="leafygreen-ui-1kp3ins"> To learn how to query the <code class="leafygreen-ui-1l06pbn"> myView </code> collection in the MongoDB Atlas UI, see <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/atlas/atlas-ui/documents/#view--filter--and-sort-documents" target="_self"> <span> View, Filter, and Sort Documents </span> </a> in the MongoDB Atlas documentation. </p> </section> </div> </div> </div> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Example <a class="headerlink leafygreen-ui-1kepx47" href="#example" 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="example"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> Assume near the end of January 2019, the collection <code class="leafygreen-ui-1l06pbn"> bakesales </code> contains the sales information by items: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.bakesales.insertMany( [\n { date: new ISODate(\"2018-12-01\"), item: \"Cake - Chocolate\", quantity: 2, amount: new NumberDecimal(\"60\") },\n { date: new ISODate(\"2018-12-02\"), item: \"Cake - Peanut Butter\", quantity: 5, amount: new NumberDecimal(\"90\") },\n { date: new ISODate(\"2018-12-02\"), item: \"Cake - Red Velvet\", quantity: 10, amount: new NumberDecimal(\"200\") },\n { date: new ISODate(\"2018-12-04\"), item: \"Cookies - Chocolate Chip\", quantity: 20, amount: new NumberDecimal(\"80\") },\n { date: new ISODate(\"2018-12-04\"), item: \"Cake - Peanut Butter\", quantity: 1, amount: new NumberDecimal(\"16\") },\n { date: new ISODate(\"2018-12-05\"), item: \"Pie - Key Lime\", quantity: 3, amount: new NumberDecimal(\"60\") },\n { date: new ISODate(\"2019-01-25\"), item: \"Cake - Chocolate\", quantity: 2, amount: new NumberDecimal(\"60\") },\n { date: new ISODate(\"2019-01-25\"), item: \"Cake - Peanut Butter\", quantity: 1, amount: new NumberDecimal(\"16\") },\n { date: new ISODate(\"2019-01-26\"), item: \"Cake - Red Velvet\", quantity: 5, amount: new NumberDecimal(\"100\") },\n { date: new ISODate(\"2019-01-26\"), item: \"Cookies - Chocolate Chip\", quantity: 12, amount: new NumberDecimal(\"48\") },\n { date: new ISODate(\"2019-01-26\"), item: \"Cake - Carrot\", quantity: 2, amount: new NumberDecimal(\"36\") },\n { date: new ISODate(\"2019-01-26\"), item: \"Cake - Red Velvet\", quantity: 5, amount: new NumberDecimal(\"100\") },\n { date: new ISODate(\"2019-01-27\"), item: \"Pie - Chocolate Cream\", quantity: 1, amount: new NumberDecimal(\"20\") },\n { date: new ISODate(\"2019-01-27\"), item: \"Cake - Peanut Butter\", quantity: 5, amount: new NumberDecimal(\"80\") },\n { date: new ISODate(\"2019-01-27\"), item: \"Tarts - Apple\", quantity: 3, amount: new NumberDecimal(\"12\") },\n { date: new ISODate(\"2019-01-27\"), item: \"Cookies - Chocolate Chip\", quantity: 12, amount: new NumberDecimal(\"48\") },\n { date: new ISODate(\"2019-01-27\"), item: \"Cake - Carrot\", quantity: 5, amount: new NumberDecimal(\"36\") },\n { date: new ISODate(\"2019-01-27\"), item: \"Cake - Red Velvet\", quantity: 5, amount: new NumberDecimal(\"100\") },\n { date: new ISODate(\"2019-01-28\"), item: \"Cookies - Chocolate Chip\", quantity: 20, amount: new NumberDecimal(\"80\") },\n { date: new ISODate(\"2019-01-28\"), item: \"Pie - Key Lime\", quantity: 3, amount: new NumberDecimal(\"60\") },\n { date: new ISODate(\"2019-01-28\"), item: \"Cake - Red Velvet\", quantity: 5, amount: new NumberDecimal(\"100\") },\n] );","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><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">bakesales</span>.<span class="lg-highlight-title lg-highlight-function">insertMany</span>( <!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">date</span>: <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">ISODate</span>(<span class="lg-highlight-string">"2018-12-01"</span>)<!-- -->, <span class="lg-highlight-attr">item</span>: <span class="lg-highlight-string">"Cake - Chocolate"</span>, <span class="lg-highlight-attr">quantity</span>: <span class="lg-highlight-number">2</span>, <span class="lg-highlight-attr">amount</span>: <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">NumberDecimal</span>(<span class="lg-highlight-string">"60"</span>) }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">date</span>: <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">ISODate</span>(<span class="lg-highlight-string">"2018-12-02"</span>)<!-- -->, <span class="lg-highlight-attr">item</span>: <span class="lg-highlight-string">"Cake - Peanut Butter"</span>, <span class="lg-highlight-attr">quantity</span>: <span class="lg-highlight-number">5</span>, <span class="lg-highlight-attr">amount</span>: <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">NumberDecimal</span>(<span class="lg-highlight-string">"90"</span>) }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">date</span>: <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">ISODate</span>(<span class="lg-highlight-string">"2018-12-02"</span>)<!-- -->, <span class="lg-highlight-attr">item</span>: <span class="lg-highlight-string">"Cake - Red Velvet"</span>, <span class="lg-highlight-attr">quantity</span>: <span class="lg-highlight-number">10</span>, <span class="lg-highlight-attr">amount</span>: <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">NumberDecimal</span>(<span class="lg-highlight-string">"200"</span>) }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">date</span>: <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">ISODate</span>(<span class="lg-highlight-string">"2018-12-04"</span>)<!-- -->, <span class="lg-highlight-attr">item</span>: <span class="lg-highlight-string">"Cookies - Chocolate Chip"</span>, <span class="lg-highlight-attr">quantity</span>: <span class="lg-highlight-number">20</span>, <span class="lg-highlight-attr">amount</span>: <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">NumberDecimal</span>(<span class="lg-highlight-string">"80"</span>) }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">date</span>: <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">ISODate</span>(<span class="lg-highlight-string">"2018-12-04"</span>)<!-- -->, <span class="lg-highlight-attr">item</span>: <span class="lg-highlight-string">"Cake - Peanut Butter"</span>, <span class="lg-highlight-attr">quantity</span>: <span class="lg-highlight-number">1</span>, <span class="lg-highlight-attr">amount</span>: <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">NumberDecimal</span>(<span class="lg-highlight-string">"16"</span>) }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">date</span>: <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">ISODate</span>(<span class="lg-highlight-string">"2018-12-05"</span>)<!-- -->, <span class="lg-highlight-attr">item</span>: <span class="lg-highlight-string">"Pie - Key Lime"</span>, <span class="lg-highlight-attr">quantity</span>: <span class="lg-highlight-number">3</span>, <span class="lg-highlight-attr">amount</span>: <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">NumberDecimal</span>(<span class="lg-highlight-string">"60"</span>) }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">date</span>: <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">ISODate</span>(<span class="lg-highlight-string">"2019-01-25"</span>)<!-- -->, <span class="lg-highlight-attr">item</span>: <span class="lg-highlight-string">"Cake - Chocolate"</span>, <span class="lg-highlight-attr">quantity</span>: <span class="lg-highlight-number">2</span>, <span class="lg-highlight-attr">amount</span>: <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">NumberDecimal</span>(<span class="lg-highlight-string">"60"</span>) }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">date</span>: <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">ISODate</span>(<span class="lg-highlight-string">"2019-01-25"</span>)<!-- -->, <span class="lg-highlight-attr">item</span>: <span class="lg-highlight-string">"Cake - Peanut Butter"</span>, <span class="lg-highlight-attr">quantity</span>: <span class="lg-highlight-number">1</span>, <span class="lg-highlight-attr">amount</span>: <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">NumberDecimal</span>(<span class="lg-highlight-string">"16"</span>) }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">date</span>: <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">ISODate</span>(<span class="lg-highlight-string">"2019-01-26"</span>)<!-- -->, <span class="lg-highlight-attr">item</span>: <span class="lg-highlight-string">"Cake - Red Velvet"</span>, <span class="lg-highlight-attr">quantity</span>: <span class="lg-highlight-number">5</span>, <span class="lg-highlight-attr">amount</span>: <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">NumberDecimal</span>(<span class="lg-highlight-string">"100"</span>) }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">date</span>: <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">ISODate</span>(<span class="lg-highlight-string">"2019-01-26"</span>)<!-- -->, <span class="lg-highlight-attr">item</span>: <span class="lg-highlight-string">"Cookies - Chocolate Chip"</span>, <span class="lg-highlight-attr">quantity</span>: <span class="lg-highlight-number">12</span>, <span class="lg-highlight-attr">amount</span>: <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">NumberDecimal</span>(<span class="lg-highlight-string">"48"</span>) }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">date</span>: <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">ISODate</span>(<span class="lg-highlight-string">"2019-01-26"</span>)<!-- -->, <span class="lg-highlight-attr">item</span>: <span class="lg-highlight-string">"Cake - Carrot"</span>, <span class="lg-highlight-attr">quantity</span>: <span class="lg-highlight-number">2</span>, <span class="lg-highlight-attr">amount</span>: <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">NumberDecimal</span>(<span class="lg-highlight-string">"36"</span>) }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">date</span>: <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">ISODate</span>(<span class="lg-highlight-string">"2019-01-26"</span>)<!-- -->, <span class="lg-highlight-attr">item</span>: <span class="lg-highlight-string">"Cake - Red Velvet"</span>, <span class="lg-highlight-attr">quantity</span>: <span class="lg-highlight-number">5</span>, <span class="lg-highlight-attr">amount</span>: <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">NumberDecimal</span>(<span class="lg-highlight-string">"100"</span>) }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">date</span>: <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">ISODate</span>(<span class="lg-highlight-string">"2019-01-27"</span>)<!-- -->, <span class="lg-highlight-attr">item</span>: <span class="lg-highlight-string">"Pie - Chocolate Cream"</span>, <span class="lg-highlight-attr">quantity</span>: <span class="lg-highlight-number">1</span>, <span class="lg-highlight-attr">amount</span>: <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">NumberDecimal</span>(<span class="lg-highlight-string">"20"</span>) }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">date</span>: <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">ISODate</span>(<span class="lg-highlight-string">"2019-01-27"</span>)<!-- -->, <span class="lg-highlight-attr">item</span>: <span class="lg-highlight-string">"Cake - Peanut Butter"</span>, <span class="lg-highlight-attr">quantity</span>: <span class="lg-highlight-number">5</span>, <span class="lg-highlight-attr">amount</span>: <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">NumberDecimal</span>(<span class="lg-highlight-string">"80"</span>) }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">date</span>: <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">ISODate</span>(<span class="lg-highlight-string">"2019-01-27"</span>)<!-- -->, <span class="lg-highlight-attr">item</span>: <span class="lg-highlight-string">"Tarts - Apple"</span>, <span class="lg-highlight-attr">quantity</span>: <span class="lg-highlight-number">3</span>, <span class="lg-highlight-attr">amount</span>: <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">NumberDecimal</span>(<span class="lg-highlight-string">"12"</span>) }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">date</span>: <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">ISODate</span>(<span class="lg-highlight-string">"2019-01-27"</span>)<!-- -->, <span class="lg-highlight-attr">item</span>: <span class="lg-highlight-string">"Cookies - Chocolate Chip"</span>, <span class="lg-highlight-attr">quantity</span>: <span class="lg-highlight-number">12</span>, <span class="lg-highlight-attr">amount</span>: <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">NumberDecimal</span>(<span class="lg-highlight-string">"48"</span>) }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">date</span>: <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">ISODate</span>(<span class="lg-highlight-string">"2019-01-27"</span>)<!-- -->, <span class="lg-highlight-attr">item</span>: <span class="lg-highlight-string">"Cake - Carrot"</span>, <span class="lg-highlight-attr">quantity</span>: <span class="lg-highlight-number">5</span>, <span class="lg-highlight-attr">amount</span>: <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">NumberDecimal</span>(<span class="lg-highlight-string">"36"</span>) }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">date</span>: <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">ISODate</span>(<span class="lg-highlight-string">"2019-01-27"</span>)<!-- -->, <span class="lg-highlight-attr">item</span>: <span class="lg-highlight-string">"Cake - Red Velvet"</span>, <span class="lg-highlight-attr">quantity</span>: <span class="lg-highlight-number">5</span>, <span class="lg-highlight-attr">amount</span>: <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">NumberDecimal</span>(<span class="lg-highlight-string">"100"</span>) }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">date</span>: <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">ISODate</span>(<span class="lg-highlight-string">"2019-01-28"</span>)<!-- -->, <span class="lg-highlight-attr">item</span>: <span class="lg-highlight-string">"Cookies - Chocolate Chip"</span>, <span class="lg-highlight-attr">quantity</span>: <span class="lg-highlight-number">20</span>, <span class="lg-highlight-attr">amount</span>: <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">NumberDecimal</span>(<span class="lg-highlight-string">"80"</span>) }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">date</span>: <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">ISODate</span>(<span class="lg-highlight-string">"2019-01-28"</span>)<!-- -->, <span class="lg-highlight-attr">item</span>: <span class="lg-highlight-string">"Pie - Key Lime"</span>, <span class="lg-highlight-attr">quantity</span>: <span class="lg-highlight-number">3</span>, <span class="lg-highlight-attr">amount</span>: <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">NumberDecimal</span>(<span class="lg-highlight-string">"60"</span>) }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">date</span>: <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">ISODate</span>(<span class="lg-highlight-string">"2019-01-28"</span>)<!-- -->, <span class="lg-highlight-attr">item</span>: <span class="lg-highlight-string">"Cake - Red Velvet"</span>, <span class="lg-highlight-attr">quantity</span>: <span class="lg-highlight-number">5</span>, <span class="lg-highlight-attr">amount</span>: <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">NumberDecimal</span>(<span class="lg-highlight-string">"100"</span>) }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">] )<!-- -->;</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> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> 1. Define the On-Demand Materialized View <a class="headerlink leafygreen-ui-1kepx47" href="#1.-define-the-on-demand-materialized-view" 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="1.-define-the-on-demand-materialized-view"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> The following <code class="leafygreen-ui-1l06pbn"> updateMonthlySales </code> function defines a <code class="leafygreen-ui-1l06pbn"> monthlybakesales </code> materialized view that contains the cumulative monthly sales information. In the example, the function takes a date parameter to only update monthly sales information starting from a particular date. </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"updateMonthlySales = function(startDate) {\n db.bakesales.aggregate( [\n { $match: { date: { $gte: startDate } } },\n { $group: { _id: { $dateToString: { format: \"%Y-%m\", date: \"$date\" } }, sales_quantity: { $sum: \"$quantity\"}, sales_amount: { $sum: \"$amount\" } } },\n { $merge: { into: \"monthlybakesales\", whenMatched: \"replace\" } }\n ] );\n};","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">updateMonthlySales <!-- -->= <span class="lg-highlight-keyword lg-highlight-function">function</span>(<span class="lg-highlight-params">startDate</span>)<!-- --> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->db.<span class="lg-highlight-property">bakesales</span>.<span class="lg-highlight-title lg-highlight-function">aggregate</span>( <!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">$match</span>: <!-- -->{ <span class="lg-highlight-attr">date</span>: <!-- -->{ <span class="lg-highlight-attr">$gte</span>: <!-- -->startDate } } }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">$group</span>: <!-- -->{ <span class="lg-highlight-attr">_id</span>: <!-- -->{ <span class="lg-highlight-attr">$dateToString</span>: <!-- -->{ <span class="lg-highlight-attr">format</span>: <span class="lg-highlight-string">"%Y-%m"</span>, <span class="lg-highlight-attr">date</span>: <span class="lg-highlight-string">"$date"</span> } }<!-- -->, <span class="lg-highlight-attr">sales_quantity</span>: <!-- -->{ <span class="lg-highlight-attr">$sum</span>: <span class="lg-highlight-string">"$quantity"</span>}<!-- -->, <span class="lg-highlight-attr">sales_amount</span>: <!-- -->{ <span class="lg-highlight-attr">$sum</span>: <span class="lg-highlight-string">"$amount"</span> } } }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">$merge</span>: <!-- -->{ <span class="lg-highlight-attr">into</span>: <span class="lg-highlight-string">"monthlybakesales"</span>, <span class="lg-highlight-attr">whenMatched</span>: <span class="lg-highlight-string">"replace"</span> } }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> ] )<!-- -->;</td></tr><tr class=""><td class="leafygreen-ui-7razhx">}<!-- -->;</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> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> The <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/match/#mongodb-pipeline-pipe.-match"> <code class="leafygreen-ui-1l06pbn"> $match </code> </a> stage filters the data to process only those sales greater than or equal to the <code class="leafygreen-ui-1l06pbn"> startDate </code> . </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> The <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/group/#mongodb-pipeline-pipe.-group"> <code class="leafygreen-ui-1l06pbn"> $group </code> </a> stage groups the sales information by the year-month. The documents output by this stage have the form: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ \"_id\" : \"&lt;yyyy-mm&gt;\", \"sales_quantity\" : &lt;num&gt;, \"sales_amount\" : &lt;numberdecimal&gt; }","programmingLanguage":"JavaScript"} </script> <div class="css-1lju8ps"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-tyg50d"> <pre class="leafygreen-ui-1agdxuk" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-string">"&lt;YYYY-mm&gt;"</span>, <span class="lg-highlight-string">"sales_quantity"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;<!-- -->,<!-- --> <span class="lg-highlight-string">"sales_amount"</span> <!-- -->: &lt;<span class="lg-highlight-title lg-highlight-class">NumberDecimal</span>&gt; <!-- -->}</td></tr></tbody></table></code></pre> </div> </div> </div> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> 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 writes the output to the <code class="leafygreen-ui-1l06pbn"> monthlybakesales </code> collection. </p> <p class="leafygreen-ui-1kp3ins"> Based <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/merge/#std-label-merge-on"> on </a> the <code class="leafygreen-ui-1l06pbn"> _id </code> field (the default for unsharded output collections), the stage checks if the document in the aggregation results <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/merge/#std-label-merge-whenMatched"> matches </a> an existing document in the collection: </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/merge/#std-label-merge-whenMatched"> When there is a match </a> (i.e. a document with the same year-month already exists in the collection), the stage <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/merge/#std-label-merge-whenMatched-replace"> replaces the existing document </a> with the document from the aggregation results. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/merge/#std-label-merge-whenNotMatched"> When there is not a match </a> , the stage inserts the document from the aggregation results into the collection (the default behavior when not matched). </p> </li> </ul> </li> </ul> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> 2. Perform Initial Run <a class="headerlink leafygreen-ui-1kepx47" href="#2.-perform-initial-run" 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="2.-perform-initial-run"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> For the initial run, you can pass in a date of <code class="leafygreen-ui-1l06pbn"> new ISODate("1970-01-01") </code> : </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"updateMonthlySales(new ISODate(\"1970-01-01\"));","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"><span class="lg-highlight-title lg-highlight-function">updateMonthlySales</span>(<span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">ISODate</span>(<span class="lg-highlight-string">"1970-01-01"</span>))<!-- -->;</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"> After the initial run, the <code class="leafygreen-ui-1l06pbn"> monthlybakesales </code> contains the following documents; i.e. <code class="leafygreen-ui-1l06pbn"> db.monthlybakesales.find().sort( { _id: 1 } ) </code> returns the following: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ \"_id\" : \"2018-12\", \"sales_quantity\" : 41, \"sales_amount\" : NumberDecimal(\"506\") }\n{ \"_id\" : \"2019-01\", \"sales_quantity\" : 86, \"sales_amount\" : NumberDecimal(\"896\") }","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-string">"2018-12"</span>, <span class="lg-highlight-string">"sales_quantity"</span> <!-- -->: <span class="lg-highlight-number">41</span>, <span class="lg-highlight-string">"sales_amount"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">NumberDecimal</span>(<span class="lg-highlight-string">"506"</span>) }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-string">"2019-01"</span>, <span class="lg-highlight-string">"sales_quantity"</span> <!-- -->: <span class="lg-highlight-number">86</span>, <span class="lg-highlight-string">"sales_amount"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">NumberDecimal</span>(<span class="lg-highlight-string">"896"</span>) }</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> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> 3. Refresh Materialized View <a class="headerlink leafygreen-ui-1kepx47" href="#3.-refresh-materialized-view" 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="3.-refresh-materialized-view"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> Assume that by the first week in February 2019, the <code class="leafygreen-ui-1l06pbn"> bakesales </code> collection is updated with newer sales information; specifically, additional January and February sales. </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.bakesales.insertMany( [\n { date: new ISODate(\"2019-01-28\"), item: \"Cake - Chocolate\", quantity: 3, amount: new NumberDecimal(\"90\") },\n { date: new ISODate(\"2019-01-28\"), item: \"Cake - Peanut Butter\", quantity: 2, amount: new NumberDecimal(\"32\") },\n { date: new ISODate(\"2019-01-30\"), item: \"Cake - Red Velvet\", quantity: 1, amount: new NumberDecimal(\"20\") },\n { date: new ISODate(\"2019-01-30\"), item: \"Cookies - Chocolate Chip\", quantity: 6, amount: new NumberDecimal(\"24\") },\n { date: new ISODate(\"2019-01-31\"), item: \"Pie - Key Lime\", quantity: 2, amount: new NumberDecimal(\"40\") },\n { date: new ISODate(\"2019-01-31\"), item: \"Pie - Banana Cream\", quantity: 2, amount: new NumberDecimal(\"40\") },\n { date: new ISODate(\"2019-02-01\"), item: \"Cake - Red Velvet\", quantity: 5, amount: new NumberDecimal(\"100\") },\n { date: new ISODate(\"2019-02-01\"), item: \"Tarts - Apple\", quantity: 2, amount: new NumberDecimal(\"8\") },\n { date: new ISODate(\"2019-02-02\"), item: \"Cake - Chocolate\", quantity: 2, amount: new NumberDecimal(\"60\") },\n { date: new ISODate(\"2019-02-02\"), item: \"Cake - Peanut Butter\", quantity: 1, amount: new NumberDecimal(\"16\") },\n { date: new ISODate(\"2019-02-03\"), item: \"Cake - Red Velvet\", quantity: 5, amount: new NumberDecimal(\"100\") }\n] )","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><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">bakesales</span>.<span class="lg-highlight-title lg-highlight-function">insertMany</span>( <!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">date</span>: <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">ISODate</span>(<span class="lg-highlight-string">"2019-01-28"</span>)<!-- -->, <span class="lg-highlight-attr">item</span>: <span class="lg-highlight-string">"Cake - Chocolate"</span>, <span class="lg-highlight-attr">quantity</span>: <span class="lg-highlight-number">3</span>, <span class="lg-highlight-attr">amount</span>: <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">NumberDecimal</span>(<span class="lg-highlight-string">"90"</span>) }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">date</span>: <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">ISODate</span>(<span class="lg-highlight-string">"2019-01-28"</span>)<!-- -->, <span class="lg-highlight-attr">item</span>: <span class="lg-highlight-string">"Cake - Peanut Butter"</span>, <span class="lg-highlight-attr">quantity</span>: <span class="lg-highlight-number">2</span>, <span class="lg-highlight-attr">amount</span>: <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">NumberDecimal</span>(<span class="lg-highlight-string">"32"</span>) }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">date</span>: <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">ISODate</span>(<span class="lg-highlight-string">"2019-01-30"</span>)<!-- -->, <span class="lg-highlight-attr">item</span>: <span class="lg-highlight-string">"Cake - Red Velvet"</span>, <span class="lg-highlight-attr">quantity</span>: <span class="lg-highlight-number">1</span>, <span class="lg-highlight-attr">amount</span>: <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">NumberDecimal</span>(<span class="lg-highlight-string">"20"</span>) }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">date</span>: <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">ISODate</span>(<span class="lg-highlight-string">"2019-01-30"</span>)<!-- -->, <span class="lg-highlight-attr">item</span>: <span class="lg-highlight-string">"Cookies - Chocolate Chip"</span>, <span class="lg-highlight-attr">quantity</span>: <span class="lg-highlight-number">6</span>, <span class="lg-highlight-attr">amount</span>: <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">NumberDecimal</span>(<span class="lg-highlight-string">"24"</span>) }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">date</span>: <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">ISODate</span>(<span class="lg-highlight-string">"2019-01-31"</span>)<!-- -->, <span class="lg-highlight-attr">item</span>: <span class="lg-highlight-string">"Pie - Key Lime"</span>, <span class="lg-highlight-attr">quantity</span>: <span class="lg-highlight-number">2</span>, <span class="lg-highlight-attr">amount</span>: <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">NumberDecimal</span>(<span class="lg-highlight-string">"40"</span>) }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">date</span>: <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">ISODate</span>(<span class="lg-highlight-string">"2019-01-31"</span>)<!-- -->, <span class="lg-highlight-attr">item</span>: <span class="lg-highlight-string">"Pie - Banana Cream"</span>, <span class="lg-highlight-attr">quantity</span>: <span class="lg-highlight-number">2</span>, <span class="lg-highlight-attr">amount</span>: <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">NumberDecimal</span>(<span class="lg-highlight-string">"40"</span>) }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">date</span>: <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">ISODate</span>(<span class="lg-highlight-string">"2019-02-01"</span>)<!-- -->, <span class="lg-highlight-attr">item</span>: <span class="lg-highlight-string">"Cake - Red Velvet"</span>, <span class="lg-highlight-attr">quantity</span>: <span class="lg-highlight-number">5</span>, <span class="lg-highlight-attr">amount</span>: <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">NumberDecimal</span>(<span class="lg-highlight-string">"100"</span>) }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">date</span>: <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">ISODate</span>(<span class="lg-highlight-string">"2019-02-01"</span>)<!-- -->, <span class="lg-highlight-attr">item</span>: <span class="lg-highlight-string">"Tarts - Apple"</span>, <span class="lg-highlight-attr">quantity</span>: <span class="lg-highlight-number">2</span>, <span class="lg-highlight-attr">amount</span>: <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">NumberDecimal</span>(<span class="lg-highlight-string">"8"</span>) }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">date</span>: <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">ISODate</span>(<span class="lg-highlight-string">"2019-02-02"</span>)<!-- -->, <span class="lg-highlight-attr">item</span>: <span class="lg-highlight-string">"Cake - Chocolate"</span>, <span class="lg-highlight-attr">quantity</span>: <span class="lg-highlight-number">2</span>, <span class="lg-highlight-attr">amount</span>: <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">NumberDecimal</span>(<span class="lg-highlight-string">"60"</span>) }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">date</span>: <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">ISODate</span>(<span class="lg-highlight-string">"2019-02-02"</span>)<!-- -->, <span class="lg-highlight-attr">item</span>: <span class="lg-highlight-string">"Cake - Peanut Butter"</span>, <span class="lg-highlight-attr">quantity</span>: <span class="lg-highlight-number">1</span>, <span class="lg-highlight-attr">amount</span>: <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">NumberDecimal</span>(<span class="lg-highlight-string">"16"</span>) }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">date</span>: <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">ISODate</span>(<span class="lg-highlight-string">"2019-02-03"</span>)<!-- -->, <span class="lg-highlight-attr">item</span>: <span class="lg-highlight-string">"Cake - Red Velvet"</span>, <span class="lg-highlight-attr">quantity</span>: <span class="lg-highlight-number">5</span>, <span class="lg-highlight-attr">amount</span>: <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">NumberDecimal</span>(<span class="lg-highlight-string">"100"</span>) }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">] )</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"> To refresh the <code class="leafygreen-ui-1l06pbn"> monthlybakesales </code> data for January and February, run the function again to rerun the aggregation pipeline, starting with <code class="leafygreen-ui-1l06pbn"> new ISODate("2019-01-01") </code> . </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"updateMonthlySales(new ISODate(\"2019-01-01\"));","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"><span class="lg-highlight-title lg-highlight-function">updateMonthlySales</span>(<span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">ISODate</span>(<span class="lg-highlight-string">"2019-01-01"</span>))<!-- -->;</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 content of <code class="leafygreen-ui-1l06pbn"> monthlybakesales </code> has been updated to reflect the most recent data in the <code class="leafygreen-ui-1l06pbn"> bakesales </code> collection; i.e. <code class="leafygreen-ui-1l06pbn"> db.monthlybakesales.find().sort( { _id: 1 } ) </code> returns the following: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ \"_id\" : \"2018-12\", \"sales_quantity\" : 41, \"sales_amount\" : NumberDecimal(\"506\") }\n{ \"_id\" : \"2019-01\", \"sales_quantity\" : 102, \"sales_amount\" : NumberDecimal(\"1142\") }\n{ \"_id\" : \"2019-02\", \"sales_quantity\" : 15, \"sales_amount\" : NumberDecimal(\"284\") }","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-string">"2018-12"</span>, <span class="lg-highlight-string">"sales_quantity"</span> <!-- -->: <span class="lg-highlight-number">41</span>, <span class="lg-highlight-string">"sales_amount"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">NumberDecimal</span>(<span class="lg-highlight-string">"506"</span>) }</td></tr><tr class="leafygreen-ui-1wr1lm6"><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-string">"2019-01"</span>, <span class="lg-highlight-string">"sales_quantity"</span> <!-- -->: <span class="lg-highlight-number">102</span>, <span class="lg-highlight-string">"sales_amount"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">NumberDecimal</span>(<span class="lg-highlight-string">"1142"</span>) }</td></tr><tr class="leafygreen-ui-1wr1lm6"><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-string">"2019-02"</span>, <span class="lg-highlight-string">"sales_quantity"</span> <!-- -->: <span class="lg-highlight-number">15</span>, <span class="lg-highlight-string">"sales_amount"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">NumberDecimal</span>(<span class="lg-highlight-string">"284"</span>) }</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> </section> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Additional Information <a class="headerlink leafygreen-ui-1kepx47" href="#additional-information" 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="additional-information"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> 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: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Can output to a collection in the same or different database. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Creates a new collection if the output collection does not already exist. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Can incorporate results (insert new documents, merge documents, replace documents, keep existing documents, fail the operation, process documents with a custom update pipeline) into an existing collection. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Can output to a sharded collection. Input collection can also be sharded. </p> </li> </ul> <p class="leafygreen-ui-1kp3ins"> See <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/merge/#mongodb-pipeline-pipe.-merge"> <code class="leafygreen-ui-1l06pbn"> $merge </code> </a> for: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> More information on <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/merge/#mongodb-pipeline-pipe.-merge"> <code class="leafygreen-ui-1l06pbn"> $merge </code> </a> and available options </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Example: <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/merge/#std-label-merge-mat-view-init-creation"> On-Demand Materialized View: Initial Creation </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Example: <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/merge/#std-label-merge-mat-view-refresh"> On-Demand Materialized View: Update/Replace Data </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Example: <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/merge/#std-label-merge-mat-view-insert-only"> Only Insert New Data </a> </p> </li> </ul> </section> </section>
https://www.mongodb.com/docs/manual/reference/operator/aggregation/regexMatch/
<section> <h1 class="contains-headerlink leafygreen-ui-41fr9s" weight="medium"> $regexMatch (aggregation) <a class="headerlink leafygreen-ui-1kepx47" href="#-regexmatch--aggregation-" 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="-regexmatch--aggregation-"> </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="#definition" target="_self"> <span> Definition </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#syntax" target="_self"> <span> Syntax </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#behavior" target="_self"> <span> Behavior </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#examples" target="_self"> <span> Examples </span> </a> </li> </ul> </div> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Definition <a class="headerlink leafygreen-ui-1kepx47" href="#definition" 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="definition"> </div> </a> </h2> <dl class="expression"> <dt> <code class="leafygreen-ui-1l06pbn"> $regexMatch </code> <a class="headerlink leafygreen-ui-1kepx47" href="#mongodb-expression-exp.-regexMatch" title="Permalink to this definition"> <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="mongodb-expression-exp.-regexMatch"> </div> </a> </dt> <dd> <p class="leafygreen-ui-1kp3ins"> Performs a regular expression (regex) pattern matching and returns: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <code class="leafygreen-ui-1l06pbn"> true </code> if a match exists. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <code class="leafygreen-ui-1l06pbn"> false </code> if a match doesn't exist. </p> </li> </ul> </dd> </dl> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Syntax <a class="headerlink leafygreen-ui-1kepx47" href="#syntax" 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="syntax"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> The <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-expression-exp.-regexMatch" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $regexMatch </code> </span> </a> operator has the following syntax: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ $regexMatch: { input: &lt;expression&gt; , regex: &lt;expression&gt;, options: &lt;expression&gt; } }","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-1q4bxgx" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-attr">$regexMatch</span>: <!-- -->{ <span class="lg-highlight-attr">input</span>: &lt;<!-- -->expression<!-- -->&gt; <!-- -->,<!-- --> <span class="lg-highlight-attr">regex</span>: &lt;<!-- -->expression<!-- -->&gt;<!-- -->,<!-- --> <span class="lg-highlight-attr">options</span>: &lt;<!-- -->expression<!-- -->&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> Field </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="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-regexMatch-input" target="_self"> <span> input </span> </a> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <span class="leafygreen-ui-1qnjd6d" id="std-label-regexMatch-input"> </span> <p class="leafygreen-ui-1kp3ins"> The string on which you wish to apply the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-regexMatch-regex" target="_self"> <span> regex pattern </span> </a> . Can be a string or any valid <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/#std-label-aggregation-expressions"> expression </a> that resolves to a string. </p> </div> </div> </td> </tr> <tr class=""> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-regexMatch-regex" target="_self"> <span> regex </span> </a> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <span class="leafygreen-ui-1qnjd6d" id="std-label-regexMatch-regex"> </span> <p class="leafygreen-ui-1kp3ins"> The regex pattern to apply. Can be any valid <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/#std-label-aggregation-expressions"> expression </a> that resolves to either a string or regex pattern <code class="leafygreen-ui-1l06pbn"> /&lt;pattern&gt;/ </code> . When using the regex <code class="leafygreen-ui-1l06pbn"> /&lt;pattern&gt;/ </code> , you can also specify the regex options <code class="leafygreen-ui-1l06pbn"> i </code> and <code class="leafygreen-ui-1l06pbn"> m </code> (but not the <code class="leafygreen-ui-1l06pbn"> s </code> or <code class="leafygreen-ui-1l06pbn"> x </code> options): </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <code class="leafygreen-ui-1l06pbn"> "pattern" </code> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <code class="leafygreen-ui-1l06pbn"> /&lt;pattern&gt;/ </code> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <code class="leafygreen-ui-1l06pbn"> /&lt;pattern&gt;/&lt;options&gt; </code> </p> </li> </ul> <p class="leafygreen-ui-1kp3ins"> Alternatively, you can also specify the regex options with the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-regexMatch-options" target="_self"> <span> options </span> </a> field. To specify the <code class="leafygreen-ui-1l06pbn"> s </code> or <code class="leafygreen-ui-1l06pbn"> x </code> options, you must use the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-regexMatch-options" target="_self"> <span> options </span> </a> field. </p> <p class="leafygreen-ui-1kp3ins"> You cannot specify options in both the <code class="leafygreen-ui-1l06pbn"> regex </code> and the <code class="leafygreen-ui-1l06pbn"> options </code> field. </p> </div> </div> </td> </tr> <tr class=""> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-regexMatch-options" target="_self"> <span> options </span> </a> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <span class="leafygreen-ui-1qnjd6d" id="std-label-regexMatch-options"> </span> <p class="leafygreen-ui-1kp3ins"> <em> Optional </em> . The following <code class="leafygreen-ui-1l06pbn"> &lt;options&gt; </code> are available for use with regular expression. </p> <p class="leafygreen-ui-1kp3ins"> You cannot specify options in both the <code class="leafygreen-ui-1l06pbn"> regex </code> and the <code class="leafygreen-ui-1l06pbn"> options </code> field. </p> <div class="leafygreen-ui-skkc39" tabindex="0"> <table class="leafygreen-ui-hr8lsv"> <colgroup> <col style="width:10%"/> <col style="width:90%"/> </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> Option </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> <code class="leafygreen-ui-1l06pbn"> i </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Case insensitivity to match both upper and lower cases. You can specify the option in the <code class="leafygreen-ui-1l06pbn"> options </code> field or as part of the regex field. </div> </div> </td> </tr> <tr class=""> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> m </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <p class="leafygreen-ui-1kp3ins"> For patterns that include anchors (i.e. <code class="leafygreen-ui-1l06pbn"> ^ </code> for the start, <code class="leafygreen-ui-1l06pbn"> $ </code> for the end), match at the beginning or end of each line for strings with multiline values. Without this option, these anchors match at beginning or end of the string. </p> <p class="leafygreen-ui-1kp3ins"> If the pattern contains no anchors or if the string value has no newline characters (e.g. <code class="leafygreen-ui-1l06pbn"> \n </code> ), the <code class="leafygreen-ui-1l06pbn"> m </code> option has no effect. </p> </div> </div> </td> </tr> <tr class=""> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> x </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <p class="leafygreen-ui-1kp3ins"> "Extended" capability to ignore all white space characters in the pattern unless escaped or included in a character class. </p> <p class="leafygreen-ui-1kp3ins"> Additionally, it ignores characters in-between and including an un-escaped hash/pound ( <code class="leafygreen-ui-1l06pbn"> # </code> ) character and the next new line, so that you may include comments in complicated patterns. This only applies to data characters; white space characters may never appear within special character sequences in a pattern. </p> <p class="leafygreen-ui-1kp3ins"> The <code class="leafygreen-ui-1l06pbn"> x </code> option does not affect the handling of the VT character (i.e. code 11). </p> <p class="leafygreen-ui-1kp3ins"> You can specify the option only in the <code class="leafygreen-ui-1l06pbn"> options </code> field. </p> </div> </div> </td> </tr> <tr class=""> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> s </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <p class="leafygreen-ui-1kp3ins"> Allows the dot character (i.e. <code class="leafygreen-ui-1l06pbn"> . </code> ) to match all characters <em> including </em> newline characters. </p> <p class="leafygreen-ui-1kp3ins"> You can specify the option only in the <code class="leafygreen-ui-1l06pbn"> options </code> field. </p> </div> </div> </td> </tr> </tbody> </table> </div> </div> </div> </td> </tr> </tbody> </table> </div> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Returns <a class="headerlink leafygreen-ui-1kepx47" href="#returns" 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="returns"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> The operator returns a boolean: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <code class="leafygreen-ui-1l06pbn"> true </code> if a match exists. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <code class="leafygreen-ui-1l06pbn"> false </code> if a match doesn't exist. </p> </li> </ul> <div class="leafygreen-ui-13vw3ie" role="note"> <h2 class="leafygreen-ui-1fn4p2b"> Tip </h2> <h3 class="leafygreen-ui-144d5kf"> <strong> See also: </strong> </h3> <div class="leafygreen-ui-9mycqc"> <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/regexFind/#mongodb-expression-exp.-regexFind"> <code class="leafygreen-ui-1l06pbn"> $regexFind </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/regexFindAll/#mongodb-expression-exp.-regexFindAll"> <code class="leafygreen-ui-1l06pbn"> $regexFindAll </code> </a> </p> </li> </ul> </div> </div> </section> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Behavior <a class="headerlink leafygreen-ui-1kepx47" href="#behavior" 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="behavior"> </div> </a> </h2> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> PCRE Library <a class="headerlink leafygreen-ui-1kepx47" href="#pcre-library" 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="pcre-library"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> Starting in version 6.1, MongoDB uses the PCRE2 (Perl Compatible Regular Expressions) library to implement regular expression pattern matching. To learn more about PCRE2, see the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.pcre.org/current/doc/html/" rel="noopener noreferrer"> <span> PCRE Documentation <!-- --> . </span> <svg alt="" aria-hidden="true" class="leafygreen-ui-1ie5kuq" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M13.823 2.4491C13.8201 2.30008 13.6999 2.17994 13.5509 2.17704L9.5062 2.09836C9.25654 2.09351 9.12821 2.39519 9.30482 2.5718L10.3856 3.65257L7.93433 6.10383C7.87964 6.15852 7.83047 6.21665 7.78683 6.27752L5.99909 8.06525C5.46457 8.59977 5.46457 9.4664 5.99909 10.0009C6.53361 10.5354 7.40023 10.5354 7.93475 10.0009L9.72249 8.21317C9.78336 8.16953 9.84148 8.12037 9.89618 8.06567L12.3474 5.61441L13.4282 6.69518C13.6048 6.87179 13.9065 6.74347 13.9016 6.4938L13.823 2.4491Z" fill="currentColor"> </path> <path d="M7.25 3.12893C7.66421 3.12893 8 3.46472 8 3.87893C8 4.29315 7.66421 4.62893 7.25 4.62893H4C3.72386 4.62893 3.5 4.85279 3.5 5.12893V11.9929C3.5 12.2691 3.72386 12.4929 4 12.4929H10.864C11.1401 12.4929 11.364 12.2691 11.364 11.9929V8.75C11.364 8.33579 11.6998 8 12.114 8C12.5282 8 12.864 8.33579 12.864 8.75V11.9929C12.864 13.0975 11.9686 13.9929 10.864 13.9929H4C2.89543 13.9929 2 13.0975 2 11.9929V5.12893C2 4.02436 2.89543 3.12893 4 3.12893H7.25Z" fill="currentColor"> </path> </svg> </a> </p> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> <code class="leafygreen-ui-1l06pbn"> $regexMatch </code> and Collation <a class="headerlink leafygreen-ui-1kepx47" href="#-regexmatch-and-collation" 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="-regexmatch-and-collation"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-expression-exp.-regexMatch" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $regexMatch </code> </span> </a> ignores the collation specified for the collection, <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> , and the index, if used. </p> <p class="leafygreen-ui-1kp3ins"> For example, the create a sample collection with collation strength <code class="leafygreen-ui-1l06pbn"> 1 </code> (i.e. compare base character only and ignore other differences such as case and diacritics): </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.createCollection( \"myColl\", { collation: { locale: \"fr\", strength: 1 } } )","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-1q4bxgx" tabindex="0"><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">createCollection</span>( <span class="lg-highlight-string">"myColl"</span>, <!-- -->{ <span class="lg-highlight-attr">collation</span>: <!-- -->{ <span class="lg-highlight-attr">locale</span>: <span class="lg-highlight-string">"fr"</span>, <span class="lg-highlight-attr">strength</span>: <span class="lg-highlight-number">1</span> } } )</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"> Insert the following documents: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.myColl.insertMany([\n { _id: 1, category: \"café\" },\n { _id: 2, category: \"cafe\" },\n { _id: 3, category: \"cafE\" }\n])","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">myColl</span>.<span class="lg-highlight-title lg-highlight-function">insertMany</span>(<!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">1</span>, <span class="lg-highlight-attr">category</span>: <span class="lg-highlight-string">"café"</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">2</span>, <span class="lg-highlight-attr">category</span>: <span class="lg-highlight-string">"cafe"</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">3</span>, <span class="lg-highlight-attr">category</span>: <span class="lg-highlight-string">"cafE"</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">])</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"> Using the collection's collation, the following operation performs a case-insensitive and diacritic-insensitive match: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.myColl.aggregate( [ { $match: { category: \"cafe\" } } ] )","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-1q4bxgx" tabindex="0"><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">myColl</span>.<span class="lg-highlight-title lg-highlight-function">aggregate</span>( <!-- -->[ <!-- -->{ <span class="lg-highlight-attr">$match</span>: <!-- -->{ <span class="lg-highlight-attr">category</span>: <span class="lg-highlight-string">"cafe"</span> } } ] )</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 operation returns the following 3 documents: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ \"_id\" : 1, \"category\" : \"café\" }\n{ \"_id\" : 2, \"category\" : \"cafe\" }\n{ \"_id\" : 3, \"category\" : \"cafE\" }","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">1</span>, <span class="lg-highlight-string">"category"</span> <!-- -->: <span class="lg-highlight-string">"café"</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">2</span>, <span class="lg-highlight-string">"category"</span> <!-- -->: <span class="lg-highlight-string">"cafe"</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">3</span>, <span class="lg-highlight-string">"category"</span> <!-- -->: <span class="lg-highlight-string">"cafE"</span> }</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"> However, the aggregation expression <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-expression-exp.-regexMatch" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $regexMatch </code> </span> </a> ignores collation; that is, the following regular expression pattern matching examples are case-sensitive and diacritic sensitive: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.myColl.aggregate( [ { $addFields: { results: { $regexMatch: { input: \"$category\", regex: /cafe/ } } } } ] )\ndb.myColl.aggregate(\n [ { $addFields: { results: { $regexMatch: { input: \"$category\", regex: /cafe/ } } } } ],\n { collation: { locale: \"fr\", strength: 1 } } // Ignored in the $regexMatch\n)","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><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">myColl</span>.<span class="lg-highlight-title lg-highlight-function">aggregate</span>( <!-- -->[ <!-- -->{ <span class="lg-highlight-attr">$addFields</span>: <!-- -->{ <span class="lg-highlight-attr">results</span>: <!-- -->{ <span class="lg-highlight-attr">$regexMatch</span>: <!-- -->{ <span class="lg-highlight-attr">input</span>: <span class="lg-highlight-string">"$category"</span>, <span class="lg-highlight-attr">regex</span>: <span class="lg-highlight-regexp">/cafe/</span> <!-- -->} } } } ] )</td></tr><tr class=""><td class="leafygreen-ui-7razhx">db.<span class="lg-highlight-property">myColl</span>.<span class="lg-highlight-title lg-highlight-function">aggregate</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->[ <!-- -->{ <span class="lg-highlight-attr">$addFields</span>: <!-- -->{ <span class="lg-highlight-attr">results</span>: <!-- -->{ <span class="lg-highlight-attr">$regexMatch</span>: <!-- -->{ <span class="lg-highlight-attr">input</span>: <span class="lg-highlight-string">"$category"</span>, <span class="lg-highlight-attr">regex</span>: <span class="lg-highlight-regexp">/cafe/</span> <!-- -->} } } } ]<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">collation</span>: <!-- -->{ <span class="lg-highlight-attr">locale</span>: <span class="lg-highlight-string">"fr"</span>, <span class="lg-highlight-attr">strength</span>: <span class="lg-highlight-number">1</span> } } <span class="lg-highlight-comment">//</span><span class="lg-highlight-comment"> Ignored in the </span><span class="lg-highlight-comment">$regexMatch</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx">)</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"> Both operations return the following: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ \"_id\" : 1, \"category\" : \"café\", \"results\" : false }\n{ \"_id\" : 2, \"category\" : \"cafe\", \"results\" : true }\n{ \"_id\" : 3, \"category\" : \"cafE\", \"results\" : false }","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">1</span>, <span class="lg-highlight-string">"category"</span> <!-- -->: <span class="lg-highlight-string">"café"</span>, <span class="lg-highlight-string">"results"</span> <!-- -->: <span class="lg-highlight-literal">false</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">2</span>, <span class="lg-highlight-string">"category"</span> <!-- -->: <span class="lg-highlight-string">"cafe"</span>, <span class="lg-highlight-string">"results"</span> <!-- -->: <span class="lg-highlight-literal">true</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">3</span>, <span class="lg-highlight-string">"category"</span> <!-- -->: <span class="lg-highlight-string">"cafE"</span>, <span class="lg-highlight-string">"results"</span> <!-- -->: <span class="lg-highlight-literal">false</span> }</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"> To perform a case-insensitive regex pattern matching, use the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-regexMatch-example-i-options" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> i </code> Option </span> </a> instead. See <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-regexMatch-example-i-options" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> i </code> Option </span> </a> for an example. </p> </section> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Examples <a class="headerlink leafygreen-ui-1kepx47" href="#examples" 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="examples"> </div> </a> </h2> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> <code class="leafygreen-ui-1l06pbn"> $regexMatch </code> and Its Options <a class="headerlink leafygreen-ui-1kepx47" href="#-regexmatch-and-its-options" 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="-regexmatch-and-its-options"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> To illustrate the behavior of the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-expression-exp.-regexMatch" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $regexMatch </code> </span> </a> operator as discussed in this example, create a sample collection <code class="leafygreen-ui-1l06pbn"> products </code> with the following documents: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.products.insertMany([\n { _id: 1, description: \"Single LINE description.\" },\n { _id: 2, description: \"First lines\\nsecond line\" },\n { _id: 3, description: \"Many spaces before line\" },\n { _id: 4, description: \"Multiple\\nline descriptions\" },\n { _id: 5, description: \"anchors, links and hyperlinks\" },\n { _id: 6, description: \"métier work vocation\" }\n])","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><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">products</span>.<span class="lg-highlight-title lg-highlight-function">insertMany</span>(<!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">1</span>, <span class="lg-highlight-attr">description</span>: <span class="lg-highlight-string">"Single LINE description."</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">2</span>, <span class="lg-highlight-attr">description</span>: <span class="lg-highlight-string">"First lines</span><span class="lg-highlight-string">\n</span><span class="lg-highlight-string">second line"</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">3</span>, <span class="lg-highlight-attr">description</span>: <span class="lg-highlight-string">"Many spaces before line"</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">4</span>, <span class="lg-highlight-attr">description</span>: <span class="lg-highlight-string">"Multiple</span><span class="lg-highlight-string">\n</span><span class="lg-highlight-string">line descriptions"</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">5</span>, <span class="lg-highlight-attr">description</span>: <span class="lg-highlight-string">"anchors, links and hyperlinks"</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">6</span>, <span class="lg-highlight-attr">description</span>: <span class="lg-highlight-string">"métier work vocation"</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">])</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"> By default, <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-expression-exp.-regexMatch" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $regexMatch </code> </span> </a> performs a case-sensitive match. For example, the following aggregation performs a case- <em> sensitive </em> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-expression-exp.-regexMatch" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $regexMatch </code> </span> </a> on the <code class="leafygreen-ui-1l06pbn"> description </code> field. The regex pattern <code class="leafygreen-ui-1l06pbn"> /line/ </code> does not specify any grouping: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.products.aggregate([\n { $addFields: { result: { $regexMatch: { input: \"$description\", regex: /line/ } } } }\n])","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><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">products</span>.<span class="lg-highlight-title lg-highlight-function">aggregate</span>(<!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">$addFields</span>: <!-- -->{ <span class="lg-highlight-attr">result</span>: <!-- -->{ <span class="lg-highlight-attr">$regexMatch</span>: <!-- -->{ <span class="lg-highlight-attr">input</span>: <span class="lg-highlight-string">"$description"</span>, <span class="lg-highlight-attr">regex</span>: <span class="lg-highlight-regexp">/line/</span> <!-- -->} } } }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">])</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 operation returns the following: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ \"_id\" : 1, \"description\" : \"Single LINE description.\", \"result\" : false }\n{ \"_id\" : 2, \"description\" : \"First lines\\nsecond line\", \"result\" : true }\n{ \"_id\" : 3, \"description\" : \"Many spaces before line\", \"result\" : true }\n{ \"_id\" : 4, \"description\" : \"Multiple\\nline descriptions\", \"result\" : true }\n{ \"_id\" : 5, \"description\" : \"anchors, links and hyperlinks\", \"result\" : false }\n{ \"_id\" : 6, \"description\" : \"métier work vocation\", \"result\" : false }","programmingLanguage":"JavaScript"} </script> <div class="css-1lju8ps"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-tyg50d"> <pre class="leafygreen-ui-1453az5" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">1</span>, <span class="lg-highlight-string">"description"</span> <!-- -->: <span class="lg-highlight-string">"Single LINE description."</span>, <span class="lg-highlight-string">"result"</span> <!-- -->: <span class="lg-highlight-literal">false</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">2</span>, <span class="lg-highlight-string">"description"</span> <!-- -->: <span class="lg-highlight-string">"First lines</span><span class="lg-highlight-string">\n</span><span class="lg-highlight-string">second line"</span>, <span class="lg-highlight-string">"result"</span> <!-- -->: <span class="lg-highlight-literal">true</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">3</span>, <span class="lg-highlight-string">"description"</span> <!-- -->: <span class="lg-highlight-string">"Many spaces before line"</span>, <span class="lg-highlight-string">"result"</span> <!-- -->: <span class="lg-highlight-literal">true</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">4</span>, <span class="lg-highlight-string">"description"</span> <!-- -->: <span class="lg-highlight-string">"Multiple</span><span class="lg-highlight-string">\n</span><span class="lg-highlight-string">line descriptions"</span>, <span class="lg-highlight-string">"result"</span> <!-- -->: <span class="lg-highlight-literal">true</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">5</span>, <span class="lg-highlight-string">"description"</span> <!-- -->: <span class="lg-highlight-string">"anchors, links and hyperlinks"</span>, <span class="lg-highlight-string">"result"</span> <!-- -->: <span class="lg-highlight-literal">false</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">6</span>, <span class="lg-highlight-string">"description"</span> <!-- -->: <span class="lg-highlight-string">"métier work vocation"</span>, <span class="lg-highlight-string">"result"</span> <!-- -->: <span class="lg-highlight-literal">false</span> }</td></tr></tbody></table></code></pre> </div> </div> </div> <p class="leafygreen-ui-1kp3ins"> The following regex pattern <code class="leafygreen-ui-1l06pbn"> /lin(e|k)/ </code> specifies a grouping <code class="leafygreen-ui-1l06pbn"> (e|k) </code> in the pattern: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.products.aggregate([\n { $addFields: { result: { $regexMatch: { input: \"$description\", regex: /lin(e|k)/ } } } }\n])","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><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">products</span>.<span class="lg-highlight-title lg-highlight-function">aggregate</span>(<!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">$addFields</span>: <!-- -->{ <span class="lg-highlight-attr">result</span>: <!-- -->{ <span class="lg-highlight-attr">$regexMatch</span>: <!-- -->{ <span class="lg-highlight-attr">input</span>: <span class="lg-highlight-string">"$description"</span>, <span class="lg-highlight-attr">regex</span>: <span class="lg-highlight-regexp">/lin(e|k)/</span> <!-- -->} } } }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">])</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 operation returns the following: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ \"_id\" : 1, \"description\" : \"Single LINE description.\", \"result\" : false }\n{ \"_id\" : 2, \"description\" : \"First lines\\nsecond line\", \"result\" : true }\n{ \"_id\" : 3, \"description\" : \"Many spaces before line\", \"result\" : true }\n{ \"_id\" : 4, \"description\" : \"Multiple\\nline descriptions\", \"result\" : true }\n{ \"_id\" : 5, \"description\" : \"anchors, links and hyperlinks\", \"result\" : true }\n{ \"_id\" : 6, \"description\" : \"métier work vocation\", \"result\" : false }","programmingLanguage":"JavaScript"} </script> <div class="css-1lju8ps"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-tyg50d"> <pre class="leafygreen-ui-1453az5" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">1</span>, <span class="lg-highlight-string">"description"</span> <!-- -->: <span class="lg-highlight-string">"Single LINE description."</span>, <span class="lg-highlight-string">"result"</span> <!-- -->: <span class="lg-highlight-literal">false</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">2</span>, <span class="lg-highlight-string">"description"</span> <!-- -->: <span class="lg-highlight-string">"First lines</span><span class="lg-highlight-string">\n</span><span class="lg-highlight-string">second line"</span>, <span class="lg-highlight-string">"result"</span> <!-- -->: <span class="lg-highlight-literal">true</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">3</span>, <span class="lg-highlight-string">"description"</span> <!-- -->: <span class="lg-highlight-string">"Many spaces before line"</span>, <span class="lg-highlight-string">"result"</span> <!-- -->: <span class="lg-highlight-literal">true</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">4</span>, <span class="lg-highlight-string">"description"</span> <!-- -->: <span class="lg-highlight-string">"Multiple</span><span class="lg-highlight-string">\n</span><span class="lg-highlight-string">line descriptions"</span>, <span class="lg-highlight-string">"result"</span> <!-- -->: <span class="lg-highlight-literal">true</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">5</span>, <span class="lg-highlight-string">"description"</span> <!-- -->: <span class="lg-highlight-string">"anchors, links and hyperlinks"</span>, <span class="lg-highlight-string">"result"</span> <!-- -->: <span class="lg-highlight-literal">true</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">6</span>, <span class="lg-highlight-string">"description"</span> <!-- -->: <span class="lg-highlight-string">"métier work vocation"</span>, <span class="lg-highlight-string">"result"</span> <!-- -->: <span class="lg-highlight-literal">false</span> }</td></tr></tbody></table></code></pre> </div> </div> </div> <span class="leafygreen-ui-1qnjd6d" id="std-label-regexMatch-example-i-options"> </span> <section> <h4 class="contains-headerlink leafygreen-ui-1vzlt5f"> <code class="leafygreen-ui-1l06pbn"> i </code> Option <a class="headerlink leafygreen-ui-1kepx47" href="#i-option" 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="i-option"> </div> </a> </h4> <div class="leafygreen-ui-15mdk4" role="note"> <h2 class="leafygreen-ui-6n7b7d"> Note </h2> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> You cannot specify options in both the <code class="leafygreen-ui-1l06pbn"> regex </code> and the <code class="leafygreen-ui-1l06pbn"> options </code> field. </p> </div> </div> <p class="leafygreen-ui-1kp3ins"> To perform case- <em> insensitive </em> pattern matching, include the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-regexMatch-options" target="_self"> <span> i </span> </a> option as part of the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-regexMatch-regex" target="_self"> <span> regex </span> </a> field or in the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-regexMatch-options" target="_self"> <span> options </span> </a> field: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"// Specify i as part of the regex field\n{ $regexMatch: { input: \"$description\", regex: /line/i } }\n\n// Specify i in the options field\n{ $regexMatch: { input: \"$description\", regex: /line/, options: \"i\" } }\n{ $regexMatch: { input: \"$description\", regex: \"line\", options: \"i\" } }","programmingLanguage":"JavaScript"} </script> <div class="css-1lju8ps"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-tyg50d"> <pre class="leafygreen-ui-1453az5" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-comment">// Specify i as part of the regex field</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-attr">$regexMatch</span>: <!-- -->{ <span class="lg-highlight-attr">input</span>: <span class="lg-highlight-string">"$description"</span>, <span class="lg-highlight-attr">regex</span>: <span class="lg-highlight-regexp">/line/i</span> <!-- -->} }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><div class="leafygreen-ui-ihxujy"></div></td></tr><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-comment">// Specify i</span><span class="lg-highlight-comment"> in the options </span><span class="lg-highlight-comment">field</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-attr">$regexMatch</span>: <!-- -->{ <span class="lg-highlight-attr">input</span>: <span class="lg-highlight-string">"$description"</span>, <span class="lg-highlight-attr">regex</span>: <span class="lg-highlight-regexp">/line/</span>,<!-- --> <span class="lg-highlight-attr">options</span>: <span class="lg-highlight-string">"i"</span> } }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-attr">$regexMatch</span>: <!-- -->{ <span class="lg-highlight-attr">input</span>: <span class="lg-highlight-string">"$description"</span>, <span class="lg-highlight-attr">regex</span>: <span class="lg-highlight-string">"line"</span>, <span class="lg-highlight-attr">options</span>: <span class="lg-highlight-string">"i"</span> } }</td></tr></tbody></table></code></pre> </div> </div> </div> <p class="leafygreen-ui-1kp3ins"> For example, the following aggregation performs a case- <em> insensitive </em> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-expression-exp.-regexMatch" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $regexMatch </code> </span> </a> on the <code class="leafygreen-ui-1l06pbn"> description </code> field. The regex pattern <code class="leafygreen-ui-1l06pbn"> /line/ </code> does not specify any grouping: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.products.aggregate([\n { $addFields: { result: { $regexMatch: { input: \"$description\", regex: /line/i } } } }\n])","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><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">products</span>.<span class="lg-highlight-title lg-highlight-function">aggregate</span>(<!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">$addFields</span>: <!-- -->{ <span class="lg-highlight-attr">result</span>: <!-- -->{ <span class="lg-highlight-attr">$regexMatch</span>: <!-- -->{ <span class="lg-highlight-attr">input</span>: <span class="lg-highlight-string">"$description"</span>, <span class="lg-highlight-attr">regex</span>: <span class="lg-highlight-regexp">/line/i</span> <!-- -->} } } }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">])</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 operation returns the following documents: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ \"_id\" : 1, \"description\" : \"Single LINE description.\", \"result\" : true }\n{ \"_id\" : 2, \"description\" : \"First lines\\nsecond line\", \"result\" : true }\n{ \"_id\" : 3, \"description\" : \"Many spaces before line\", \"result\" : true }\n{ \"_id\" : 4, \"description\" : \"Multiple\\nline descriptions\", \"result\" : true }\n{ \"_id\" : 5, \"description\" : \"anchors, links and hyperlinks\", \"result\" : false }\n{ \"_id\" : 6, \"description\" : \"métier work vocation\", \"result\" : false }","programmingLanguage":"JavaScript"} </script> <div class="css-1lju8ps"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-tyg50d"> <pre class="leafygreen-ui-1453az5" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">1</span>, <span class="lg-highlight-string">"description"</span> <!-- -->: <span class="lg-highlight-string">"Single LINE description."</span>, <span class="lg-highlight-string">"result"</span> <!-- -->: <span class="lg-highlight-literal">true</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">2</span>, <span class="lg-highlight-string">"description"</span> <!-- -->: <span class="lg-highlight-string">"First lines</span><span class="lg-highlight-string">\n</span><span class="lg-highlight-string">second line"</span>, <span class="lg-highlight-string">"result"</span> <!-- -->: <span class="lg-highlight-literal">true</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">3</span>, <span class="lg-highlight-string">"description"</span> <!-- -->: <span class="lg-highlight-string">"Many spaces before line"</span>, <span class="lg-highlight-string">"result"</span> <!-- -->: <span class="lg-highlight-literal">true</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">4</span>, <span class="lg-highlight-string">"description"</span> <!-- -->: <span class="lg-highlight-string">"Multiple</span><span class="lg-highlight-string">\n</span><span class="lg-highlight-string">line descriptions"</span>, <span class="lg-highlight-string">"result"</span> <!-- -->: <span class="lg-highlight-literal">true</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">5</span>, <span class="lg-highlight-string">"description"</span> <!-- -->: <span class="lg-highlight-string">"anchors, links and hyperlinks"</span>, <span class="lg-highlight-string">"result"</span> <!-- -->: <span class="lg-highlight-literal">false</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">6</span>, <span class="lg-highlight-string">"description"</span> <!-- -->: <span class="lg-highlight-string">"métier work vocation"</span>, <span class="lg-highlight-string">"result"</span> <!-- -->: <span class="lg-highlight-literal">false</span> }</td></tr></tbody></table></code></pre> </div> </div> </div> </section> <section> <h4 class="contains-headerlink leafygreen-ui-1vzlt5f"> <code class="leafygreen-ui-1l06pbn"> m </code> Option <a class="headerlink leafygreen-ui-1kepx47" href="#m-option" 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="m-option"> </div> </a> </h4> <div class="leafygreen-ui-15mdk4" role="note"> <h2 class="leafygreen-ui-6n7b7d"> Note </h2> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> You cannot specify options in both the <code class="leafygreen-ui-1l06pbn"> regex </code> and the <code class="leafygreen-ui-1l06pbn"> options </code> field. </p> </div> </div> <p class="leafygreen-ui-1kp3ins"> To match the specified anchors (e.g. <code class="leafygreen-ui-1l06pbn"> ^ </code> , <code class="leafygreen-ui-1l06pbn"> $ </code> ) for each line of a multiline string, include the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-regexMatch-options" target="_self"> <span> m </span> </a> option as part of the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-regexMatch-regex" target="_self"> <span> regex </span> </a> field or in the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-regexMatch-options" target="_self"> <span> options </span> </a> field: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"// Specify m as part of the regex field\n{ $regexMatch: { input: \"$description\", regex: /line/m } }\n\n// Specify m in the options field\n{ $regexMatch: { input: \"$description\", regex: /line/, options: \"m\" } }\n{ $regexMatch: { input: \"$description\", regex: \"line\", options: \"m\" } }","programmingLanguage":"JavaScript"} </script> <div class="css-1lju8ps"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-tyg50d"> <pre class="leafygreen-ui-1453az5" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-comment">// Specify m as part of the regex field</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-attr">$regexMatch</span>: <!-- -->{ <span class="lg-highlight-attr">input</span>: <span class="lg-highlight-string">"$description"</span>, <span class="lg-highlight-attr">regex</span>: <span class="lg-highlight-regexp">/line/m</span> <!-- -->} }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><div class="leafygreen-ui-ihxujy"></div></td></tr><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-comment">// Specify m</span><span class="lg-highlight-comment"> in the options </span><span class="lg-highlight-comment">field</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-attr">$regexMatch</span>: <!-- -->{ <span class="lg-highlight-attr">input</span>: <span class="lg-highlight-string">"$description"</span>, <span class="lg-highlight-attr">regex</span>: <span class="lg-highlight-regexp">/line/</span>,<!-- --> <span class="lg-highlight-attr">options</span>: <span class="lg-highlight-string">"m"</span> } }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-attr">$regexMatch</span>: <!-- -->{ <span class="lg-highlight-attr">input</span>: <span class="lg-highlight-string">"$description"</span>, <span class="lg-highlight-attr">regex</span>: <span class="lg-highlight-string">"line"</span>, <span class="lg-highlight-attr">options</span>: <span class="lg-highlight-string">"m"</span> } }</td></tr></tbody></table></code></pre> </div> </div> </div> <p class="leafygreen-ui-1kp3ins"> The following example includes both the <code class="leafygreen-ui-1l06pbn"> i </code> and the <code class="leafygreen-ui-1l06pbn"> m </code> options to match lines starting with either the letter <code class="leafygreen-ui-1l06pbn"> s </code> or <code class="leafygreen-ui-1l06pbn"> S </code> for multiline strings: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.products.aggregate([\n { $addFields: { result: { $regexMatch: { input: \"$description\", regex: /^s/im } } } }\n])","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><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">products</span>.<span class="lg-highlight-title lg-highlight-function">aggregate</span>(<!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">$addFields</span>: <!-- -->{ <span class="lg-highlight-attr">result</span>: <!-- -->{ <span class="lg-highlight-attr">$regexMatch</span>: <!-- -->{ <span class="lg-highlight-attr">input</span>: <span class="lg-highlight-string">"$description"</span>, <span class="lg-highlight-attr">regex</span>: <span class="lg-highlight-regexp">/^s/im</span> <!-- -->} } } }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">])</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 operation returns the following: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ \"_id\" : 1, \"description\" : \"Single LINE description.\", \"result\" : true }\n{ \"_id\" : 2, \"description\" : \"First lines\\nsecond line\", \"result\" : true }\n{ \"_id\" : 3, \"description\" : \"Many spaces before line\", \"result\" : false }\n{ \"_id\" : 4, \"description\" : \"Multiple\\nline descriptions\", \"result\" : false }\n{ \"_id\" : 5, \"description\" : \"anchors, links and hyperlinks\", \"result\" : false }\n{ \"_id\" : 6, \"description\" : \"métier work vocation\", \"result\" : false }","programmingLanguage":"JavaScript"} </script> <div class="css-1lju8ps"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-tyg50d"> <pre class="leafygreen-ui-1453az5" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">1</span>, <span class="lg-highlight-string">"description"</span> <!-- -->: <span class="lg-highlight-string">"Single LINE description."</span>, <span class="lg-highlight-string">"result"</span> <!-- -->: <span class="lg-highlight-literal">true</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">2</span>, <span class="lg-highlight-string">"description"</span> <!-- -->: <span class="lg-highlight-string">"First lines</span><span class="lg-highlight-string">\n</span><span class="lg-highlight-string">second line"</span>, <span class="lg-highlight-string">"result"</span> <!-- -->: <span class="lg-highlight-literal">true</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">3</span>, <span class="lg-highlight-string">"description"</span> <!-- -->: <span class="lg-highlight-string">"Many spaces before line"</span>, <span class="lg-highlight-string">"result"</span> <!-- -->: <span class="lg-highlight-literal">false</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">4</span>, <span class="lg-highlight-string">"description"</span> <!-- -->: <span class="lg-highlight-string">"Multiple</span><span class="lg-highlight-string">\n</span><span class="lg-highlight-string">line descriptions"</span>, <span class="lg-highlight-string">"result"</span> <!-- -->: <span class="lg-highlight-literal">false</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">5</span>, <span class="lg-highlight-string">"description"</span> <!-- -->: <span class="lg-highlight-string">"anchors, links and hyperlinks"</span>, <span class="lg-highlight-string">"result"</span> <!-- -->: <span class="lg-highlight-literal">false</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">6</span>, <span class="lg-highlight-string">"description"</span> <!-- -->: <span class="lg-highlight-string">"métier work vocation"</span>, <span class="lg-highlight-string">"result"</span> <!-- -->: <span class="lg-highlight-literal">false</span> }</td></tr></tbody></table></code></pre> </div> </div> </div> </section> <section> <h4 class="contains-headerlink leafygreen-ui-1vzlt5f"> <code class="leafygreen-ui-1l06pbn"> x </code> Option <a class="headerlink leafygreen-ui-1kepx47" href="#x-option" 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="x-option"> </div> </a> </h4> <div class="leafygreen-ui-15mdk4" role="note"> <h2 class="leafygreen-ui-6n7b7d"> Note </h2> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> You cannot specify options in both the <code class="leafygreen-ui-1l06pbn"> regex </code> and the <code class="leafygreen-ui-1l06pbn"> options </code> field. </p> </div> </div> <p class="leafygreen-ui-1kp3ins"> To ignore all unescaped white space characters and comments (denoted by the un-escaped hash <code class="leafygreen-ui-1l06pbn"> # </code> character and the next new-line character) in the pattern, include the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-regexMatch-options" target="_self"> <span> s </span> </a> option in the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-regexMatch-options" target="_self"> <span> options </span> </a> field: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"// Specify x in the options field\n{ $regexMatch: { input: \"$description\", regex: /line/, options: \"x\" } }\n{ $regexMatch: { input: \"$description\", regex: \"line\", options: \"x\" } }","programmingLanguage":"JavaScript"} </script> <div class="css-1lju8ps"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-tyg50d"> <pre class="leafygreen-ui-1453az5" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-comment">// Specify x</span><span class="lg-highlight-comment"> in the options </span><span class="lg-highlight-comment">field</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-attr">$regexMatch</span>: <!-- -->{ <span class="lg-highlight-attr">input</span>: <span class="lg-highlight-string">"$description"</span>, <span class="lg-highlight-attr">regex</span>: <span class="lg-highlight-regexp">/line/</span>,<!-- --> <span class="lg-highlight-attr">options</span>: <span class="lg-highlight-string">"x"</span> } }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-attr">$regexMatch</span>: <!-- -->{ <span class="lg-highlight-attr">input</span>: <span class="lg-highlight-string">"$description"</span>, <span class="lg-highlight-attr">regex</span>: <span class="lg-highlight-string">"line"</span>, <span class="lg-highlight-attr">options</span>: <span class="lg-highlight-string">"x"</span> } }</td></tr></tbody></table></code></pre> </div> </div> </div> <p class="leafygreen-ui-1kp3ins"> The following example includes the <code class="leafygreen-ui-1l06pbn"> x </code> option to skip unescaped white spaces and comments: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.products.aggregate([\n { $addFields: { returns: { $regexMatch: { input: \"$description\", regex: /lin(e|k) # matches line or link/, options:\"x\" } } } }\n])","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><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">products</span>.<span class="lg-highlight-title lg-highlight-function">aggregate</span>(<!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">$addFields</span>: <!-- -->{ <span class="lg-highlight-attr">returns</span>: <!-- -->{ <span class="lg-highlight-attr">$regexMatch</span>: <!-- -->{ <span class="lg-highlight-attr">input</span>: <span class="lg-highlight-string">"$description"</span>, <span class="lg-highlight-attr">regex</span>: <span class="lg-highlight-regexp">/lin(e|k) # matches line or link/</span>,<!-- --> <span class="lg-highlight-attr">options</span>:<span class="lg-highlight-string">"x"</span> } } } }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">])</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 operation returns the following: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ \"_id\" : 1, \"description\" : \"Single LINE description.\", \"returns\" : false }\n{ \"_id\" : 2, \"description\" : \"First lines\\nsecond line\", \"returns\" : true }\n{ \"_id\" : 3, \"description\" : \"Many spaces before line\", \"returns\" : true }\n{ \"_id\" : 4, \"description\" : \"Multiple\\nline descriptions\", \"returns\" : true }\n{ \"_id\" : 5, \"description\" : \"anchors, links and hyperlinks\", \"returns\" : true }\n{ \"_id\" : 6, \"description\" : \"métier work vocation\", \"returns\" : false }","programmingLanguage":"JavaScript"} </script> <div class="css-1lju8ps"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-tyg50d"> <pre class="leafygreen-ui-1453az5" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">1</span>, <span class="lg-highlight-string">"description"</span> <!-- -->: <span class="lg-highlight-string">"Single LINE description."</span>, <span class="lg-highlight-string">"returns"</span> <!-- -->: <span class="lg-highlight-literal">false</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">2</span>, <span class="lg-highlight-string">"description"</span> <!-- -->: <span class="lg-highlight-string">"First lines</span><span class="lg-highlight-string">\n</span><span class="lg-highlight-string">second line"</span>, <span class="lg-highlight-string">"returns"</span> <!-- -->: <span class="lg-highlight-literal">true</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">3</span>, <span class="lg-highlight-string">"description"</span> <!-- -->: <span class="lg-highlight-string">"Many spaces before line"</span>, <span class="lg-highlight-string">"returns"</span> <!-- -->: <span class="lg-highlight-literal">true</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">4</span>, <span class="lg-highlight-string">"description"</span> <!-- -->: <span class="lg-highlight-string">"Multiple</span><span class="lg-highlight-string">\n</span><span class="lg-highlight-string">line descriptions"</span>, <span class="lg-highlight-string">"returns"</span> <!-- -->: <span class="lg-highlight-literal">true</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">5</span>, <span class="lg-highlight-string">"description"</span> <!-- -->: <span class="lg-highlight-string">"anchors, links and hyperlinks"</span>, <span class="lg-highlight-string">"returns"</span> <!-- -->: <span class="lg-highlight-literal">true</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">6</span>, <span class="lg-highlight-string">"description"</span> <!-- -->: <span class="lg-highlight-string">"métier work vocation"</span>, <span class="lg-highlight-string">"returns"</span> <!-- -->: <span class="lg-highlight-literal">false</span> }</td></tr></tbody></table></code></pre> </div> </div> </div> </section> <section> <h4 class="contains-headerlink leafygreen-ui-1vzlt5f"> <code class="leafygreen-ui-1l06pbn"> s </code> Option <a class="headerlink leafygreen-ui-1kepx47" href="#s-option" 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="s-option"> </div> </a> </h4> <div class="leafygreen-ui-15mdk4" role="note"> <h2 class="leafygreen-ui-6n7b7d"> Note </h2> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> You cannot specify options in both the <code class="leafygreen-ui-1l06pbn"> regex </code> and the <code class="leafygreen-ui-1l06pbn"> options </code> field. </p> </div> </div> <p class="leafygreen-ui-1kp3ins"> To allow the dot character (i.e. <code class="leafygreen-ui-1l06pbn"> . </code> ) in the pattern to match all characters including the new line character, include the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-regexMatch-options" target="_self"> <span> s </span> </a> option in the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-regexMatch-options" target="_self"> <span> options </span> </a> field: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"// Specify s in the options field\n{ $regexMatch: { input: \"$description\", regex: /m.*line/, options: \"s\" } }\n{ $regexMatch: { input: \"$description\", regex: \"m.*line\", options: \"s\" } }","programmingLanguage":"JavaScript"} </script> <div class="css-1lju8ps"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-tyg50d"> <pre class="leafygreen-ui-1453az5" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-comment">// Specify s</span><span class="lg-highlight-comment"> in the options </span><span class="lg-highlight-comment">field</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-attr">$regexMatch</span>: <!-- -->{ <span class="lg-highlight-attr">input</span>: <span class="lg-highlight-string">"$description"</span>, <span class="lg-highlight-attr">regex</span>: <span class="lg-highlight-regexp">/m.*line/</span>,<!-- --> <span class="lg-highlight-attr">options</span>: <span class="lg-highlight-string">"s"</span> } }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-attr">$regexMatch</span>: <!-- -->{ <span class="lg-highlight-attr">input</span>: <span class="lg-highlight-string">"$description"</span>, <span class="lg-highlight-attr">regex</span>: <span class="lg-highlight-string">"m.*line"</span>, <span class="lg-highlight-attr">options</span>: <span class="lg-highlight-string">"s"</span> } }</td></tr></tbody></table></code></pre> </div> </div> </div> <p class="leafygreen-ui-1kp3ins"> The following example includes the <code class="leafygreen-ui-1l06pbn"> s </code> option to allow the dot character (i.e. .) to match all characters including new line as well as the <code class="leafygreen-ui-1l06pbn"> i </code> option to perform a case-insensitive match: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.products.aggregate([\n { $addFields: { returns: { $regexMatch: { input: \"$description\", regex:/m.*line/, options: \"si\" } } } }\n])","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><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">products</span>.<span class="lg-highlight-title lg-highlight-function">aggregate</span>(<!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">$addFields</span>: <!-- -->{ <span class="lg-highlight-attr">returns</span>: <!-- -->{ <span class="lg-highlight-attr">$regexMatch</span>: <!-- -->{ <span class="lg-highlight-attr">input</span>: <span class="lg-highlight-string">"$description"</span>, <span class="lg-highlight-attr">regex</span>:<span class="lg-highlight-regexp">/m.*line/</span>,<!-- --> <span class="lg-highlight-attr">options</span>: <span class="lg-highlight-string">"si"</span> } } } }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">])</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 operation returns the following: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ \"_id\" : 1, \"description\" : \"Single LINE description.\", \"returns\" : false }\n{ \"_id\" : 2, \"description\" : \"First lines\\nsecond line\", \"returns\" : false }\n{ \"_id\" : 3, \"description\" : \"Many spaces before line\", \"returns\" : true }\n{ \"_id\" : 4, \"description\" : \"Multiple\\nline descriptions\", \"returns\" : true }\n{ \"_id\" : 5, \"description\" : \"anchors, links and hyperlinks\", \"returns\" : false }\n{ \"_id\" : 6, \"description\" : \"métier work vocation\", \"returns\" : false }","programmingLanguage":"JavaScript"} </script> <div class="css-1lju8ps"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-tyg50d"> <pre class="leafygreen-ui-1453az5" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">1</span>, <span class="lg-highlight-string">"description"</span> <!-- -->: <span class="lg-highlight-string">"Single LINE description."</span>, <span class="lg-highlight-string">"returns"</span> <!-- -->: <span class="lg-highlight-literal">false</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">2</span>, <span class="lg-highlight-string">"description"</span> <!-- -->: <span class="lg-highlight-string">"First lines</span><span class="lg-highlight-string">\n</span><span class="lg-highlight-string">second line"</span>, <span class="lg-highlight-string">"returns"</span> <!-- -->: <span class="lg-highlight-literal">false</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">3</span>, <span class="lg-highlight-string">"description"</span> <!-- -->: <span class="lg-highlight-string">"Many spaces before line"</span>, <span class="lg-highlight-string">"returns"</span> <!-- -->: <span class="lg-highlight-literal">true</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">4</span>, <span class="lg-highlight-string">"description"</span> <!-- -->: <span class="lg-highlight-string">"Multiple</span><span class="lg-highlight-string">\n</span><span class="lg-highlight-string">line descriptions"</span>, <span class="lg-highlight-string">"returns"</span> <!-- -->: <span class="lg-highlight-literal">true</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">5</span>, <span class="lg-highlight-string">"description"</span> <!-- -->: <span class="lg-highlight-string">"anchors, links and hyperlinks"</span>, <span class="lg-highlight-string">"returns"</span> <!-- -->: <span class="lg-highlight-literal">false</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">6</span>, <span class="lg-highlight-string">"description"</span> <!-- -->: <span class="lg-highlight-string">"métier work vocation"</span>, <span class="lg-highlight-string">"returns"</span> <!-- -->: <span class="lg-highlight-literal">false</span> }</td></tr></tbody></table></code></pre> </div> </div> </div> </section> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Use <code class="leafygreen-ui-1l06pbn"> $regexMatch </code> to Check Email Address <a class="headerlink leafygreen-ui-1kepx47" href="#use--regexmatch-to-check-email-address" 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="use--regexmatch-to-check-email-address"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> Create a sample collection <code class="leafygreen-ui-1l06pbn"> feedback </code> with the following documents: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.feedback.insertMany([\n { \"_id\" : 1, comment: \"Hi, I'm just reading about MongoDB -- [email protected]\" },\n { \"_id\" : 2, comment: \"I wanted to concatenate a string\" },\n { \"_id\" : 3, comment: \"How do I convert a date to string? Contact me at either [email protected] or [email protected]\" },\n { \"_id\" : 4, comment: \"It's just me. I'm testing. [email protected]\" }\n])","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><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">feedback</span>.<span class="lg-highlight-title lg-highlight-function">insertMany</span>(<!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">1</span>, <span class="lg-highlight-attr">comment</span>: <span class="lg-highlight-string">"Hi, I'm just reading about MongoDB -- [email protected]"</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">2</span>, <span class="lg-highlight-attr">comment</span>: <span class="lg-highlight-string">"I wanted to concatenate a string"</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">3</span>, <span class="lg-highlight-attr">comment</span>: <span class="lg-highlight-string">"How do I convert a date to string? Contact me at either [email protected] or [email protected]"</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">4</span>, <span class="lg-highlight-attr">comment</span>: <span class="lg-highlight-string">"It's just me. I'm testing. [email protected]"</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">])</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 aggregation uses the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-expression-exp.-regexMatch" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $regexMatch </code> </span> </a> to check if the <code class="leafygreen-ui-1l06pbn"> comment </code> field contains an email address with <code class="leafygreen-ui-1l06pbn"> @mongodb.com </code> and categorize the feedback as <code class="leafygreen-ui-1l06pbn"> Employee </code> or <code class="leafygreen-ui-1l06pbn"> External </code> . </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.feedback.aggregate( [\n { $addFields: {\n \"category\": { $cond: { if: { $regexMatch: { input: \"$comment\", regex: /[a-z0-9_.+-][email protected]/i } },\n then: \"Employee\",\n else: \"External\" } }\n } },","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><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">feedback</span>.<span class="lg-highlight-title lg-highlight-function">aggregate</span>( <!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">$addFields</span>: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"category"</span>: <!-- -->{ <span class="lg-highlight-attr">$cond</span>: <!-- -->{ <span class="lg-highlight-attr">if</span>: <!-- -->{ <span class="lg-highlight-attr">$regexMatch</span>: <!-- -->{ <span class="lg-highlight-attr">input</span>: <span class="lg-highlight-string">"$comment"</span>, <span class="lg-highlight-attr">regex</span>: <span class="lg-highlight-regexp">/</span><span class="lg-highlight-regexp">[a-z0-9_.+-]</span><span class="lg-highlight-regexp">[email protected]/i</span> <!-- -->} }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">then</span>: <span class="lg-highlight-string">"Employee"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">else</span>: <span class="lg-highlight-string">"External"</span> } }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> } }<!-- -->,</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 operation returns the following documents: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ \"_id\" : 1, \"comment\" : \"Hi, I'm just reading about MongoDB -- [email protected]\", \"category\" : \"External\" }\n{ \"_id\" : 2, \"comment\" : \"I wanted to concatenate a string\", \"category\" : \"External\" }\n{ \"_id\" : 3, \"comment\" : \"How do I convert a date to string? Contact me at either [email protected] or [email protected]\", \"category\" : \"Employee\" }\n{ \"_id\" : 4, \"comment\" : \"It's just me. I'm testing. [email protected]\", \"category\" : \"Employee\" }","programmingLanguage":"JavaScript"} </script> <div class="css-1lju8ps"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-tyg50d"> <pre class="leafygreen-ui-1453az5" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">1</span>, <span class="lg-highlight-string">"comment"</span> <!-- -->: <span class="lg-highlight-string">"Hi, I'm just reading about MongoDB -- [email protected]"</span>, <span class="lg-highlight-string">"category"</span> <!-- -->: <span class="lg-highlight-string">"External"</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">2</span>, <span class="lg-highlight-string">"comment"</span> <!-- -->: <span class="lg-highlight-string">"I wanted to concatenate a string"</span>, <span class="lg-highlight-string">"category"</span> <!-- -->: <span class="lg-highlight-string">"External"</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">3</span>, <span class="lg-highlight-string">"comment"</span> <!-- -->: <span class="lg-highlight-string">"How do I convert a date to string? Contact me at either [email protected] or [email protected]"</span>, <span class="lg-highlight-string">"category"</span> <!-- -->: <span class="lg-highlight-string">"Employee"</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">4</span>, <span class="lg-highlight-string">"comment"</span> <!-- -->: <span class="lg-highlight-string">"It's just me. I'm testing. [email protected]"</span>, <span class="lg-highlight-string">"category"</span> <!-- -->: <span class="lg-highlight-string">"Employee"</span> }</td></tr></tbody></table></code></pre> </div> </div> </div> </section> </section> </section>
https://www.mongodb.com/docs/manual/core/security-data-encryption/
<section> <h1 class="contains-headerlink leafygreen-ui-41fr9s" weight="medium"> Encryption <a class="headerlink leafygreen-ui-1kepx47" href="#encryption" 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="encryption"> </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="#in-use-encryption" target="_self"> <span> In-Use Encryption </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#encryption-at-rest" target="_self"> <span> Encryption at Rest </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#tls-ssl--transport-encryption-" target="_self"> <span> TLS/SSL (Transport Encryption) </span> </a> </li> </ul> </div> <p class="leafygreen-ui-1kp3ins"> MongoDB provides the following encryption methods: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/security-in-use-encryption/#std-label-security-in-use-encryption"> In-Use Encryption </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/security-encryption-at-rest/#std-label-security-encryption-at-rest"> Encryption at Rest </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/security-transport-encryption/#std-label-transport-encryption"> TLS/SSL (Transport Encryption) </a> </p> </li> </ul> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> In-Use Encryption <a class="headerlink leafygreen-ui-1kepx47" href="#in-use-encryption" 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="in-use-encryption"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> MongoDB provides two approaches to <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-In-Use-Encryption"> In-Use Encryption <!-- --> : </a> </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/queryable-encryption/#std-label-qe-manual-feature-qe"> Queryable Encryption </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/csfle/#std-label-manual-csfle-feature"> Client-Side Field Level Encryption <!-- --> . </a> </p> </li> </ul> <p class="leafygreen-ui-1kp3ins"> For more information, see <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/security-in-use-encryption/#std-label-security-in-use-encryption"> In-Use Encryption <!-- --> . </a> </p> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Encryption at Rest <a class="headerlink leafygreen-ui-1kepx47" href="#encryption-at-rest" 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="encryption-at-rest"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> Encryption at rest, when used in conjunction with transport encryption and security policies that protect relevant accounts, passwords, and encryption keys, can help ensure compliance with security and privacy standards, including HIPAA, PCI-DSS, and FERPA. </p> <p class="leafygreen-ui-1kp3ins"> For more information, see <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/security-encryption-at-rest/#std-label-security-encryption-at-rest"> Encryption at Rest <!-- --> . </a> </p> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> TLS/SSL (Transport Encryption) <a class="headerlink leafygreen-ui-1kepx47" href="#tls-ssl--transport-encryption-" 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="tls-ssl--transport-encryption-"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> MongoDB supports TLS/SSL (Transport Layer Security/Secure Sockets Layer) to encrypt all of MongoDB's network traffic. TLS/SSL ensures that MongoDB network traffic is only readable by the intended client. </p> <p class="leafygreen-ui-1kp3ins"> For more information, see <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/security-transport-encryption/#std-label-transport-encryption"> TLS/SSL (Transport Encryption) <!-- --> . </a> </p> </section> </section>
https://www.mongodb.com/docs/manual/tutorial/sharding-segmenting-data-by-location/
<section> <h1 class="contains-headerlink leafygreen-ui-41fr9s" weight="medium"> Segmenting Data by Location <a class="headerlink leafygreen-ui-1kepx47" href="#segmenting-data-by-location" 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="segmenting-data-by-location"> </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="#scenario" target="_self"> <span> Scenario </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#procedure" target="_self"> <span> Procedure </span> </a> </li> </ul> </div> <p class="leafygreen-ui-1kp3ins"> In sharded clusters, you can create <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-zone"> zones </a> of sharded data based on the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-shard-key"> shard key </a> . You can associate each zone with one or more shards in the cluster. A shard can associate with any number of zones. In a balanced cluster, MongoDB migrates <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-chunk"> chunks </a> covered by a zone only to those shards associated with the zone. </p> <div class="leafygreen-ui-13vw3ie" role="note"> <h2 class="leafygreen-ui-1fn4p2b"> Tip </h2> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> By defining the zones and the zone ranges <em> before </em> sharding an empty or a non-existing collection, the shard collection operation creates chunks for the defined zone ranges as well as any additional chunks to cover the entire range of the shard key values and performs an initial chunk distribution based on the zone ranges. This initial creation and distribution of chunks allows for faster setup of zoned sharding. After the initial distribution, the balancer manages the chunk distribution going forward. </p> <p class="leafygreen-ui-1kp3ins"> See <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/sh.updateZoneKeyRange/#std-label-pre-define-zone-range-example"> Pre-Define Zones and Zone Ranges for an Empty or Non-Existing Collection </a> for an example. </p> </div> </div> <p class="leafygreen-ui-1kp3ins"> This tutorial uses <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/zone-sharding/#std-label-zone-sharding"> Zones </a> to segment data based on a geographic area. </p> <p class="leafygreen-ui-1kp3ins"> The following are some example use cases for segmenting data by geographic area: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> An application that has to segment user data by country </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> A database that has to allocate resources by country </p> </li> </ul> <p class="leafygreen-ui-1kp3ins"> The following diagram illustrates a sharded cluster that uses geographic zones to manage and satisfy data segmentation requirements. </p> <div class="figure css-5vkxs0" style="width:700px"> <img alt="Diagram geo distribution based on zones" class="leafygreen-ui-1qnf57e" height="300" src="/docs/manual/images/sharding-segmenting-data-by-location-overview.bakedsvg.svg" style="--border-color:#C1C7C6" width="582"/> </div> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Scenario <a class="headerlink leafygreen-ui-1kepx47" href="#scenario" 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="scenario"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> A financial chat application logs messages, tracking the country of the originating user. The application stores the logs in the <code class="leafygreen-ui-1l06pbn"> chat </code> database under the <code class="leafygreen-ui-1l06pbn"> messages </code> collection. The chats contain information that must be segmented by country to have servers local to the country serve read and write requests for the country's users. A group of countries can be assigned same zone in order to share resources. </p> <p class="leafygreen-ui-1kp3ins"> The application currently has users in the US, UK, and Germany. The <code class="leafygreen-ui-1l06pbn"> country </code> field represents the user's country based on its <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2" rel="noopener noreferrer"> <span> ISO 3166-1 Alpha-2 </span> <svg alt="" aria-hidden="true" class="leafygreen-ui-1ie5kuq" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M13.823 2.4491C13.8201 2.30008 13.6999 2.17994 13.5509 2.17704L9.5062 2.09836C9.25654 2.09351 9.12821 2.39519 9.30482 2.5718L10.3856 3.65257L7.93433 6.10383C7.87964 6.15852 7.83047 6.21665 7.78683 6.27752L5.99909 8.06525C5.46457 8.59977 5.46457 9.4664 5.99909 10.0009C6.53361 10.5354 7.40023 10.5354 7.93475 10.0009L9.72249 8.21317C9.78336 8.16953 9.84148 8.12037 9.89618 8.06567L12.3474 5.61441L13.4282 6.69518C13.6048 6.87179 13.9065 6.74347 13.9016 6.4938L13.823 2.4491Z" fill="currentColor"> </path> <path d="M7.25 3.12893C7.66421 3.12893 8 3.46472 8 3.87893C8 4.29315 7.66421 4.62893 7.25 4.62893H4C3.72386 4.62893 3.5 4.85279 3.5 5.12893V11.9929C3.5 12.2691 3.72386 12.4929 4 12.4929H10.864C11.1401 12.4929 11.364 12.2691 11.364 11.9929V8.75C11.364 8.33579 11.6998 8 12.114 8C12.5282 8 12.864 8.33579 12.864 8.75V11.9929C12.864 13.0975 11.9686 13.9929 10.864 13.9929H4C2.89543 13.9929 2 13.0975 2 11.9929V5.12893C2 4.02436 2.89543 3.12893 4 3.12893H7.25Z" fill="currentColor"> </path> </svg> </a> two-character country codes. </p> <p class="leafygreen-ui-1kp3ins"> The following documents represent a partial view of three chat messages: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{\n \"_id\" : ObjectId(\"56f08c447fe58b2e96f595fa\"),\n \"country\" : \"US\",\n \"userid\" : 123,\n \"message\" : \"Hello there\",\n ...,\n}\n{\n \"_id\" : ObjectId(\"56f08c447fe58b2e96f595fb\"),\n \"country\" : \"UK\",\n \"userid\" : 456,\n \"message\" : \"Good Morning\"\n ...,\n}\n{\n \"_id\" : ObjectId(\"56f08c447fe58b2e96f595fc\"),\n \"country\" : \"DE\",\n \"userid\" : 789,\n \"message\" : \"Guten Tag\"\n ...,\n}","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">ObjectId</span>(<span class="lg-highlight-string">"56f08c447fe58b2e96f595fa"</span>)<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"country"</span> <!-- -->: <span class="lg-highlight-string">"US"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"userid"</span> <!-- -->: <span class="lg-highlight-number">123</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"message"</span> <!-- -->: <span class="lg-highlight-string">"Hello there"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->...<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">}</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">ObjectId</span>(<span class="lg-highlight-string">"56f08c447fe58b2e96f595fb"</span>)<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"country"</span> <!-- -->: <span class="lg-highlight-string">"UK"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"userid"</span> <!-- -->: <span class="lg-highlight-number">456</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"message"</span> <!-- -->: <span class="lg-highlight-string">"Good Morning"</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->...<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">}</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">ObjectId</span>(<span class="lg-highlight-string">"56f08c447fe58b2e96f595fc"</span>)<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"country"</span> <!-- -->: <span class="lg-highlight-string">"DE"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"userid"</span> <!-- -->: <span class="lg-highlight-number">789</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"message"</span> <!-- -->: <span class="lg-highlight-string">"Guten Tag"</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->...<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">}</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> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Shard Key <a class="headerlink leafygreen-ui-1kepx47" href="#shard-key" 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="shard-key"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> The <code class="leafygreen-ui-1l06pbn"> messages </code> collection uses the <code class="leafygreen-ui-1l06pbn"> { country : 1, userid : 1 } </code> compound index as the shard key. </p> <p class="leafygreen-ui-1kp3ins"> The <code class="leafygreen-ui-1l06pbn"> country </code> field in each document allows for creating a zone for each distinct country value. </p> <p class="leafygreen-ui-1kp3ins"> The <code class="leafygreen-ui-1l06pbn"> userid </code> field provides a high <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/sharding-choose-a-shard-key/#std-label-shard-key-cardinality"> cardinality </a> and low <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/sharding-choose-a-shard-key/#std-label-shard-key-frequency"> frequency </a> component to the shard key relative to <code class="leafygreen-ui-1l06pbn"> country </code> . </p> <p class="leafygreen-ui-1kp3ins"> See <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/sharding-choose-a-shard-key/#std-label-sharding-shard-key-requirements"> Choosing a Shard Key </a> for more general instructions on selecting a shard key. </p> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Architecture <a class="headerlink leafygreen-ui-1kepx47" href="#architecture" 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="architecture"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> The sharded cluster has shards in two data centers - one in Europe, and one in North America. </p> <div class="figure css-5vkxs0" style="width:700px"> <img alt="Diagram of zones used for supporting geo distribution architecture" class="leafygreen-ui-1qnf57e" height="297" src="/docs/manual/images/sharding-segmenting-data-by-location-architecture.bakedsvg.svg" style="--border-color:#C1C7C6" width="600"/> </div> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Zones <a class="headerlink leafygreen-ui-1kepx47" href="#zones" 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="zones"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> This application requires one zone per data center. </p> <dl> <dt> <code class="leafygreen-ui-1l06pbn"> EU </code> - European data center </dt> <dd class="css-1ufxuu7"> <p class="leafygreen-ui-1kp3ins"> Shards deployed on this data center are assigned to the <code class="leafygreen-ui-1l06pbn"> EU </code> zone. </p> <p class="leafygreen-ui-1kp3ins"> For each country using the <code class="leafygreen-ui-1l06pbn"> EU </code> data center for local reads and writes, create a zone range for the <code class="leafygreen-ui-1l06pbn"> EU </code> zone with: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> a lower bound of <code class="leafygreen-ui-1l06pbn"> { "country" : &lt;country&gt;, "userid" : MinKey } </code> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> an upper bound of <code class="leafygreen-ui-1l06pbn"> { "country" : &lt;country&gt;, "userid" : MaxKey } </code> </p> </li> </ul> </dd> <dt> <code class="leafygreen-ui-1l06pbn"> NA </code> - North American data center </dt> <dd class="css-1ufxuu7"> <p class="leafygreen-ui-1kp3ins"> Shards deployed on this data center are assigned to the <code class="leafygreen-ui-1l06pbn"> NA </code> zone. </p> <p class="leafygreen-ui-1kp3ins"> For each country using the <code class="leafygreen-ui-1l06pbn"> NA </code> data center for local reads and writes, create a zone range for the <code class="leafygreen-ui-1l06pbn"> NA </code> zone with: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> a lower bound of <code class="leafygreen-ui-1l06pbn"> { "country" : &lt;country&gt;, "userid" : MinKey } </code> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> an upper bound of <code class="leafygreen-ui-1l06pbn"> { "country" : &lt;country&gt;, "userid" : MaxKey } </code> </p> </li> </ul> </dd> </dl> <div class="leafygreen-ui-15mdk4" role="note"> <h2 class="leafygreen-ui-6n7b7d"> Note </h2> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> The <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/mongodb-extended-json/#mongodb-bsontype-MinKey"> <code class="leafygreen-ui-1l06pbn"> MinKey </code> </a> and <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/mongodb-extended-json/#mongodb-bsontype-MaxKey"> <code class="leafygreen-ui-1l06pbn"> MaxKey </code> </a> values are reserved special values for comparisons </p> </div> </div> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Write Operations <a class="headerlink leafygreen-ui-1kepx47" href="#write-operations" 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="write-operations"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> With zones, if an inserted or updated document matches a configured zone, it can only be written to a shard inside of that zone. </p> <p class="leafygreen-ui-1kp3ins"> MongoDB can write documents that do not match a configured zone to any shard in the cluster. </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"> The behavior described above requires the cluster to be in a steady state with no chunks violating a configured zone. See the following section on the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-sharding-segmenting-data-by-location-balancer" target="_self"> <span> balancer </span> </a> for more information. </p> </div> </div> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Read Operations <a class="headerlink leafygreen-ui-1kepx47" href="#read-operations" 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="read-operations"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> MongoDB can route queries to a specific shard if the query includes at least the <code class="leafygreen-ui-1l06pbn"> country </code> field. </p> <p class="leafygreen-ui-1kp3ins"> For example, MongoDB can attempt a <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/sharded-cluster-query-router/#std-label-sharding-mongos-targeted"> targeted read operation </a> on the following query: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"chatDB = db.getSiblingDB(\"chat\")\nchatDB.messages.find( { \"country\" : \"UK\" , \"userid\" : \"123\" } )","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">chatDB <!-- -->= <!-- -->db.<span class="lg-highlight-title lg-highlight-function">getSiblingDB</span>(<span class="lg-highlight-string">"chat"</span>)</td></tr><tr class=""><td class="leafygreen-ui-7razhx">chatDB.<span class="lg-highlight-property">messages</span>.<span class="lg-highlight-title lg-highlight-function">find</span>( <!-- -->{ <span class="lg-highlight-string">"country"</span> <!-- -->: <span class="lg-highlight-string">"UK"</span> <!-- -->, <span class="lg-highlight-string">"userid"</span> <!-- -->: <span class="lg-highlight-string">"123"</span> } )</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"> Queries without the <code class="leafygreen-ui-1l06pbn"> country </code> field perform <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/sharded-cluster-query-router/#std-label-sharding-mongos-broadcast"> broadcast operations <!-- --> . </a> </p> <span class="leafygreen-ui-1qnjd6d" id="std-label-sharding-segmenting-data-by-location-balancer"> </span> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Balancer <a class="headerlink leafygreen-ui-1kepx47" href="#balancer" 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="balancer"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> The <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/sharding-balancer-administration/#std-label-sharding-balancing"> balancer </a> <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/sharding-data-partitioning/#std-label-sharding-chunk-migration"> migrates </a> chunks to the appropriate shard respecting any configured zones. Until the migration, shards may contain chunks that violate configured zones. Once balancing completes, shards should only contain chunks whose ranges do not violate its assigned zones. </p> <p class="leafygreen-ui-1kp3ins"> Adding or removing zones or zone ranges can result in chunk migrations. Depending on the size of your data set and the number of chunks a zone or zone range affects, these migrations may impact cluster performance. Consider running your <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/sharding-balancer-administration/#std-label-sharding-balancing"> balancer </a> during specific scheduled windows. See <a class="leafygreen-ui-tqgtui" href="/docs/manual/tutorial/manage-sharded-cluster-balancer/#std-label-sharding-schedule-balancing-window"> Schedule the Balancing Window </a> for a tutorial on how to set a scheduling window. </p> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Security <a class="headerlink leafygreen-ui-1kepx47" href="#security" 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="security"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> For sharded clusters running with <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/authorization/#std-label-authorization"> Role-Based Access Control in Self-Managed Deployments </a> , authenticate as a user with at least the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/built-in-roles/#mongodb-authrole-clusterManager"> <code class="leafygreen-ui-1l06pbn"> clusterManager </code> </a> role on the <code class="leafygreen-ui-1l06pbn"> admin </code> database. </p> </section> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Procedure <a class="headerlink leafygreen-ui-1kepx47" href="#procedure" 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="procedure"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> You must be connected to a <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongos/#mongodb-binary-bin.mongos"> <code class="leafygreen-ui-1l06pbn"> mongos </code> </a> to create zones and zone ranges. You cannot create zones or zone ranges by connecting directly to a <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-shard"> shard <!-- --> . </a> </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"HowTo","steps":[{"@type":"HowToStep","text":"Disable the Balancer (Optional)To reduce performance impacts, the balancer may be disabled on the entire\nsharded cluster to ensure no migrations take place while configuring the new zones.Use sh.stopBalancer() to stop the balancer for the cluster.Use sh.isBalancerRunning() to check if the balancer process\nis currently running. Wait until any current balancing rounds have completed\nbefore proceeding."},{"@type":"HowToStep","text":"Add each shard to the appropriate zoneAdd each shard in the North American data center to the NA zone.Add each shard in the European data center to the EU zone.You can review the zones assigned to any given shard by running\nsh.status()."},{"@type":"HowToStep","text":"Define ranges for each zoneFor shard key values where country : US, define a shard key range\nand associate it to the NA zone using the sh.addTagRange()\nmethod. This method requires:The full namespace of the target collection.The inclusive lower bound of the range.The exclusive upper bound of the range.The name of the zone.For shard key values where country : UK, define a shard key range\nand associate it to the EU zone using the sh.addTagRange()\nmethod. This method requires:The full namespace of the target collection.The inclusive lower bound of the range.The exclusive upper bound of the range.The name of the zone.For shard key values where country : DE, define a shard key range\nand associate it to the EU zone using the sh.addTagRange()\nmethod. This method requires:The full namespace of the target collection.The inclusive lower bound of the range.The exclusive upper bound of the range.The name of the zone.The MinKey and MaxKey values are reserved special\nvalue for comparisons. MinKey always compares as lower than every\nother possible value, while MaxKey always compares as higher than\nevery other possible value. The configured ranges captures every user for\neach device.Both country : UK and country : DE are assigned to the EU zone.\nThis associates any document with either UK or DE as the value for\ncountry to the EU data center."},{"@type":"HowToStep","text":"Enable the Balancer (Optional)If the balancer was disabled in previous steps, re-enable the balancer at\nthe completion of this procedure to rebalance the cluster.Use sh.enableBalancing(), specifying the namespace of the\ncollection, to start the balancer.Use sh.isBalancerRunning() to check if the balancer process\nis currently running."},{"@type":"HowToStep","text":"Review the ChangesThe next time the balancer runs, it\nsplits chunks where necessary and migrates chunks across the shards respecting the\nconfigured zones.Once balancing finishes:shards in the NA zone should only contain documents with\ncountry : US, andshards in the EU zone should only contain documents with\ncountry : UK or country : DE.A document with a value for country other than US, UK, or\nDE can reside on any shard in the cluster.To confirm the chunk distribution, run sh.status()."}],"name":"Procedure","image":"https://webimages.mongodb.com/_com_assets/cms/kuyj2focmkbxv7gh3-stacked_default_slate_blue.svg?auto=format%252Ccompress"} </script> <div class="css-4nyere eccljxs0"> <div class="css-1nuklj8 e1ckbxcu1"> <div class="css-18fui5z e1ckbxcu0"> <div class="css-19lsqsq e1ckbxcu2"> 1 </div> </div> <div class="css-1ed38mk"> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Disable the Balancer (Optional) <a class="headerlink leafygreen-ui-1kepx47" href="#disable-the-balancer-optional" 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="disable-the-balancer-optional"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> To reduce performance impacts, the balancer may be disabled on the entire sharded cluster to ensure no migrations take place while configuring the new zones. </p> <p class="leafygreen-ui-1kp3ins"> Use <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/sh.stopBalancer/#mongodb-method-sh.stopBalancer"> <code class="leafygreen-ui-1l06pbn"> sh.stopBalancer() </code> </a> to stop the balancer for the cluster. </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"sh.stopBalancer()\n","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">sh.<span class="lg-highlight-title lg-highlight-function">stopBalancer</span>(<!-- -->)</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"> Use <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/sh.isBalancerRunning/#mongodb-method-sh.isBalancerRunning"> <code class="leafygreen-ui-1l06pbn"> sh.isBalancerRunning() </code> </a> to check if the balancer process is currently running. Wait until any current balancing rounds have completed before proceeding. </p> </section> </div> </div> <div class="css-1nuklj8 e1ckbxcu1"> <div class="css-18fui5z e1ckbxcu0"> <div class="css-19lsqsq e1ckbxcu2"> 2 </div> </div> <div class="css-1ed38mk"> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Add each shard to the appropriate zone <a class="headerlink leafygreen-ui-1kepx47" href="#add-each-shard-to-the-appropriate-zone" 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="add-each-shard-to-the-appropriate-zone"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> Add each shard in the North American data center to the <code class="leafygreen-ui-1l06pbn"> NA </code> zone. </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"sh.addShardTag(&lt;shard&gt;, \"NA\")\n","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">sh.<span class="lg-highlight-title lg-highlight-function">addShardTag</span>(<span class="lg-highlight-tag lg-highlight-xml">&lt;</span><span class="lg-highlight-name lg-highlight-tag lg-highlight-xml">shard</span><span class="lg-highlight-tag lg-highlight-xml"> </span><span class="lg-highlight-attr lg-highlight-tag lg-highlight-xml">name</span><span class="lg-highlight-tag lg-highlight-xml">&gt;</span><span class="lg-highlight-xml">, "NA")</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-xml"></span></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"> Add each shard in the European data center to the <code class="leafygreen-ui-1l06pbn"> EU </code> zone. </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"sh.addShardTag(&lt;shard&gt;, \"EU\")\n","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">sh.<span class="lg-highlight-title lg-highlight-function">addShardTag</span>(<span class="lg-highlight-tag lg-highlight-xml">&lt;</span><span class="lg-highlight-name lg-highlight-tag lg-highlight-xml">shard</span><span class="lg-highlight-tag lg-highlight-xml"> </span><span class="lg-highlight-attr lg-highlight-tag lg-highlight-xml">name</span><span class="lg-highlight-tag lg-highlight-xml">&gt;</span><span class="lg-highlight-xml">, "EU")</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-xml"></span></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"> You can review the zones assigned to any given shard by running <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/sh.status/#mongodb-method-sh.status"> <code class="leafygreen-ui-1l06pbn"> sh.status() </code> . </a> </p> </section> </div> </div> <div class="css-1nuklj8 e1ckbxcu1"> <div class="css-18fui5z e1ckbxcu0"> <div class="css-19lsqsq e1ckbxcu2"> 3 </div> </div> <div class="css-1ed38mk"> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Define ranges for each zone <a class="headerlink leafygreen-ui-1kepx47" href="#define-ranges-for-each-zone" 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="define-ranges-for-each-zone"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> For shard key values where <code class="leafygreen-ui-1l06pbn"> country : US </code> , define a shard key range and associate it to the <code class="leafygreen-ui-1l06pbn"> NA </code> zone using the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/sh.addTagRange/#mongodb-method-sh.addTagRange"> <code class="leafygreen-ui-1l06pbn"> sh.addTagRange() </code> </a> method. This method requires: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> The full namespace of the target collection. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> The inclusive lower bound of the range. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> The exclusive upper bound of the range. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> The name of the zone. </p> </li> </ul> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"sh.addTagRange( \n \"chat.messages\",\n { \"country\" : \"US\", \"userid\" : MinKey },\n { \"country\" : \"US\", \"userid\" : MaxKey }, \n \"NA\"\n)\n","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">sh.<span class="lg-highlight-title lg-highlight-function">addTagRange</span>( </td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"chat.messages"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"country"</span> <!-- -->: <span class="lg-highlight-string">"US"</span>, <span class="lg-highlight-string">"userid"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">MinKey</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"country"</span> <!-- -->: <span class="lg-highlight-string">"US"</span>, <span class="lg-highlight-string">"userid"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">MaxKey</span> }<!-- -->, </td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"NA"</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx">)</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"> For shard key values where <code class="leafygreen-ui-1l06pbn"> country : UK </code> , define a shard key range and associate it to the <code class="leafygreen-ui-1l06pbn"> EU </code> zone using the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/sh.addTagRange/#mongodb-method-sh.addTagRange"> <code class="leafygreen-ui-1l06pbn"> sh.addTagRange() </code> </a> method. This method requires: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> The full namespace of the target collection. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> The inclusive lower bound of the range. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> The exclusive upper bound of the range. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> The name of the zone. </p> </li> </ul> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"sh.addTagRange( \n \"chat.messages\",\n { \"country\" : \"UK\", \"userid\" : MinKey },\n { \"country\" : \"UK\", \"userid\" : MaxKey }, \n \"EU\"\n)\n","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">sh.<span class="lg-highlight-title lg-highlight-function">addTagRange</span>( </td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"chat.messages"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"country"</span> <!-- -->: <span class="lg-highlight-string">"UK"</span>, <span class="lg-highlight-string">"userid"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">MinKey</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"country"</span> <!-- -->: <span class="lg-highlight-string">"UK"</span>, <span class="lg-highlight-string">"userid"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">MaxKey</span> }<!-- -->, </td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"EU"</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx">)</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"> For shard key values where <code class="leafygreen-ui-1l06pbn"> country : DE </code> , define a shard key range and associate it to the <code class="leafygreen-ui-1l06pbn"> EU </code> zone using the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/sh.addTagRange/#mongodb-method-sh.addTagRange"> <code class="leafygreen-ui-1l06pbn"> sh.addTagRange() </code> </a> method. This method requires: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> The full namespace of the target collection. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> The inclusive lower bound of the range. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> The exclusive upper bound of the range. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> The name of the zone. </p> </li> </ul> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"sh.addTagRange( \n \"chat.messages\",\n { \"country\" : \"DE\", \"userid\" : MinKey },\n { \"country\" : \"DE\", \"userid\" : MaxKey }, \n \"EU\"\n)\n","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">sh.<span class="lg-highlight-title lg-highlight-function">addTagRange</span>( </td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"chat.messages"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"country"</span> <!-- -->: <span class="lg-highlight-string">"DE"</span>, <span class="lg-highlight-string">"userid"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">MinKey</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"country"</span> <!-- -->: <span class="lg-highlight-string">"DE"</span>, <span class="lg-highlight-string">"userid"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">MaxKey</span> }<!-- -->, </td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"EU"</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx">)</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 <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/mongodb-extended-json/#mongodb-bsontype-MinKey"> <code class="leafygreen-ui-1l06pbn"> MinKey </code> </a> and <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/mongodb-extended-json/#mongodb-bsontype-MaxKey"> <code class="leafygreen-ui-1l06pbn"> MaxKey </code> </a> values are reserved special value for comparisons. <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/mongodb-extended-json/#mongodb-bsontype-MinKey"> <code class="leafygreen-ui-1l06pbn"> MinKey </code> </a> always compares as lower than every other possible value, while <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/mongodb-extended-json/#mongodb-bsontype-MaxKey"> <code class="leafygreen-ui-1l06pbn"> MaxKey </code> </a> always compares as higher than every other possible value. The configured ranges captures every user for each <code class="leafygreen-ui-1l06pbn"> device </code> . </p> <p class="leafygreen-ui-1kp3ins"> Both <code class="leafygreen-ui-1l06pbn"> country : UK </code> and <code class="leafygreen-ui-1l06pbn"> country : DE </code> are assigned to the <code class="leafygreen-ui-1l06pbn"> EU </code> zone. This associates any document with either <code class="leafygreen-ui-1l06pbn"> UK </code> or <code class="leafygreen-ui-1l06pbn"> DE </code> as the value for <code class="leafygreen-ui-1l06pbn"> country </code> to the EU data center. </p> </section> </div> </div> <div class="css-1nuklj8 e1ckbxcu1"> <div class="css-18fui5z e1ckbxcu0"> <div class="css-19lsqsq e1ckbxcu2"> 4 </div> </div> <div class="css-1ed38mk"> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Enable the Balancer (Optional) <a class="headerlink leafygreen-ui-1kepx47" href="#enable-the-balancer-optional" 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="enable-the-balancer-optional"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> If the balancer was disabled in previous steps, re-enable the balancer at the completion of this procedure to rebalance the cluster. </p> <p class="leafygreen-ui-1kp3ins"> Use <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/sh.enableBalancing/#mongodb-method-sh.enableBalancing"> <code class="leafygreen-ui-1l06pbn"> sh.enableBalancing() </code> </a> , specifying the namespace of the collection, to start the balancer. </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"sh.enableBalancing(\"chat.message\")\n","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">sh.<span class="lg-highlight-title lg-highlight-function">enableBalancing</span>(<span class="lg-highlight-string">"chat.message"</span>)</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"> Use <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/sh.isBalancerRunning/#mongodb-method-sh.isBalancerRunning"> <code class="leafygreen-ui-1l06pbn"> sh.isBalancerRunning() </code> </a> to check if the balancer process is currently running. </p> </section> </div> </div> <div class="css-1nuklj8 e1ckbxcu1"> <div class="css-18fui5z e1ckbxcu0"> <div class="css-19lsqsq e1ckbxcu2"> 5 </div> </div> <div class="css-1ed38mk"> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Review the Changes <a class="headerlink leafygreen-ui-1kepx47" href="#review-the-changes" 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="review-the-changes"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> The next time the <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/sharding-balancer-administration/#std-label-sharding-balancing"> balancer </a> runs, it splits chunks where necessary and <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/sharding-data-partitioning/#std-label-sharding-chunk-migration"> migrates </a> chunks across the shards respecting the configured zones. </p> <p class="leafygreen-ui-1kp3ins"> Once balancing finishes: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> shards in the <code class="leafygreen-ui-1l06pbn"> NA </code> zone should only contain documents with <code class="leafygreen-ui-1l06pbn"> country : US </code> , and </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> shards in the <code class="leafygreen-ui-1l06pbn"> EU </code> zone should only contain documents with <code class="leafygreen-ui-1l06pbn"> country : UK </code> or <code class="leafygreen-ui-1l06pbn"> country : DE </code> . </p> </li> </ul> <p class="leafygreen-ui-1kp3ins"> A document with a value for <code class="leafygreen-ui-1l06pbn"> country </code> other than <code class="leafygreen-ui-1l06pbn"> US </code> , <code class="leafygreen-ui-1l06pbn"> UK </code> , or <code class="leafygreen-ui-1l06pbn"> DE </code> can reside on any shard in the cluster. </p> <p class="leafygreen-ui-1kp3ins"> To confirm the chunk distribution, run <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/sh.status/#mongodb-method-sh.status"> <code class="leafygreen-ui-1l06pbn"> sh.status() </code> . </a> </p> </section> </div> </div> </div> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Updating Zones <a class="headerlink leafygreen-ui-1kepx47" href="#updating-zones" 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="updating-zones"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> The application requires the following updates: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Documents with <code class="leafygreen-ui-1l06pbn"> country : UK </code> must now be associated to the new <code class="leafygreen-ui-1l06pbn"> UK </code> data center. Any data in the <code class="leafygreen-ui-1l06pbn"> EU </code> data center must be migrated </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> The chat application now supports users in Mexico. Documents with <code class="leafygreen-ui-1l06pbn"> country : MX </code> must be routed to the <code class="leafygreen-ui-1l06pbn"> NA </code> data center. </p> </li> </ul> <p class="leafygreen-ui-1kp3ins"> Perform the following procedures to update the zone ranges. </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"HowTo","steps":[{"@type":"HowToStep","text":"Disable the Balancer (Optional)To reduce performance impacts, the balancer may be disabled on the entire\nsharded cluster to ensure no migrations take place while configuring the\nnew zones or removing the old ones.Use sh.stopBalancer() to stop the balancer for the cluster.Use sh.isBalancerRunning() to check if the balancer process\nis currently running. Wait until any current balancing rounds have completed\nbefore proceeding."},{"@type":"HowToStep","text":"Add the new UK zoneAdd each shard in the UK data center to the UK zone.You can review the zones assigned to any given shard by running\nsh.status()."},{"@type":"HowToStep","text":"Remove the old zone rangeRemove the old zone range associated to the UK country using the\nsh.removeTagRange() method. This method requires:The full namespace of the target collection.The inclusive lower bound of the range.The exclusive upper bound of the range."},{"@type":"HowToStep","text":"Add new zone rangesFor shard key values where country : UK, define a shard key range\nand associate it to the UK zone using the sh.addTagRange()\nmethod. This method requires:The full namespace of the target collection.The inclusive lower bound of the range.The exclusive upper bound of the range.The name of the zone.For shard key values where country : MX, define a shard key range\nand associate it to the NA zone using the sh.addTagRange()\nmethod. This method requires:The full namespace of the target collection.The inclusive lower bound of the range.The exclusive upper bound of the range.The name of the zone.The MinKey and MaxKey values are reserved special values\nfor comparisons. MinKey always compares as lower than every other\npossible value, while MaxKey always compares as higher than\nevery other possible value. This ensures the two ranges captures the\nentire possible value space of userid."},{"@type":"HowToStep","text":"Enable the Balancer (Optional)If the balancer was disabled in previous steps, re-enable the balancer at\nthe completion of this procedure to rebalance the cluster.Use sh.enableBalancing(), specifying the namespace of the\ncollection, to start the balancerUse sh.isBalancerRunning() to check if the balancer process\nis currently running."},{"@type":"HowToStep","text":"Review the changesThe next time the balancer runs, it\nsplits chunks where necessary and migrates chunks across the shards respecting the\nconfigured zones.Before balancing:shards in the EU zone only contain documents where\ncountry : DE or country : UK, anddocuments where country : MX could be stored on any shard in\nthe sharded cluster.After balancing:shards in the EU zone only contain documents where\ncountry : DE,shards in the UK zone only contain documents where\ncountry : UK, andshards in the NA zone only contain documents where\ncountry : US or country : MX.A document with a value for country other than US, MX,\nUK, or DE can reside on any shard in the cluster.To confirm the chunk distribution, run sh.status()."}],"name":"Updating Zones","image":"https://webimages.mongodb.com/_com_assets/cms/kuyj2focmkbxv7gh3-stacked_default_slate_blue.svg?auto=format%252Ccompress"} </script> <div class="css-4nyere eccljxs0"> <div class="css-1nuklj8 e1ckbxcu1"> <div class="css-18fui5z e1ckbxcu0"> <div class="css-19lsqsq e1ckbxcu2"> 1 </div> </div> <div class="css-1ed38mk"> <section> <h4 class="contains-headerlink leafygreen-ui-1vzlt5f"> Disable the Balancer (Optional) <a class="headerlink leafygreen-ui-1kepx47" href="#disable-the-balancer-optional-1" 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="disable-the-balancer-optional-1"> </div> </a> </h4> <p class="leafygreen-ui-1kp3ins"> To reduce performance impacts, the balancer may be disabled on the entire sharded cluster to ensure no migrations take place while configuring the new zones or removing the old ones. </p> <p class="leafygreen-ui-1kp3ins"> Use <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/sh.stopBalancer/#mongodb-method-sh.stopBalancer"> <code class="leafygreen-ui-1l06pbn"> sh.stopBalancer() </code> </a> to stop the balancer for the cluster. </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"sh.stopBalancer()\n","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">sh.<span class="lg-highlight-title lg-highlight-function">stopBalancer</span>(<!-- -->)</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"> Use <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/sh.isBalancerRunning/#mongodb-method-sh.isBalancerRunning"> <code class="leafygreen-ui-1l06pbn"> sh.isBalancerRunning() </code> </a> to check if the balancer process is currently running. Wait until any current balancing rounds have completed before proceeding. </p> </section> </div> </div> <div class="css-1nuklj8 e1ckbxcu1"> <div class="css-18fui5z e1ckbxcu0"> <div class="css-19lsqsq e1ckbxcu2"> 2 </div> </div> <div class="css-1ed38mk"> <section> <h4 class="contains-headerlink leafygreen-ui-1vzlt5f"> Add the new <code class="leafygreen-ui-1l06pbn"> UK </code> zone <a class="headerlink leafygreen-ui-1kepx47" href="#add-the-new-uk-zone" 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="add-the-new-uk-zone"> </div> </a> </h4> <p class="leafygreen-ui-1kp3ins"> Add each shard in the <code class="leafygreen-ui-1l06pbn"> UK </code> data center to the <code class="leafygreen-ui-1l06pbn"> UK </code> zone. </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"sh.addShardTag(\"&lt;shard&gt;\", \"UK\")\n","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">sh.<span class="lg-highlight-title lg-highlight-function">addShardTag</span>(<span class="lg-highlight-string">"&lt;shard name&gt;"</span>, <span class="lg-highlight-string">"UK"</span>)</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"> You can review the zones assigned to any given shard by running <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/sh.status/#mongodb-method-sh.status"> <code class="leafygreen-ui-1l06pbn"> sh.status() </code> . </a> </p> </section> </div> </div> <div class="css-1nuklj8 e1ckbxcu1"> <div class="css-18fui5z e1ckbxcu0"> <div class="css-19lsqsq e1ckbxcu2"> 3 </div> </div> <div class="css-1ed38mk"> <section> <h4 class="contains-headerlink leafygreen-ui-1vzlt5f"> Remove the old zone range <a class="headerlink leafygreen-ui-1kepx47" href="#remove-the-old-zone-range" 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="remove-the-old-zone-range"> </div> </a> </h4> <p class="leafygreen-ui-1kp3ins"> Remove the old zone range associated to the <code class="leafygreen-ui-1l06pbn"> UK </code> country using the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/sh.removeTagRange/#mongodb-method-sh.removeTagRange"> <code class="leafygreen-ui-1l06pbn"> sh.removeTagRange() </code> </a> method. This method requires: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> The full namespace of the target collection. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> The inclusive lower bound of the range. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> The exclusive upper bound of the range. </p> </li> </ul> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"sh.removeTagRange(\n \"chat.messages\",\n { \"country\" : \"UK\", \"userid\" : MinKey },\n { \"country\" : \"UK\", \"userid\" : MaxKey }\n)\n","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">sh.<span class="lg-highlight-title lg-highlight-function">removeTagRange</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"chat.messages"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"country"</span> <!-- -->: <span class="lg-highlight-string">"UK"</span>, <span class="lg-highlight-string">"userid"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">MinKey</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"country"</span> <!-- -->: <span class="lg-highlight-string">"UK"</span>, <span class="lg-highlight-string">"userid"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">MaxKey</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">)</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> </section> </div> </div> <div class="css-1nuklj8 e1ckbxcu1"> <div class="css-18fui5z e1ckbxcu0"> <div class="css-19lsqsq e1ckbxcu2"> 4 </div> </div> <div class="css-1ed38mk"> <section> <h4 class="contains-headerlink leafygreen-ui-1vzlt5f"> Add new zone ranges <a class="headerlink leafygreen-ui-1kepx47" href="#add-new-zone-ranges" 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="add-new-zone-ranges"> </div> </a> </h4> <p class="leafygreen-ui-1kp3ins"> For shard key values where <code class="leafygreen-ui-1l06pbn"> country : UK </code> , define a shard key range and associate it to the <code class="leafygreen-ui-1l06pbn"> UK </code> zone using the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/sh.addTagRange/#mongodb-method-sh.addTagRange"> <code class="leafygreen-ui-1l06pbn"> sh.addTagRange() </code> </a> method. This method requires: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> The full namespace of the target collection. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> The inclusive lower bound of the range. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> The exclusive upper bound of the range. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> The name of the zone. </p> </li> </ul> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"sh.addTagRange( \n \"chat.message\",\n { \"country\" : \"UK\", \"userid\" : MinKey },\n { \"country\" : \"UK\", \"userid\" : MaxKey }, \n \"UK\"\n)\n","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">sh.<span class="lg-highlight-title lg-highlight-function">addTagRange</span>( </td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"chat.message"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"country"</span> <!-- -->: <span class="lg-highlight-string">"UK"</span>, <span class="lg-highlight-string">"userid"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">MinKey</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"country"</span> <!-- -->: <span class="lg-highlight-string">"UK"</span>, <span class="lg-highlight-string">"userid"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">MaxKey</span> }<!-- -->, </td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"UK"</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx">)</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"> For shard key values where <code class="leafygreen-ui-1l06pbn"> country : MX </code> , define a shard key range and associate it to the <code class="leafygreen-ui-1l06pbn"> NA </code> zone using the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/sh.addTagRange/#mongodb-method-sh.addTagRange"> <code class="leafygreen-ui-1l06pbn"> sh.addTagRange() </code> </a> method. This method requires: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> The full namespace of the target collection. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> The inclusive lower bound of the range. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> The exclusive upper bound of the range. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> The name of the zone. </p> </li> </ul> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"sh.addTagRange( \n \"chat.messages\",\n { \"country\" : \"MX\", \"userid\" : MinKey },\n { \"country\" : \"MX\", \"userid\" : MaxKey }, \n \"NA\"\n)\n","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">sh.<span class="lg-highlight-title lg-highlight-function">addTagRange</span>( </td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"chat.messages"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"country"</span> <!-- -->: <span class="lg-highlight-string">"MX"</span>, <span class="lg-highlight-string">"userid"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">MinKey</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"country"</span> <!-- -->: <span class="lg-highlight-string">"MX"</span>, <span class="lg-highlight-string">"userid"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">MaxKey</span> }<!-- -->, </td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"NA"</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx">)</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 <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/mongodb-extended-json/#mongodb-bsontype-MinKey"> <code class="leafygreen-ui-1l06pbn"> MinKey </code> </a> and <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/mongodb-extended-json/#mongodb-bsontype-MaxKey"> <code class="leafygreen-ui-1l06pbn"> MaxKey </code> </a> values are reserved special values for comparisons. <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/mongodb-extended-json/#mongodb-bsontype-MinKey"> <code class="leafygreen-ui-1l06pbn"> MinKey </code> </a> always compares as lower than every other possible value, while <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/mongodb-extended-json/#mongodb-bsontype-MaxKey"> <code class="leafygreen-ui-1l06pbn"> MaxKey </code> </a> always compares as higher than every other possible value. This ensures the two ranges captures the entire possible value space of <code class="leafygreen-ui-1l06pbn"> userid </code> . </p> </section> </div> </div> <div class="css-1nuklj8 e1ckbxcu1"> <div class="css-18fui5z e1ckbxcu0"> <div class="css-19lsqsq e1ckbxcu2"> 5 </div> </div> <div class="css-1ed38mk"> <section> <h4 class="contains-headerlink leafygreen-ui-1vzlt5f"> Enable the Balancer (Optional) <a class="headerlink leafygreen-ui-1kepx47" href="#enable-the-balancer-optional-1" 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="enable-the-balancer-optional-1"> </div> </a> </h4> <p class="leafygreen-ui-1kp3ins"> If the balancer was disabled in previous steps, re-enable the balancer at the completion of this procedure to rebalance the cluster. </p> <p class="leafygreen-ui-1kp3ins"> Use <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/sh.enableBalancing/#mongodb-method-sh.enableBalancing"> <code class="leafygreen-ui-1l06pbn"> sh.enableBalancing() </code> </a> , specifying the namespace of the collection, to start the balancer </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"sh.enableBalancing(\"chat.messages\")\n","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">sh.<span class="lg-highlight-title lg-highlight-function">enableBalancing</span>(<span class="lg-highlight-string">"chat.messages"</span>)</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"> Use <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/sh.isBalancerRunning/#mongodb-method-sh.isBalancerRunning"> <code class="leafygreen-ui-1l06pbn"> sh.isBalancerRunning() </code> </a> to check if the balancer process is currently running. </p> </section> </div> </div> <div class="css-1nuklj8 e1ckbxcu1"> <div class="css-18fui5z e1ckbxcu0"> <div class="css-19lsqsq e1ckbxcu2"> 6 </div> </div> <div class="css-1ed38mk"> <section> <h4 class="contains-headerlink leafygreen-ui-1vzlt5f"> Review the changes <a class="headerlink leafygreen-ui-1kepx47" href="#review-the-changes-1" 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="review-the-changes-1"> </div> </a> </h4> <p class="leafygreen-ui-1kp3ins"> The next time the <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/sharding-balancer-administration/#std-label-sharding-balancing"> balancer </a> runs, it splits chunks where necessary and <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/sharding-data-partitioning/#std-label-sharding-chunk-migration"> migrates </a> chunks across the shards respecting the configured zones. </p> <p class="leafygreen-ui-1kp3ins"> Before balancing: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> shards in the <code class="leafygreen-ui-1l06pbn"> EU </code> zone only contain documents where <code class="leafygreen-ui-1l06pbn"> country : DE </code> or <code class="leafygreen-ui-1l06pbn"> country : UK </code> , and </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> documents where <code class="leafygreen-ui-1l06pbn"> country : MX </code> could be stored on any shard in the sharded cluster. </p> </li> </ul> <p class="leafygreen-ui-1kp3ins"> After balancing: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> shards in the <code class="leafygreen-ui-1l06pbn"> EU </code> zone only contain documents where <code class="leafygreen-ui-1l06pbn"> country : DE </code> , </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> shards in the <code class="leafygreen-ui-1l06pbn"> UK </code> zone only contain documents where <code class="leafygreen-ui-1l06pbn"> country : UK </code> , and </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> shards in the <code class="leafygreen-ui-1l06pbn"> NA </code> zone only contain documents where <code class="leafygreen-ui-1l06pbn"> country : US </code> or <code class="leafygreen-ui-1l06pbn"> country : MX </code> . </p> </li> </ul> <p class="leafygreen-ui-1kp3ins"> A document with a value for <code class="leafygreen-ui-1l06pbn"> country </code> other than <code class="leafygreen-ui-1l06pbn"> US </code> , <code class="leafygreen-ui-1l06pbn"> MX </code> , <code class="leafygreen-ui-1l06pbn"> UK </code> , or <code class="leafygreen-ui-1l06pbn"> DE </code> can reside on any shard in the cluster. </p> <p class="leafygreen-ui-1kp3ins"> To confirm the chunk distribution, run <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/sh.status/#mongodb-method-sh.status"> <code class="leafygreen-ui-1l06pbn"> sh.status() </code> . </a> </p> </section> </div> </div> </div> <div class="leafygreen-ui-13vw3ie" role="note"> <h2 class="leafygreen-ui-1fn4p2b"> Tip </h2> <h3 class="leafygreen-ui-144d5kf"> <strong> See also: </strong> </h3> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/zone-sharding/#std-label-zone-sharding"> Zones </a> </p> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/sharding-balancer-administration/#std-label-sharding-balancing"> Sharded Cluster Balancer </a> </p> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/tutorial/deploy-shard-cluster/"> Deploy a Self-Managed Sharded Cluster </a> </p> </div> </div> </section> </section> </section>
https://www.mongodb.com/docs/manual/core/localhost-exception/
<section> <h1 class="contains-headerlink leafygreen-ui-41fr9s" weight="medium"> Localhost Exception in Self-Managed Deployments <a class="headerlink leafygreen-ui-1kepx47" href="#localhost-exception-in-self-managed-deployments" 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="localhost-exception-in-self-managed-deployments"> </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="#localhost-exception-for-sharded-clusters" target="_self"> <span> Localhost Exception for Sharded Clusters </span> </a> </li> </ul> </div> <div class="leafygreen-ui-85da11" role="note"> <h2 class="leafygreen-ui-1ac4g5h"> Important </h2> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> On a <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> instance, the localhost exception only applies when there are <strong> no users or roles </strong> created in the MongoDB instance. </p> </div> </div> <p class="leafygreen-ui-1kp3ins"> The localhost exception allows you to enable access control and then create the first user or role in the system. After you enable access control, connect to the localhost interface and create the first user in the <code class="leafygreen-ui-1l06pbn"> admin </code> database. </p> <p class="leafygreen-ui-1kp3ins"> If you create a user first, the user must have privileges to create other users. The <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/built-in-roles/#mongodb-authrole-userAdmin"> <code class="leafygreen-ui-1l06pbn"> userAdmin </code> </a> or <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/built-in-roles/#mongodb-authrole-userAdminAnyDatabase"> <code class="leafygreen-ui-1l06pbn"> userAdminAnyDatabase </code> </a> role both confer the privilege to create other users. </p> <div class="leafygreen-ui-1sjx7ru" role="note"> <h2 class="leafygreen-ui-29m78u"> Warning </h2> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> Connections using the localhost exception have access to create <em> only </em> the <strong> first user or role </strong> . </p> <p class="leafygreen-ui-1kp3ins"> Once you create any user or role, the localhost exception is disabled. If you need to create a user and a role, you must create the user first using one of the builtin <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/built-in-roles/#mongodb-authrole-userAdmin"> <code class="leafygreen-ui-1l06pbn"> userAdmin </code> </a> or <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/built-in-roles/#mongodb-authrole-userAdminAnyDatabase"> <code class="leafygreen-ui-1l06pbn"> userAdminAnyDatabase </code> </a> roles. If you create a role first, you won't be able to create a user. </p> </div> </div> <p class="leafygreen-ui-1kp3ins"> The ability to create a role first with the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/db.createRole/#mongodb-method-db.createRole"> <code class="leafygreen-ui-1l06pbn"> db.createRole() </code> </a> method is specifically for users authorizing with LDAP. See <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/security-ldap-external/#std-label-security-ldap-external"> LDAP Authorization </a> for more information. </p> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Localhost Exception for Sharded Clusters <a class="headerlink leafygreen-ui-1kepx47" href="#localhost-exception-for-sharded-clusters" 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="localhost-exception-for-sharded-clusters"> </div> </a> </h2> <div class="leafygreen-ui-85da11" role="note"> <h2 class="leafygreen-ui-1ac4g5h"> Important </h2> <div class="leafygreen-ui-9mycqc"> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> On a <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongos/#mongodb-binary-bin.mongos"> <code class="leafygreen-ui-1l06pbn"> mongos </code> </a> , the localhost exception only applies when there are no <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/security-users/#std-label-sharding-localhost"> sharded cluster users </a> or roles created. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> In a sharded cluster, the localhost exception applies to each shard individually as well as to the cluster as a whole. </p> </li> </ul> </div> </div> <p class="leafygreen-ui-1kp3ins"> Once you create a sharded cluster and add a <a class="leafygreen-ui-tqgtui" href="/docs/manual/tutorial/configure-scram-client-authentication/#std-label-create-user-admin"> user administrator </a> through the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongos/#mongodb-binary-bin.mongos"> <code class="leafygreen-ui-1l06pbn"> mongos </code> </a> instance, you <strong> must </strong> still prevent unauthorized access to the individual shards. To prevent unauthorized access to individual shards, follow one of the following steps for each shard in your cluster: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/tutorial/configure-scram-client-authentication/#std-label-create-user-admin"> Create a user administrator </a> on the shard's primary. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Disable the localhost exception at startup. To disable the localhost exception, set the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/parameters/#mongodb-parameter-param.enableLocalhostAuthBypass"> <code class="leafygreen-ui-1l06pbn"> enableLocalhostAuthBypass </code> </a> parameter to <code class="leafygreen-ui-1l06pbn"> 0 </code> . </p> </li> </ul> </section> </section>
https://www.mongodb.com/docs/manual/reference/command/validateDBMetadata/
<section> <h1 class="contains-headerlink leafygreen-ui-41fr9s" weight="medium"> validateDBMetadata <a class="headerlink leafygreen-ui-1kepx47" href="#validatedbmetadata" 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="validatedbmetadata"> </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="#definition" target="_self"> <span> Definition </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#compatibility" target="_self"> <span> Compatibility </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#syntax" target="_self"> <span> Syntax </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#command-fields" target="_self"> <span> Command Fields </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#behavior" target="_self"> <span> Behavior </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#output" target="_self"> <span> Output </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#example" target="_self"> <span> Example </span> </a> </li> </ul> </div> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Definition <a class="headerlink leafygreen-ui-1kepx47" href="#definition" 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="definition"> </div> </a> </h2> <div> <p> <em> New <!-- --> in version <!-- --> 5.0 </em> . </p> </div> <dl class="dbcommand"> <dt> <code class="leafygreen-ui-1l06pbn"> validateDBMetadata </code> <a class="headerlink leafygreen-ui-1kepx47" href="#mongodb-dbcommand-dbcmd.validateDBMetadata" title="Permalink to this definition"> <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="mongodb-dbcommand-dbcmd.validateDBMetadata"> </div> </a> </dt> <dd> <p class="leafygreen-ui-1kp3ins"> The <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-dbcommand-dbcmd.validateDBMetadata" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> validateDBMetadata </code> </span> </a> command checks that the stored metadata of a database or a collection is valid within a particular API version. </p> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-dbcommand-dbcmd.validateDBMetadata" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> validateDBMetadata </code> </span> </a> reports errors, but does not have the capability to fix errors. </p> </dd> </dl> </section> <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"> This command is available in 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> <div class="leafygreen-ui-15mdk4" role="note"> <h2 class="leafygreen-ui-6n7b7d"> Note </h2> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> This command is supported in all MongoDB Atlas clusters. For information on Atlas support for all commands, see <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/atlas/unsupported-commands/" target="_self"> <span> Unsupported Commands <!-- --> . </span> </a> </p> </div> </div> <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"> Syntax <a class="headerlink leafygreen-ui-1kepx47" href="#syntax" 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="syntax"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> The command has the following syntax: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.runCommand(\n {\n validateDBMetadata: 1,\n apiParameters: {\n version: &lt;string&gt;,\n strict: &lt;boolean&gt;,\n deprecationErrors: &lt;boolean&gt;\n },\n db: &lt;string&gt;,\n collection: &lt;string&gt;,\n }\n)","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">runCommand</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">validateDBMetadata</span>: <span class="lg-highlight-number">1</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">apiParameters</span>: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">version</span>: &lt;<!-- -->string<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">strict</span>: &lt;<!-- -->boolean<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">deprecationErrors</span>: &lt;<!-- -->boolean<!-- -->&gt;</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->}<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">db</span>: &lt;<!-- -->string<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">collection</span>: &lt;<!-- -->string<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->}</td></tr><tr class=""><td class="leafygreen-ui-7razhx">)</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> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Command Fields <a class="headerlink leafygreen-ui-1kepx47" href="#command-fields" 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="command-fields"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> The command takes the following fields: </p> <div class="leafygreen-ui-skkc39" tabindex="0"> <table class="leafygreen-ui-hr8lsv"> <colgroup> <col style="width:10%"/> <col style="width:10%"/> <col style="width:50%"/> </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> Field </div> </div> </th> <th class="leafygreen-ui-13uteka" role="columnheader" scope="col"> <div class="leafygreen-ui-ui0te9"> <div> Type </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="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-api-params-document" target="_self"> <span> apiParameters </span> </a> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> document </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <span class="leafygreen-ui-1qnjd6d" id="std-label-api-params-document"> </span> <p class="leafygreen-ui-1kp3ins"> <em> All Fields are Required </em> . </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <code class="leafygreen-ui-1l06pbn"> version </code> ( <em> string </em> ) </p> <p class="leafygreen-ui-1kp3ins"> The API Version to validate against. For now, <code class="leafygreen-ui-1l06pbn"> "1" </code> is the only version. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <code class="leafygreen-ui-1l06pbn"> strict </code> ( <em> boolean </em> ) </p> <p class="leafygreen-ui-1kp3ins"> If <code class="leafygreen-ui-1l06pbn"> true </code> , <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/stable-api/#std-label-api-strict-resp"> APIStrictError </a> responses will be included in the output. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <code class="leafygreen-ui-1l06pbn"> deprecationErrors </code> ( <em> boolean </em> ) </p> <p class="leafygreen-ui-1kp3ins"> If <code class="leafygreen-ui-1l06pbn"> true </code> , <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/stable-api/#std-label-api-deprecation-resp"> APIDeprecationError </a> responses will be included in the output. </p> </li> </ul> </div> </div> </td> </tr> <tr class=""> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> db </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> string </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <em> Optional </em> . The name of the database to validate. If no database is specified, all databases will be validated. </div> </div> </td> </tr> <tr class=""> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> collection </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> string </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <em> Optional </em> . The name of the collection or view to validate. If no collection or view is specified, all collections in the database specified by <code class="leafygreen-ui-1l06pbn"> db </code> will be validated. If no database is specified, all collections in all databases will be validated. </div> </div> </td> </tr> </tbody> </table> </div> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Behavior <a class="headerlink leafygreen-ui-1kepx47" href="#behavior" 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="behavior"> </div> </a> </h2> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Validate all collections in all databases, reporting <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/stable-api/#std-label-api-strict-resp"> APIStrictError </a> and <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/stable-api/#std-label-api-vers-resp"> APIVersionError </a> error responses. </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.runCommand( {\n validateDBMetadata: 1,\n apiParameters: {\n version: \"1\",\n strict: true,\n deprecationErrors: true\n },\n})","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">runCommand</span>( <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">validateDBMetadata</span>: <span class="lg-highlight-number">1</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">apiParameters</span>: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">version</span>: <span class="lg-highlight-string">"1"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">strict</span>: <span class="lg-highlight-literal">true</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">deprecationErrors</span>: <span class="lg-highlight-literal">true</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">})</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> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Validate all collections in <code class="leafygreen-ui-1l06pbn"> inventory </code> : </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.runCommand( {\n validateDBMetadata: 1,\n apiParameters: {\n version: \"1\",\n strict: true,\n deprecationErrors: true\n },\n db: \"inventory\",\n})","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">runCommand</span>( <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">validateDBMetadata</span>: <span class="lg-highlight-number">1</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">apiParameters</span>: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">version</span>: <span class="lg-highlight-string">"1"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">strict</span>: <span class="lg-highlight-literal">true</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">deprecationErrors</span>: <span class="lg-highlight-literal">true</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">db</span>: <span class="lg-highlight-string">"inventory"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">})</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> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Validate the <code class="leafygreen-ui-1l06pbn"> sales </code> collection in the <code class="leafygreen-ui-1l06pbn"> inventory </code> database: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.runCommand( {\n validateDBMetadata: 1,\n apiParameters: {\n version: \"1\",\n strict: true,\n deprecationErrors: true\n },\n db: \"inventory\",\n collection: \"sales\",\n})","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">runCommand</span>( <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">validateDBMetadata</span>: <span class="lg-highlight-number">1</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">apiParameters</span>: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">version</span>: <span class="lg-highlight-string">"1"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">strict</span>: <span class="lg-highlight-literal">true</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">deprecationErrors</span>: <span class="lg-highlight-literal">true</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">db</span>: <span class="lg-highlight-string">"inventory"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">collection</span>: <span class="lg-highlight-string">"sales"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">})</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> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Validate any and all <code class="leafygreen-ui-1l06pbn"> sales </code> collections across all databases: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.runCommand( {\n validateDBMetadata: 1,\n apiParameters: {\n version: \"1\",\n strict: true,\n deprecationErrors: true\n },\n collection: \"sales\",\n})","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">runCommand</span>( <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">validateDBMetadata</span>: <span class="lg-highlight-number">1</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">apiParameters</span>: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">version</span>: <span class="lg-highlight-string">"1"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">strict</span>: <span class="lg-highlight-literal">true</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">deprecationErrors</span>: <span class="lg-highlight-literal">true</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">collection</span>: <span class="lg-highlight-string">"sales"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">})</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> </li> </ul> <div class="leafygreen-ui-15mdk4" role="note"> <h2 class="leafygreen-ui-6n7b7d"> Note </h2> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> Your user must have the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/privilege-actions/#mongodb-authaction-validate"> <code class="leafygreen-ui-1l06pbn"> validate </code> </a> privilege action on all collections you want to validate. </p> </div> </div> <span class="leafygreen-ui-1qnjd6d" id="std-label-validateDBMetadata-output"> </span> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Output <a class="headerlink leafygreen-ui-1kepx47" href="#output" 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="output"> </div> </a> </h2> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{\n apiVersionErrors: [\n {\n ns: &lt;string&gt;,\n code: &lt;int&gt;,\n codeName: &lt;string&gt;,\n errmsg: &lt;string&gt;\n }\n ],\n ok: &lt;int&gt;,\n hasMoreErrors: &lt;boolean&gt;,\n}","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">apiVersionErrors</span>: <!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">ns</span>: &lt;<!-- -->string<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">code</span>: &lt;<!-- -->int<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">codeName</span>: &lt;<!-- -->string<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">errmsg</span>: &lt;<!-- -->string<!-- -->&gt;</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->}</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> ]<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">ok</span>: &lt;<!-- -->int<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">hasMoreErrors</span>: &lt;<!-- -->boolean<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">}</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> <dl class="data"> <dt> <code class="leafygreen-ui-1l06pbn"> validateDBMetadata.apiVersionErrors </code> <a class="headerlink leafygreen-ui-1kepx47" href="#mongodb-data-validateDBMetadata.apiVersionErrors" title="Permalink to this definition"> <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="mongodb-data-validateDBMetadata.apiVersionErrors"> </div> </a> </dt> <dd> <p class="leafygreen-ui-1kp3ins"> Array of documents describing API Version errors. </p> </dd> </dl> <dl class="data"> <dt> <code class="leafygreen-ui-1l06pbn"> validateDBMetadata.apiVersionErrors[n].ns </code> <a class="headerlink leafygreen-ui-1kepx47" href="#mongodb-data-validateDBMetadata.apiVersionErrors-n-.ns" title="Permalink to this definition"> <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="mongodb-data-validateDBMetadata.apiVersionErrors-n-.ns"> </div> </a> </dt> <dd> <p class="leafygreen-ui-1kp3ins"> Namespace of the collection or view with error. </p> </dd> </dl> <dl class="data"> <dt> <code class="leafygreen-ui-1l06pbn"> validateDBMetadata.apiVersionErrors[n].code </code> <a class="headerlink leafygreen-ui-1kepx47" href="#mongodb-data-validateDBMetadata.apiVersionErrors-n-.code" title="Permalink to this definition"> <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="mongodb-data-validateDBMetadata.apiVersionErrors-n-.code"> </div> </a> </dt> <dd> <p class="leafygreen-ui-1kp3ins"> Numeric error code. </p> </dd> </dl> <dl class="data"> <dt> <code class="leafygreen-ui-1l06pbn"> validateDBMetadata.apiVersionErrors[n].codeName </code> <a class="headerlink leafygreen-ui-1kepx47" href="#mongodb-data-validateDBMetadata.apiVersionErrors-n-.codeName" title="Permalink to this definition"> <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="mongodb-data-validateDBMetadata.apiVersionErrors-n-.codeName"> </div> </a> </dt> <dd> <p class="leafygreen-ui-1kp3ins"> Name of the error code. </p> </dd> </dl> <dl class="data"> <dt> <code class="leafygreen-ui-1l06pbn"> validateDBMetadata.apiVersionErrors[n].errmsg </code> <a class="headerlink leafygreen-ui-1kepx47" href="#mongodb-data-validateDBMetadata.apiVersionErrors-n-.errmsg" title="Permalink to this definition"> <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="mongodb-data-validateDBMetadata.apiVersionErrors-n-.errmsg"> </div> </a> </dt> <dd> <p class="leafygreen-ui-1kp3ins"> String describing the error. </p> </dd> </dl> <dl class="data"> <dt> <code class="leafygreen-ui-1l06pbn"> validateDBMetadata.ok </code> <a class="headerlink leafygreen-ui-1kepx47" href="#mongodb-data-validateDBMetadata.ok" title="Permalink to this definition"> <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="mongodb-data-validateDBMetadata.ok"> </div> </a> </dt> <dd> <p class="leafygreen-ui-1kp3ins"> If the command fails, <code class="leafygreen-ui-1l06pbn"> ok </code> is set to <code class="leafygreen-ui-1l06pbn"> 1 </code> . Otherwise, <code class="leafygreen-ui-1l06pbn"> ok </code> is set to <code class="leafygreen-ui-1l06pbn"> 0 </code> . <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-data-validateDBMetadata.ok" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> validateDBMetadata.ok </code> </span> </a> may have a value of <code class="leafygreen-ui-1l06pbn"> 0 </code> and still report validation errors. </p> </dd> </dl> <dl class="data"> <dt> <code class="leafygreen-ui-1l06pbn"> validateDBMetadata.hasMoreErrors </code> <a class="headerlink leafygreen-ui-1kepx47" href="#mongodb-data-validateDBMetadata.hasMoreErrors" title="Permalink to this definition"> <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="mongodb-data-validateDBMetadata.hasMoreErrors"> </div> </a> </dt> <dd> <p class="leafygreen-ui-1kp3ins"> If <code class="leafygreen-ui-1l06pbn"> true </code> , there are additional errors. </p> </dd> </dl> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Example <a class="headerlink leafygreen-ui-1kepx47" href="#example" 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="example"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> Use the sample Query API code to create a <code class="leafygreen-ui-1l06pbn"> sales </code> collection in <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/mongodb-shell/#mongodb-binary-bin.mongosh" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongosh </code> : </span> </a> </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.sales.insertMany([\n { \"_id\" : 1, \"item\" : \"shoes\", \"price\" : 10, \"quantity\" : 2, \"date\" : ISODate(\"2021-01-01T08:00:00Z\") },\n { \"_id\" : 2, \"item\" : \"hat\", \"price\" : 20, \"quantity\" : 1, \"date\" : ISODate(\"2021-02-03T09:00:00Z\") },\n { \"_id\" : 3, \"item\" : \"gloves\", \"price\" : 5, \"quantity\" : 5, \"date\" : ISODate(\"2021-02-03T09:05:00Z\") },\n { \"_id\" : 4, \"item\" : \"pants\", \"price\" : 10, \"quantity\" : 10, \"date\" : ISODate(\"2021-02-15T08:00:00Z\") },\n { \"_id\" : 5, \"item\" : \"socks\", \"price\" : 5, \"quantity\" : 10, \"date\" : ISODate(\"2021-02-15T09:05:00Z\") },\n { \"_id\" : 6, \"item\" : \"shirt\", \"price\" : 5, \"quantity\" : 5, \"date\" : ISODate(\"2021-02-15T12:05:10Z\") },\n { \"_id\" : 7, \"item\" : \"belt\", \"price\" : 5, \"quantity\" : 10, \"date\" : ISODate(\"2021-02-15T14:12:12Z\") },\n { \"_id\" : 8, \"item\" : \"blouse\", \"price\" : 10, \"quantity\" : 5, \"date\" : ISODate(\"2021-03-16T20:20:13Z\") }\n])","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><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">sales</span>.<span class="lg-highlight-title lg-highlight-function">insertMany</span>(<!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">1</span>, <span class="lg-highlight-string">"item"</span> <!-- -->: <span class="lg-highlight-string">"shoes"</span>, <span class="lg-highlight-string">"price"</span> <!-- -->: <span class="lg-highlight-number">10</span>, <span class="lg-highlight-string">"quantity"</span> <!-- -->: <span class="lg-highlight-number">2</span>, <span class="lg-highlight-string">"date"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">ISODate</span>(<span class="lg-highlight-string">"2021-01-01T08:00:00Z"</span>) }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">2</span>, <span class="lg-highlight-string">"item"</span> <!-- -->: <span class="lg-highlight-string">"hat"</span>, <span class="lg-highlight-string">"price"</span> <!-- -->: <span class="lg-highlight-number">20</span>, <span class="lg-highlight-string">"quantity"</span> <!-- -->: <span class="lg-highlight-number">1</span>, <span class="lg-highlight-string">"date"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">ISODate</span>(<span class="lg-highlight-string">"2021-02-03T09:00:00Z"</span>) }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">3</span>, <span class="lg-highlight-string">"item"</span> <!-- -->: <span class="lg-highlight-string">"gloves"</span>, <span class="lg-highlight-string">"price"</span> <!-- -->: <span class="lg-highlight-number">5</span>, <span class="lg-highlight-string">"quantity"</span> <!-- -->: <span class="lg-highlight-number">5</span>, <span class="lg-highlight-string">"date"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">ISODate</span>(<span class="lg-highlight-string">"2021-02-03T09:05:00Z"</span>) }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">4</span>, <span class="lg-highlight-string">"item"</span> <!-- -->: <span class="lg-highlight-string">"pants"</span>, <span class="lg-highlight-string">"price"</span> <!-- -->: <span class="lg-highlight-number">10</span>, <span class="lg-highlight-string">"quantity"</span> <!-- -->: <span class="lg-highlight-number">10</span>, <span class="lg-highlight-string">"date"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">ISODate</span>(<span class="lg-highlight-string">"2021-02-15T08:00:00Z"</span>) }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">5</span>, <span class="lg-highlight-string">"item"</span> <!-- -->: <span class="lg-highlight-string">"socks"</span>, <span class="lg-highlight-string">"price"</span> <!-- -->: <span class="lg-highlight-number">5</span>, <span class="lg-highlight-string">"quantity"</span> <!-- -->: <span class="lg-highlight-number">10</span>, <span class="lg-highlight-string">"date"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">ISODate</span>(<span class="lg-highlight-string">"2021-02-15T09:05:00Z"</span>) }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">6</span>, <span class="lg-highlight-string">"item"</span> <!-- -->: <span class="lg-highlight-string">"shirt"</span>, <span class="lg-highlight-string">"price"</span> <!-- -->: <span class="lg-highlight-number">5</span>, <span class="lg-highlight-string">"quantity"</span> <!-- -->: <span class="lg-highlight-number">5</span>, <span class="lg-highlight-string">"date"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">ISODate</span>(<span class="lg-highlight-string">"2021-02-15T12:05:10Z"</span>) }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">7</span>, <span class="lg-highlight-string">"item"</span> <!-- -->: <span class="lg-highlight-string">"belt"</span>, <span class="lg-highlight-string">"price"</span> <!-- -->: <span class="lg-highlight-number">5</span>, <span class="lg-highlight-string">"quantity"</span> <!-- -->: <span class="lg-highlight-number">10</span>, <span class="lg-highlight-string">"date"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">ISODate</span>(<span class="lg-highlight-string">"2021-02-15T14:12:12Z"</span>) }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">8</span>, <span class="lg-highlight-string">"item"</span> <!-- -->: <span class="lg-highlight-string">"blouse"</span>, <span class="lg-highlight-string">"price"</span> <!-- -->: <span class="lg-highlight-number">10</span>, <span class="lg-highlight-string">"quantity"</span> <!-- -->: <span class="lg-highlight-number">5</span>, <span class="lg-highlight-string">"date"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">ISODate</span>(<span class="lg-highlight-string">"2021-03-16T20:20:13Z"</span>) }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">])</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"> Add a <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/indexes/index-types/index-text/#std-label-index-type-text"> text index </a> on the <code class="leafygreen-ui-1l06pbn"> item </code> field. </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.sales.createIndex( { item: \"text\" } )","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">sales</span>.<span class="lg-highlight-title lg-highlight-function">createIndex</span>( <!-- -->{ <span class="lg-highlight-attr">item</span>: <span class="lg-highlight-string">"text"</span> } )</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"> Validate the <code class="leafygreen-ui-1l06pbn"> sales </code> collection for strict compliance with API version 1 and include <code class="leafygreen-ui-1l06pbn"> deprecationErrors </code> in the output. </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.runCommand( {\n validateDBMetadata: 1,\n apiParameters: {\n version: \"1\",\n strict: true,\n deprecationErrors: true\n },\n collection: \"sales\",\n})","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">runCommand</span>( <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">validateDBMetadata</span>: <span class="lg-highlight-number">1</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">apiParameters</span>: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">version</span>: <span class="lg-highlight-string">"1"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">strict</span>: <span class="lg-highlight-literal">true</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">deprecationErrors</span>: <span class="lg-highlight-literal">true</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">collection</span>: <span class="lg-highlight-string">"sales"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">})</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"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-dbcommand-dbcmd.validateDBMetadata" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> validateDBMetadata </code> </span> </a> reports an <code class="leafygreen-ui-1l06pbn"> APIStrictError </code> on the <code class="leafygreen-ui-1l06pbn"> item_text </code> index. </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{\n apiVersionErrors: [\n {\n ns: 'test.sales',\n code: 323,\n codeName: 'APIStrictError',\n errmsg: 'The index with name item_text is not allowed in API version 1.'\n }\n ],\n ok: 1,\n hasMoreErrors: false,\n}","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">apiVersionErrors</span>: <!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">ns</span>: <span class="lg-highlight-string">'test.sales'</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">code</span>: <span class="lg-highlight-number">323</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">codeName</span>: <span class="lg-highlight-string">'APIStrictError'</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">errmsg</span>: <span class="lg-highlight-string">'The index with name item_text is not allowed in API version 1.'</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> ]<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">ok</span>: <span class="lg-highlight-number">1</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">hasMoreErrors</span>: <span class="lg-highlight-literal">false</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">}</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> </section> </section>
https://www.mongodb.com/docs/manual/reference/operator/update/positional-filtered/
<section> <h1 class="contains-headerlink leafygreen-ui-41fr9s" weight="medium"> $[&lt;identifier&gt;] <a class="headerlink leafygreen-ui-1kepx47" href="#---identifier--" 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="---identifier--"> </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="#definition" target="_self"> <span> Definition </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#behavior" target="_self"> <span> Behavior </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-x9koo9" href="#restrictions" target="_self"> <span> Restrictions </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-x9koo9" href="#upsert" target="_self"> <span> <code class="css-1kekw28 e1wawog0"> upsert </code> </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-x9koo9" href="#nested-arrays" target="_self"> <span> Nested Arrays </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#examples" target="_self"> <span> Examples </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-x9koo9" href="#update-all-array-elements-that-match-arrayfilters" target="_self"> <span> Update All Array Elements That Match <code class="css-1kekw28 e1wawog0"> arrayFilters </code> </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-x9koo9" href="#update-all-documents-that-match-arrayfilters-in-an-array" target="_self"> <span> Update All Documents That Match <code class="css-1kekw28 e1wawog0"> arrayFilters </code> in an Array </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-x9koo9" href="#update-all-array-elements-that-match-multiple-conditions" target="_self"> <span> Update All Array Elements that Match Multiple Conditions </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-x9koo9" href="#update-array-elements-using-a-negation-operator" target="_self"> <span> Update Array Elements Using a Negation Operator </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-x9koo9" href="#update-nested-arrays-in-conjunction-with----" target="_self"> <span> Update Nested Arrays in Conjunction with <code class="css-1kekw28 e1wawog0"> $[] </code> </span> </a> </li> </ul> </div> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Definition <a class="headerlink leafygreen-ui-1kepx47" href="#definition" 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="definition"> </div> </a> </h2> <dl class="update"> <dt> <code class="leafygreen-ui-1l06pbn"> $[&lt;identifier&gt;] </code> <a class="headerlink leafygreen-ui-1kepx47" href="#mongodb-update-up.---identifier--" title="Permalink to this definition"> <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="mongodb-update-up.---identifier--"> </div> </a> </dt> <dd> <p class="leafygreen-ui-1kp3ins"> The filtered positional operator <code class="leafygreen-ui-1l06pbn"> $[&lt;identifier&gt;] </code> identifies the array elements that match the <code class="leafygreen-ui-1l06pbn"> arrayFilters </code> conditions for an update operation, e.g. <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/db.collection.updateMany/#mongodb-method-db.collection.updateMany"> <code class="leafygreen-ui-1l06pbn"> db.collection.updateMany() </code> </a> and <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/db.collection.findAndModify/#mongodb-method-db.collection.findAndModify"> <code class="leafygreen-ui-1l06pbn"> db.collection.findAndModify() </code> . </a> </p> <p class="leafygreen-ui-1kp3ins"> Used in conjunction with the <code class="leafygreen-ui-1l06pbn"> arrayFilters </code> option, the <code class="leafygreen-ui-1l06pbn"> $[&lt;identifier&gt;] </code> operator has the following form: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ &lt;update&gt;: { \"&lt;array&gt;.$[&lt;identifier&gt;]\" : value } },\n{ arrayFilters: [ { &lt;identifier&gt;: &lt;condition&gt; } ] }","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">{ <!-- -->&lt;update operator&gt;: { "&lt;array&gt;.$[&lt;identifier&gt;]" : value } },</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ arrayFilters: [ { &lt;identifier&gt;: &lt;condition&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"> Use in conjunction with the <code class="leafygreen-ui-1l06pbn"> arrayFilters </code> option to update all elements that match the 11arrayFilters`` conditions in the document or documents that match the query conditions. For example: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.collection.updateMany(\n { &lt;query&gt; },\n { &lt;update&gt;: { \"&lt;array&gt;.$[&lt;identifier&gt;]\" : value } },\n { arrayFilters: [ { &lt;identifier&gt;: &lt;condition&gt; } ] }\n)","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><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">updateMany</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <!-- -->&lt;query conditions&gt; },</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> { &lt;update operator&gt;: { "&lt;array&gt;.$[&lt;identifier&gt;]" : value } },</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> { arrayFilters: [ { &lt;identifier&gt;: &lt;condition&gt; } ] }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">)</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-15mdk4" role="note"> <h2 class="leafygreen-ui-6n7b7d"> Note </h2> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> The <code class="leafygreen-ui-1l06pbn"> &lt;identifier&gt; </code> must begin with a lowercase letter and contain only alphanumeric characters. </p> </div> </div> <p class="leafygreen-ui-1kp3ins"> For an example, see <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-positional-update-arrayFilters" target="_self"> <span> Update All Array Elements That Match <code class="leafygreen-ui-1l06pbn"> arrayFilters </code> . </span> </a> </p> </dd> </dl> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Behavior <a class="headerlink leafygreen-ui-1kepx47" href="#behavior" 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="behavior"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> Starting in MongoDB 5.0, update operators process document fields with string-based names in lexicographic order. Fields with numeric names are processed in numeric order. See <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/update/#std-label-update-operators-processing-order"> Update Operators Behavior </a> for details. </p> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Restrictions <a class="headerlink leafygreen-ui-1kepx47" href="#restrictions" 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="restrictions"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> The <code class="leafygreen-ui-1l06pbn"> arrayFilters </code> option cannot include the following query operators: </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/query/expr/#mongodb-query-op.-expr"> <code class="leafygreen-ui-1l06pbn"> $expr </code> </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/query/text/#mongodb-query-op.-text"> <code class="leafygreen-ui-1l06pbn"> $text </code> </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/query/where/#mongodb-query-op.-where"> <code class="leafygreen-ui-1l06pbn"> $where </code> </a> </p> </li> </ul> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> <code class="leafygreen-ui-1l06pbn"> upsert </code> <a class="headerlink leafygreen-ui-1kepx47" href="#upsert" 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="upsert"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> If an <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-upsert"> upsert </a> operation results in an insert, the <code class="leafygreen-ui-1l06pbn"> query </code> must include an <a class="leafygreen-ui-tqgtui" href="/docs/manual/tutorial/query-arrays/#std-label-array-match-exact"> exact equality match </a> on the array field in order to use <code class="leafygreen-ui-1l06pbn"> $[&lt;identifier&gt;] </code> in the update statement. </p> <p class="leafygreen-ui-1kp3ins"> For example, the following upsert operation, which uses <code class="leafygreen-ui-1l06pbn"> $[&lt;identifier&gt;] </code> in the update document, specifies an exact equality match condition on the array field: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.collection.updateOne(\n { myArray: [ 0, 1 ] },\n { $set: { \"myArray.$[element]\": 2 } },\n { arrayFilters: [ { element: 0 } ], upsert: true }\n)","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">updateOne</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">myArray</span>: <!-- -->[ <span class="lg-highlight-number">0</span>, <span class="lg-highlight-number">1</span> ] }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">$set</span>: <!-- -->{ <span class="lg-highlight-string">"myArray.$[element]"</span>: <span class="lg-highlight-number">2</span> } }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">arrayFilters</span>: <!-- -->[ <!-- -->{ <span class="lg-highlight-attr">element</span>: <span class="lg-highlight-number">0</span> } ]<!-- -->, <span class="lg-highlight-attr">upsert</span>: <span class="lg-highlight-literal">true</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">)</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"> If no such document exists, the operation would result in an insert of a document that resembles the following: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ \"_id\" : ObjectId(...), \"myArray\" : [ 2, 1 ] }","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">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">ObjectId</span>(<!-- -->...<!-- -->)<!-- -->, <span class="lg-highlight-string">"myArray"</span> <!-- -->: <!-- -->[ <span class="lg-highlight-number">2</span>, <span class="lg-highlight-number">1</span> ] }</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"> If the upsert operation did not include an exact equality match and no matching documents were found to update, the upsert operation would error. For example, the following operations would error if no matching documents were found to update: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.array.updateOne(\n { },\n { $set: { \"myArray.$[element]\": 10 } },\n { arrayFilters: [ { element: 9 } ], upsert: true }\n)","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">array</span>.<span class="lg-highlight-title lg-highlight-function">updateOne</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <!-- -->}<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">$set</span>: <!-- -->{ <span class="lg-highlight-string">"myArray.$[element]"</span>: <span class="lg-highlight-number">10</span> } }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">arrayFilters</span>: <!-- -->[ <!-- -->{ <span class="lg-highlight-attr">element</span>: <span class="lg-highlight-number">9</span> } ]<!-- -->, <span class="lg-highlight-attr">upsert</span>: <span class="lg-highlight-literal">true</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">)</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 operation would return an error that resembles the following: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"MongoServerError: The path 'myArray' must exist in the document in order to apply array updates.","programmingLanguage":"JavaScript"} </script> <div class="css-1lju8ps"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-tyg50d"> <pre class="leafygreen-ui-1agdxuk" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-title lg-highlight-class">MongoServerError</span>: <span class="lg-highlight-title lg-highlight-class">The</span> path <span class="lg-highlight-string">'myArray'</span> must exist <span class="lg-highlight-keyword">in</span> the <span class="lg-highlight-variable lg-highlight-language">document</span> <span class="lg-highlight-keyword">in</span> order to apply array updates.</td></tr></tbody></table></code></pre> </div> </div> </div> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Nested Arrays <a class="headerlink leafygreen-ui-1kepx47" href="#nested-arrays" 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="nested-arrays"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> The filtered positional operator <code class="leafygreen-ui-1l06pbn"> $[&lt;identifier&gt;] </code> can be used for queries which traverse more than one array and nested arrays. </p> <p class="leafygreen-ui-1kp3ins"> For an example, see <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-position-nested-arrays-filtered" target="_self"> <span> Update Nested Arrays in Conjunction with <code class="leafygreen-ui-1l06pbn"> $[] </code> . </span> </a> </p> </section> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Examples <a class="headerlink leafygreen-ui-1kepx47" href="#examples" 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="examples"> </div> </a> </h2> <span class="leafygreen-ui-1qnjd6d" id="std-label-positional-update-arrayFilters"> </span> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Update All Array Elements That Match <code class="leafygreen-ui-1l06pbn"> arrayFilters </code> <a class="headerlink leafygreen-ui-1kepx47" href="#update-all-array-elements-that-match-arrayfilters" 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="update-all-array-elements-that-match-arrayfilters"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> Create the <code class="leafygreen-ui-1l06pbn"> students </code> collection: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.students.insertMany( [\n { \"_id\" : 1, \"grades\" : [ 95, 92, 90 ] },\n { \"_id\" : 2, \"grades\" : [ 98, 100, 102 ] },\n { \"_id\" : 3, \"grades\" : [ 95, 110, 100 ] }\n] )","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">students</span>.<span class="lg-highlight-title lg-highlight-function">insertMany</span>( <!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">1</span>, <span class="lg-highlight-string">"grades"</span> <!-- -->: <!-- -->[ <span class="lg-highlight-number">95</span>, <span class="lg-highlight-number">92</span>, <span class="lg-highlight-number">90</span> ] }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">2</span>, <span class="lg-highlight-string">"grades"</span> <!-- -->: <!-- -->[ <span class="lg-highlight-number">98</span>, <span class="lg-highlight-number">100</span>, <span class="lg-highlight-number">102</span> ] }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">3</span>, <span class="lg-highlight-string">"grades"</span> <!-- -->: <!-- -->[ <span class="lg-highlight-number">95</span>, <span class="lg-highlight-number">110</span>, <span class="lg-highlight-number">100</span> ] }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">] )</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"> To update all elements that are greater than or equal to <code class="leafygreen-ui-1l06pbn"> 100 </code> in the <code class="leafygreen-ui-1l06pbn"> grades </code> array, use the filtered positional operator <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-update-up.---identifier--" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $[&lt;identifier&gt;] </code> </span> </a> with the <code class="leafygreen-ui-1l06pbn"> arrayFilters </code> : </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.students.updateMany(\n { },\n { $set: { \"grades.$[element]\" : 100 } },\n { arrayFilters: [ { \"element\": { $gte: 100 } } ] }\n)","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">students</span>.<span class="lg-highlight-title lg-highlight-function">updateMany</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <!-- -->}<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">$set</span>: <!-- -->{ <span class="lg-highlight-string">"grades.$[element]"</span> <!-- -->: <span class="lg-highlight-number">100</span> } }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">arrayFilters</span>: <!-- -->[ <!-- -->{ <span class="lg-highlight-string">"element"</span>: <!-- -->{ <span class="lg-highlight-attr">$gte</span>: <span class="lg-highlight-number">100</span> } } ] }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">)</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 positional <code class="leafygreen-ui-1l06pbn"> $[&lt;identifier&gt;] </code> operator acts as a placeholder for all elements in the array field that match the conditions specified in <code class="leafygreen-ui-1l06pbn"> arrayFilters </code> . </p> <p class="leafygreen-ui-1kp3ins"> After the operation, the <code class="leafygreen-ui-1l06pbn"> students </code> collection contains the following documents: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ \"_id\" : 1, \"grades\" : [ 95, 92, 90 ] }\n{ \"_id\" : 2, \"grades\" : [ 98, 100, 100 ] }\n{ \"_id\" : 3, \"grades\" : [ 95, 100, 100 ] }","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">1</span>, <span class="lg-highlight-string">"grades"</span> <!-- -->: <!-- -->[ <span class="lg-highlight-number">95</span>, <span class="lg-highlight-number">92</span>, <span class="lg-highlight-number">90</span> ] }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">2</span>, <span class="lg-highlight-string">"grades"</span> <!-- -->: <!-- -->[ <span class="lg-highlight-number">98</span>, <span class="lg-highlight-number">100</span>, <span class="lg-highlight-number">100</span> ] }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">3</span>, <span class="lg-highlight-string">"grades"</span> <!-- -->: <!-- -->[ <span class="lg-highlight-number">95</span>, <span class="lg-highlight-number">100</span>, <span class="lg-highlight-number">100</span> ] }</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> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Update All Documents That Match <code class="leafygreen-ui-1l06pbn"> arrayFilters </code> in an Array <a class="headerlink leafygreen-ui-1kepx47" href="#update-all-documents-that-match-arrayfilters-in-an-array" 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="update-all-documents-that-match-arrayfilters-in-an-array"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> The <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-update-up.---identifier--" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $[&lt;identifier&gt;] </code> </span> </a> operator facilitates updates to arrays that contain embedded documents. To access the fields in the embedded documents, use the <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/document/#std-label-document-dot-notation"> dot notation </a> with the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-update-up.---identifier--" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $[&lt;identifier&gt;] </code> . </span> </a> </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.collection.updateMany(\n { &lt;query&gt; },\n { &lt;update&gt;: { \"array.$[&lt;identifier&gt;].field\" : value } },\n { arrayFilters: [ { &lt;identifier&gt;: &lt;condition&gt; } } ] }\n)","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><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">updateMany</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <!-- -->&lt;query selector&gt; },</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> { &lt;update operator&gt;: { "array.$[&lt;identifier&gt;].field" : value } },</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> { arrayFilters: [ { &lt;identifier&gt;: &lt;condition&gt; } } ] }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">)</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"> Create the <code class="leafygreen-ui-1l06pbn"> students2 </code> collection: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.students2.insertMany( [\n {\n \"_id\" : 1,\n \"grades\" : [\n { \"grade\" : 80, \"mean\" : 75, \"std\" : 6 },\n { \"grade\" : 85, \"mean\" : 90, \"std\" : 4 },\n { \"grade\" : 85, \"mean\" : 85, \"std\" : 6 }\n ]\n },\n {\n \"_id\" : 2,\n \"grades\" : [\n { \"grade\" : 90, \"mean\" : 75, \"std\" : 6 },\n { \"grade\" : 87, \"mean\" : 90, \"std\" : 3 },\n { \"grade\" : 85, \"mean\" : 85, \"std\" : 4 }\n ]\n }\n] )","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">students2</span>.<span class="lg-highlight-title lg-highlight-function">insertMany</span>( <!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">1</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"grades"</span> <!-- -->: <!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"grade"</span> <!-- -->: <span class="lg-highlight-number">80</span>, <span class="lg-highlight-string">"mean"</span> <!-- -->: <span class="lg-highlight-number">75</span>, <span class="lg-highlight-string">"std"</span> <!-- -->: <span class="lg-highlight-number">6</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"grade"</span> <!-- -->: <span class="lg-highlight-number">85</span>, <span class="lg-highlight-string">"mean"</span> <!-- -->: <span class="lg-highlight-number">90</span>, <span class="lg-highlight-string">"std"</span> <!-- -->: <span class="lg-highlight-number">4</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"grade"</span> <!-- -->: <span class="lg-highlight-number">85</span>, <span class="lg-highlight-string">"mean"</span> <!-- -->: <span class="lg-highlight-number">85</span>, <span class="lg-highlight-string">"std"</span> <!-- -->: <span class="lg-highlight-number">6</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> ]</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">2</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"grades"</span> <!-- -->: <!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"grade"</span> <!-- -->: <span class="lg-highlight-number">90</span>, <span class="lg-highlight-string">"mean"</span> <!-- -->: <span class="lg-highlight-number">75</span>, <span class="lg-highlight-string">"std"</span> <!-- -->: <span class="lg-highlight-number">6</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"grade"</span> <!-- -->: <span class="lg-highlight-number">87</span>, <span class="lg-highlight-string">"mean"</span> <!-- -->: <span class="lg-highlight-number">90</span>, <span class="lg-highlight-string">"std"</span> <!-- -->: <span class="lg-highlight-number">3</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"grade"</span> <!-- -->: <span class="lg-highlight-number">85</span>, <span class="lg-highlight-string">"mean"</span> <!-- -->: <span class="lg-highlight-number">85</span>, <span class="lg-highlight-string">"std"</span> <!-- -->: <span class="lg-highlight-number">4</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> ]</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">] )</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"> To modify the value of the <code class="leafygreen-ui-1l06pbn"> mean </code> field for all elements in the <code class="leafygreen-ui-1l06pbn"> grades </code> array where the grade is greater than or equal to <code class="leafygreen-ui-1l06pbn"> 85 </code> , use the positional <code class="leafygreen-ui-1l06pbn"> $[&lt;identifier&gt;] </code> operator and <code class="leafygreen-ui-1l06pbn"> arrayFilters </code> : </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.students2.updateMany(\n { },\n { $set: { \"grades.$[elem].mean\" : 100 } },\n { arrayFilters: [ { \"elem.grade\": { $gte: 85 } } ] }\n)","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">students2</span>.<span class="lg-highlight-title lg-highlight-function">updateMany</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <!-- -->}<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">$set</span>: <!-- -->{ <span class="lg-highlight-string">"grades.$[elem].mean"</span> <!-- -->: <span class="lg-highlight-number">100</span> } }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">arrayFilters</span>: <!-- -->[ <!-- -->{ <span class="lg-highlight-string">"elem.grade"</span>: <!-- -->{ <span class="lg-highlight-attr">$gte</span>: <span class="lg-highlight-number">85</span> } } ] }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">)</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"> After the operation, the collection has the following documents: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{\n \"_id\" : 1,\n \"grades\" : [\n { \"grade\" : 80, \"mean\" : 75, \"std\" : 6 },\n { \"grade\" : 85, \"mean\" : 100, \"std\" : 4 },\n { \"grade\" : 85, \"mean\" : 100, \"std\" : 6 }\n ]\n}\n{\n \"_id\" : 2,\n \"grades\" : [\n { \"grade\" : 90, \"mean\" : 100, \"std\" : 6 },\n { \"grade\" : 87, \"mean\" : 100, \"std\" : 3 },\n { \"grade\" : 85, \"mean\" : 100, \"std\" : 4 }\n ]\n}","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">1</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"grades"</span> <!-- -->: <!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"grade"</span> <!-- -->: <span class="lg-highlight-number">80</span>, <span class="lg-highlight-string">"mean"</span> <!-- -->: <span class="lg-highlight-number">75</span>, <span class="lg-highlight-string">"std"</span> <!-- -->: <span class="lg-highlight-number">6</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"grade"</span> <!-- -->: <span class="lg-highlight-number">85</span>, <span class="lg-highlight-string">"mean"</span> <!-- -->: <span class="lg-highlight-number">100</span>, <span class="lg-highlight-string">"std"</span> <!-- -->: <span class="lg-highlight-number">4</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"grade"</span> <!-- -->: <span class="lg-highlight-number">85</span>, <span class="lg-highlight-string">"mean"</span> <!-- -->: <span class="lg-highlight-number">100</span>, <span class="lg-highlight-string">"std"</span> <!-- -->: <span class="lg-highlight-number">6</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> ]</td></tr><tr class=""><td class="leafygreen-ui-7razhx">}</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">2</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"grades"</span> <!-- -->: <!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"grade"</span> <!-- -->: <span class="lg-highlight-number">90</span>, <span class="lg-highlight-string">"mean"</span> <!-- -->: <span class="lg-highlight-number">100</span>, <span class="lg-highlight-string">"std"</span> <!-- -->: <span class="lg-highlight-number">6</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"grade"</span> <!-- -->: <span class="lg-highlight-number">87</span>, <span class="lg-highlight-string">"mean"</span> <!-- -->: <span class="lg-highlight-number">100</span>, <span class="lg-highlight-string">"std"</span> <!-- -->: <span class="lg-highlight-number">3</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"grade"</span> <!-- -->: <span class="lg-highlight-number">85</span>, <span class="lg-highlight-string">"mean"</span> <!-- -->: <span class="lg-highlight-number">100</span>, <span class="lg-highlight-string">"std"</span> <!-- -->: <span class="lg-highlight-number">4</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> ]</td></tr><tr class=""><td class="leafygreen-ui-7razhx">}</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> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Update All Array Elements that Match Multiple Conditions <a class="headerlink leafygreen-ui-1kepx47" href="#update-all-array-elements-that-match-multiple-conditions" 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="update-all-array-elements-that-match-multiple-conditions"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> Create the <code class="leafygreen-ui-1l06pbn"> students3 </code> collection: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.students3.insertMany( [\n {\n \"_id\" : 1,\n \"grades\" : [\n { \"grade\" : 80, \"mean\" : 75, \"std\" : 6 },\n { \"grade\" : 85, \"mean\" : 100, \"std\" : 4 },\n { \"grade\" : 85, \"mean\" : 100, \"std\" : 6 }\n ]\n },\n {\n \"_id\" : 2,\n \"grades\" : [\n { \"grade\" : 90, \"mean\" : 100, \"std\" : 6 },\n { \"grade\" : 87, \"mean\" : 100, \"std\" : 3 },\n { \"grade\" : 85, \"mean\" : 100, \"std\" : 4 }\n ]\n }\n] )","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">students3</span>.<span class="lg-highlight-title lg-highlight-function">insertMany</span>( <!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">1</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"grades"</span> <!-- -->: <!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"grade"</span> <!-- -->: <span class="lg-highlight-number">80</span>, <span class="lg-highlight-string">"mean"</span> <!-- -->: <span class="lg-highlight-number">75</span>, <span class="lg-highlight-string">"std"</span> <!-- -->: <span class="lg-highlight-number">6</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"grade"</span> <!-- -->: <span class="lg-highlight-number">85</span>, <span class="lg-highlight-string">"mean"</span> <!-- -->: <span class="lg-highlight-number">100</span>, <span class="lg-highlight-string">"std"</span> <!-- -->: <span class="lg-highlight-number">4</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"grade"</span> <!-- -->: <span class="lg-highlight-number">85</span>, <span class="lg-highlight-string">"mean"</span> <!-- -->: <span class="lg-highlight-number">100</span>, <span class="lg-highlight-string">"std"</span> <!-- -->: <span class="lg-highlight-number">6</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> ]</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">2</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"grades"</span> <!-- -->: <!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"grade"</span> <!-- -->: <span class="lg-highlight-number">90</span>, <span class="lg-highlight-string">"mean"</span> <!-- -->: <span class="lg-highlight-number">100</span>, <span class="lg-highlight-string">"std"</span> <!-- -->: <span class="lg-highlight-number">6</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"grade"</span> <!-- -->: <span class="lg-highlight-number">87</span>, <span class="lg-highlight-string">"mean"</span> <!-- -->: <span class="lg-highlight-number">100</span>, <span class="lg-highlight-string">"std"</span> <!-- -->: <span class="lg-highlight-number">3</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"grade"</span> <!-- -->: <span class="lg-highlight-number">85</span>, <span class="lg-highlight-string">"mean"</span> <!-- -->: <span class="lg-highlight-number">100</span>, <span class="lg-highlight-string">"std"</span> <!-- -->: <span class="lg-highlight-number">4</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> ]</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">] )</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"> To modify the value of the <code class="leafygreen-ui-1l06pbn"> std </code> field for all elements in the <code class="leafygreen-ui-1l06pbn"> grades </code> array where both the grade is greater than or equal to <code class="leafygreen-ui-1l06pbn"> 80 </code> and the <code class="leafygreen-ui-1l06pbn"> std </code> is greater than or equal to <code class="leafygreen-ui-1l06pbn"> 5 </code> , use the positional <code class="leafygreen-ui-1l06pbn"> $[&lt;identifier&gt;] </code> operator and <code class="leafygreen-ui-1l06pbn"> arrayFilters </code> : </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.students3.updateMany(\n { },\n { $inc: { \"grades.$[elem].std\" : -1 } },\n { arrayFilters: [ { \"elem.grade\": { $gte: 80 }, \"elem.std\": { $gte: 5 } } ] }\n)","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><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">students3</span>.<span class="lg-highlight-title lg-highlight-function">updateMany</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <!-- -->}<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">$inc</span>: <!-- -->{ <span class="lg-highlight-string">"grades.$[elem].std"</span> <!-- -->: <!-- -->-<span class="lg-highlight-number">1</span> } }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">arrayFilters</span>: <!-- -->[ <!-- -->{ <span class="lg-highlight-string">"elem.grade"</span>: <!-- -->{ <span class="lg-highlight-attr">$gte</span>: <span class="lg-highlight-number">80</span> }<!-- -->, <span class="lg-highlight-string">"elem.std"</span>: <!-- -->{ <span class="lg-highlight-attr">$gte</span>: <span class="lg-highlight-number">5</span> } } ] }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">)</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"> After the operation, the collection has the following documents: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ \"_id\" : 1,\n \"grades\" : [\n { \"grade\" : 80, \"mean\" : 75, \"std\" : 5 },\n { \"grade\" : 85, \"mean\" : 100, \"std\" : 4 },\n { \"grade\" : 85, \"mean\" : 100, \"std\" : 5 }\n ]\n}\n{\n \"_id\" : 2,\n \"grades\" : [\n { \"grade\" : 90, \"mean\" : 100, \"std\" : 5 },\n { \"grade\" : 87, \"mean\" : 100, \"std\" : 3 },\n { \"grade\" : 85, \"mean\" : 100, \"std\" : 4 }\n ]\n}","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">1</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"grades"</span> <!-- -->: <!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"grade"</span> <!-- -->: <span class="lg-highlight-number">80</span>, <span class="lg-highlight-string">"mean"</span> <!-- -->: <span class="lg-highlight-number">75</span>, <span class="lg-highlight-string">"std"</span> <!-- -->: <span class="lg-highlight-number">5</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"grade"</span> <!-- -->: <span class="lg-highlight-number">85</span>, <span class="lg-highlight-string">"mean"</span> <!-- -->: <span class="lg-highlight-number">100</span>, <span class="lg-highlight-string">"std"</span> <!-- -->: <span class="lg-highlight-number">4</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"grade"</span> <!-- -->: <span class="lg-highlight-number">85</span>, <span class="lg-highlight-string">"mean"</span> <!-- -->: <span class="lg-highlight-number">100</span>, <span class="lg-highlight-string">"std"</span> <!-- -->: <span class="lg-highlight-number">5</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> ]</td></tr><tr class=""><td class="leafygreen-ui-7razhx">}</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">2</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"grades"</span> <!-- -->: <!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"grade"</span> <!-- -->: <span class="lg-highlight-number">90</span>, <span class="lg-highlight-string">"mean"</span> <!-- -->: <span class="lg-highlight-number">100</span>, <span class="lg-highlight-string">"std"</span> <!-- -->: <span class="lg-highlight-number">5</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"grade"</span> <!-- -->: <span class="lg-highlight-number">87</span>, <span class="lg-highlight-string">"mean"</span> <!-- -->: <span class="lg-highlight-number">100</span>, <span class="lg-highlight-string">"std"</span> <!-- -->: <span class="lg-highlight-number">3</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"grade"</span> <!-- -->: <span class="lg-highlight-number">85</span>, <span class="lg-highlight-string">"mean"</span> <!-- -->: <span class="lg-highlight-number">100</span>, <span class="lg-highlight-string">"std"</span> <!-- -->: <span class="lg-highlight-number">4</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> ]</td></tr><tr class=""><td class="leafygreen-ui-7razhx">}</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> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Update Array Elements Using a Negation Operator <a class="headerlink leafygreen-ui-1kepx47" href="#update-array-elements-using-a-negation-operator" 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="update-array-elements-using-a-negation-operator"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> Create the <code class="leafygreen-ui-1l06pbn"> alumni </code> collection: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.alumni.insertMany( [\n {\n \"_id\": 1,\n \"name\": \"Christine Franklin\",\n \"degrees\": [\n { \"level\": \"Master\" },\n { \"level\": \"Bachelor\" }\n ],\n },\n {\n \"_id\": 2,\n \"name\": \"Reyansh Sengupta\",\n \"degrees\": [ { \"level\": \"Bachelor\" } ],\n }\n] )","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">alumni</span>.<span class="lg-highlight-title lg-highlight-function">insertMany</span>( <!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"_id"</span>: <span class="lg-highlight-number">1</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"name"</span>: <span class="lg-highlight-string">"Christine Franklin"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"degrees"</span>: <!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"level"</span>: <span class="lg-highlight-string">"Master"</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"level"</span>: <span class="lg-highlight-string">"Bachelor"</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> ]<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->}<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"_id"</span>: <span class="lg-highlight-number">2</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"name"</span>: <span class="lg-highlight-string">"Reyansh Sengupta"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"degrees"</span>: <!-- -->[ <!-- -->{ <span class="lg-highlight-string">"level"</span>: <span class="lg-highlight-string">"Bachelor"</span> } ]<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->}</td></tr><tr class=""><td class="leafygreen-ui-7razhx">] )</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"> To modify all elements in the <code class="leafygreen-ui-1l06pbn"> degrees </code> array that do not have <code class="leafygreen-ui-1l06pbn"> "level": "Bachelor" </code> , use the positional <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-update-up.---identifier--" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $[&lt;identifier&gt;] </code> </span> </a> operation with the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/query/ne/#mongodb-query-op.-ne"> <code class="leafygreen-ui-1l06pbn"> $ne </code> </a> query operator: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.alumni.updateMany(\n { },\n { $set : { \"degrees.$[degree].gradcampaign\" : 1 } },\n { arrayFilters : [ {\"degree.level\" : { $ne: \"Bachelor\" } } ] }\n)","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><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">alumni</span>.<span class="lg-highlight-title lg-highlight-function">updateMany</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <!-- -->}<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <!-- -->$set<!-- --> <!-- -->: <!-- -->{ <span class="lg-highlight-string">"degrees.$[degree].gradcampaign"</span> <!-- -->: <span class="lg-highlight-number">1</span> } }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <!-- -->arrayFilters <!-- -->: <!-- -->[ <!-- -->{<span class="lg-highlight-string">"degree.level"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-attr">$ne</span>: <span class="lg-highlight-string">"Bachelor"</span> } } ] }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">)</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"> After the operation, the collection has the following documents: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":" {\n _id: 1,\n name: 'Christine Franklin',\n degrees: [\n { level: 'Master', gradcampaign: 1 },\n { level: 'Bachelor' }\n ]\n},\n{\n _id: 2,\n name: 'Reyansh Sengupta',\n degrees: [ { level: 'Bachelor' } ]\n}"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" tabindex="-1"><code class="lg-highlight-hljs-light none leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx"> {</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> _id: 1,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> name: 'Christine Franklin',</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> degrees: [</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> { level: 'Master', gradcampaign: 1 },</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> { level: 'Bachelor' }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> ]</td></tr><tr class=""><td class="leafygreen-ui-7razhx">},</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> _id: 2,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> name: 'Reyansh Sengupta',</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> degrees: [ { level: 'Bachelor' } ]</td></tr><tr class=""><td class="leafygreen-ui-7razhx">}</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> <span class="leafygreen-ui-1qnjd6d" id="std-label-position-nested-arrays-filtered"> </span> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Update Nested Arrays in Conjunction with <code class="leafygreen-ui-1l06pbn"> $[] </code> <a class="headerlink leafygreen-ui-1kepx47" href="#update-nested-arrays-in-conjunction-with----" 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="update-nested-arrays-in-conjunction-with----"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> The <code class="leafygreen-ui-1l06pbn"> $[&lt;identifier&gt;] </code> filtered positional operator, in conjunction with the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/update/positional-all/#mongodb-update-up.---"> <code class="leafygreen-ui-1l06pbn"> $[] </code> </a> all positional operator, can be used to update nested arrays. </p> <p class="leafygreen-ui-1kp3ins"> Create a collection <code class="leafygreen-ui-1l06pbn"> students4 </code> with the following document: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.students4.insertOne(\n { \"_id\" : 1,\n \"grades\" : [\n { type: \"quiz\", questions: [ 10, 8, 5 ] },\n { type: \"quiz\", questions: [ 8, 9, 6 ] },\n { type: \"hw\", questions: [ 5, 4, 3 ] },\n { type: \"exam\", questions: [ 25, 10, 23, 0 ] },\n ]\n }\n)","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">students4</span>.<span class="lg-highlight-title lg-highlight-function">insertOne</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">1</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"grades"</span> <!-- -->: <!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">type</span>: <span class="lg-highlight-string">"quiz"</span>, <span class="lg-highlight-attr">questions</span>: <!-- -->[ <span class="lg-highlight-number">10</span>, <span class="lg-highlight-number">8</span>, <span class="lg-highlight-number">5</span> ] }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">type</span>: <span class="lg-highlight-string">"quiz"</span>, <span class="lg-highlight-attr">questions</span>: <!-- -->[ <span class="lg-highlight-number">8</span>, <span class="lg-highlight-number">9</span>, <span class="lg-highlight-number">6</span> ] }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">type</span>: <span class="lg-highlight-string">"hw"</span>, <span class="lg-highlight-attr">questions</span>: <!-- -->[ <span class="lg-highlight-number">5</span>, <span class="lg-highlight-number">4</span>, <span class="lg-highlight-number">3</span> ] }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">type</span>: <span class="lg-highlight-string">"exam"</span>, <span class="lg-highlight-attr">questions</span>: <!-- -->[ <span class="lg-highlight-number">25</span>, <span class="lg-highlight-number">10</span>, <span class="lg-highlight-number">23</span>, <span class="lg-highlight-number">0</span> ] }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->]</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">)</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 updates the values that are greater than or equal to <code class="leafygreen-ui-1l06pbn"> 8 </code> in the nested <code class="leafygreen-ui-1l06pbn"> grades.questions </code> array if the associated <code class="leafygreen-ui-1l06pbn"> grades.type </code> field is <code class="leafygreen-ui-1l06pbn"> quiz </code> . </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.students4.updateMany(\n {},\n { $inc: { \"grades.$[t].questions.$[score]\": 2 } },\n { arrayFilters: [ { \"t.type\": \"quiz\" }, { \"score\": { $gte: 8 } } ] }\n)","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><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">students4</span>.<span class="lg-highlight-title lg-highlight-function">updateMany</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{<!-- -->}<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">$inc</span>: <!-- -->{ <span class="lg-highlight-string">"grades.$[t].questions.$[score]"</span>: <span class="lg-highlight-number">2</span> } }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">arrayFilters</span>: <!-- -->[ <!-- -->{ <span class="lg-highlight-string">"t.type"</span>: <span class="lg-highlight-string">"quiz"</span> }<!-- -->, <!-- -->{ <span class="lg-highlight-string">"score"</span>: <!-- -->{ <span class="lg-highlight-attr">$gte</span>: <span class="lg-highlight-number">8</span> } } ] }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">)</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-15mdk4" role="note"> <h2 class="leafygreen-ui-6n7b7d"> Note </h2> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> Don't add spaces around the array identifiers. If you use <code class="leafygreen-ui-1l06pbn"> grades.$[ t ].questions.$[ score ] </code> in the previous example, the example fails. </p> </div> </div> <p class="leafygreen-ui-1kp3ins"> After the operation, the collection has the following document: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{\n \"_id\" : 1,\n \"grades\" : [\n { \"type\" : \"quiz\", \"questions\" : [ 12, 10, 5 ] },\n { \"type\" : \"quiz\", \"questions\" : [ 10, 11, 6 ] },\n { \"type\" : \"hw\", \"questions\" : [ 5, 4, 3 ] },\n { \"type\" : \"exam\", \"questions\" : [ 25, 10, 23, 0 ] }\n ]\n}","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">1</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"grades"</span> <!-- -->: <!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"type"</span> <!-- -->: <span class="lg-highlight-string">"quiz"</span>, <span class="lg-highlight-string">"questions"</span> <!-- -->: <!-- -->[ <span class="lg-highlight-number">12</span>, <span class="lg-highlight-number">10</span>, <span class="lg-highlight-number">5</span> ] }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"type"</span> <!-- -->: <span class="lg-highlight-string">"quiz"</span>, <span class="lg-highlight-string">"questions"</span> <!-- -->: <!-- -->[ <span class="lg-highlight-number">10</span>, <span class="lg-highlight-number">11</span>, <span class="lg-highlight-number">6</span> ] }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"type"</span> <!-- -->: <span class="lg-highlight-string">"hw"</span>, <span class="lg-highlight-string">"questions"</span> <!-- -->: <!-- -->[ <span class="lg-highlight-number">5</span>, <span class="lg-highlight-number">4</span>, <span class="lg-highlight-number">3</span> ] }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"type"</span> <!-- -->: <span class="lg-highlight-string">"exam"</span>, <span class="lg-highlight-string">"questions"</span> <!-- -->: <!-- -->[ <span class="lg-highlight-number">25</span>, <span class="lg-highlight-number">10</span>, <span class="lg-highlight-number">23</span>, <span class="lg-highlight-number">0</span> ] }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> ]</td></tr><tr class=""><td class="leafygreen-ui-7razhx">}</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"> To update all values that are greater than or equal to <code class="leafygreen-ui-1l06pbn"> 8 </code> in the nested <code class="leafygreen-ui-1l06pbn"> grades.questions </code> array, regardless of <code class="leafygreen-ui-1l06pbn"> type </code> : </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.students4.updateMany(\n {},\n { $inc: { \"grades.$[].questions.$[score]\": 2 } },\n { arrayFilters: [ { \"score\": { $gte: 8 } } ] }\n)","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">students4</span>.<span class="lg-highlight-title lg-highlight-function">updateMany</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{<!-- -->}<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">$inc</span>: <!-- -->{ <span class="lg-highlight-string">"grades.$[].questions.$[score]"</span>: <span class="lg-highlight-number">2</span> } }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">arrayFilters</span>: <!-- -->[ <!-- -->{ <span class="lg-highlight-string">"score"</span>: <!-- -->{ <span class="lg-highlight-attr">$gte</span>: <span class="lg-highlight-number">8</span> } } ] }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">)</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-13vw3ie" role="note"> <h2 class="leafygreen-ui-1fn4p2b"> Tip </h2> <h3 class="leafygreen-ui-144d5kf"> <strong> See also: </strong> </h3> <div class="leafygreen-ui-9mycqc"> <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/update/positional-all/#mongodb-update-up.---"> <code class="leafygreen-ui-1l06pbn"> $[] </code> </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/db.collection.updateMany/#mongodb-method-db.collection.updateMany"> <code class="leafygreen-ui-1l06pbn"> db.collection.updateMany() </code> </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/db.collection.findAndModify/#mongodb-method-db.collection.findAndModify"> <code class="leafygreen-ui-1l06pbn"> db.collection.findAndModify() </code> </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/query/elemMatch/#mongodb-query-op.-elemMatch"> <code class="leafygreen-ui-1l06pbn"> $elemMatch </code> </a> </p> </li> </ul> </div> </div> </section> </section> </section>
https://www.mongodb.com/docs/manual/reference/command/listCollections/
<section> <h1 class="contains-headerlink leafygreen-ui-41fr9s" weight="medium"> listCollections <a class="headerlink leafygreen-ui-1kepx47" href="#listcollections" 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="listcollections"> </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="#definition" target="_self"> <span> Definition </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#compatibility" target="_self"> <span> Compatibility </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#syntax" target="_self"> <span> Syntax </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#command-fields" target="_self"> <span> Command Fields </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#behavior" target="_self"> <span> Behavior </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#required-access" target="_self"> <span> Required Access </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#output" target="_self"> <span> Output </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#example" target="_self"> <span> Example </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#learn-more" target="_self"> <span> Learn More </span> </a> </li> </ul> </div> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Definition <a class="headerlink leafygreen-ui-1kepx47" href="#definition" 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="definition"> </div> </a> </h2> <dl class="dbcommand"> <dt> <code class="leafygreen-ui-1l06pbn"> listCollections </code> <a class="headerlink leafygreen-ui-1kepx47" href="#mongodb-dbcommand-dbcmd.listCollections" title="Permalink to this definition"> <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="mongodb-dbcommand-dbcmd.listCollections"> </div> </a> </dt> <dd> <p class="leafygreen-ui-1kp3ins"> Retrieves information, including the names and creation options, for the collections and <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/views/#std-label-views-landing-page"> views </a> in a database. </p> <p class="leafygreen-ui-1kp3ins"> The <code class="leafygreen-ui-1l06pbn"> listCollections </code> command returns a document that contains an unsorted list of all collections and views in the database. You can use the returned document to create a <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/js-cursor/#std-label-doc-cursor-methods"> cursor </a> on the collection. </p> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/mongodb-shell/#mongodb-binary-bin.mongosh" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongosh </code> </span> </a> provides the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/db.getCollectionInfos/#mongodb-method-db.getCollectionInfos"> <code class="leafygreen-ui-1l06pbn"> db.getCollectionInfos() </code> </a> and the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/db.getCollectionNames/#mongodb-method-db.getCollectionNames"> <code class="leafygreen-ui-1l06pbn"> db.getCollectionNames() </code> </a> helper methods. </p> </dd> </dl> </section> <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"> This command is available in 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> <div class="leafygreen-ui-15mdk4" role="note"> <h2 class="leafygreen-ui-6n7b7d"> Note </h2> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> This command is supported in all MongoDB Atlas clusters. For information on Atlas support for all commands, see <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/atlas/unsupported-commands/" target="_self"> <span> Unsupported Commands <!-- --> . </span> </a> </p> </div> </div> <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"> Syntax <a class="headerlink leafygreen-ui-1kepx47" href="#syntax" 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="syntax"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> The command has the following syntax: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.runCommand(\n {\n listCollections: 1,\n filter: &lt;document&gt;,\n nameOnly: &lt;boolean&gt;,\n authorizedCollections: &lt;boolean&gt;,\n comment: &lt;any&gt;\n }\n)","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">runCommand</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">listCollections</span>: <span class="lg-highlight-number">1</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">filter</span>: &lt;<span class="lg-highlight-variable lg-highlight-language">document</span>&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">nameOnly</span>: &lt;<!-- -->boolean<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">authorizedCollections</span>: &lt;<!-- -->boolean<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">comment</span>: &lt;<!-- -->any<!-- -->&gt;</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->}</td></tr><tr class=""><td class="leafygreen-ui-7razhx">)</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> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Command Fields <a class="headerlink leafygreen-ui-1kepx47" href="#command-fields" 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="command-fields"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> The command can take the following optional fields: </p> <div class="leafygreen-ui-skkc39" tabindex="0"> <table class="leafygreen-ui-hr8lsv"> <colgroup> <col style="width:20%"/> <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> Field </div> </div> </th> <th class="leafygreen-ui-13uteka" role="columnheader" scope="col"> <div class="leafygreen-ui-ui0te9"> <div> Type </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> <code class="leafygreen-ui-1l06pbn"> filter </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> document </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <p class="leafygreen-ui-1kp3ins"> Optional. A query predicate to filter the list of collections. </p> <p class="leafygreen-ui-1kp3ins"> You can specify a query predicate on any of the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-list-collection-output" target="_self"> <span> fields returned </span> </a> by <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-dbcommand-dbcmd.listCollections" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> listCollections </code> . </span> </a> </p> </div> </div> </td> </tr> <tr class=""> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> nameOnly </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> boolean </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <p class="leafygreen-ui-1kp3ins"> Optional. A flag to indicate whether the command should return just the name and type ( <code class="leafygreen-ui-1l06pbn"> view </code> , <code class="leafygreen-ui-1l06pbn"> collection </code> , or <code class="leafygreen-ui-1l06pbn"> timeseries </code> ) or return both the name and other information. </p> <p class="leafygreen-ui-1kp3ins"> The default value is <code class="leafygreen-ui-1l06pbn"> false </code> . </p> <p class="leafygreen-ui-1kp3ins"> When <code class="leafygreen-ui-1l06pbn"> nameOnly </code> is <code class="leafygreen-ui-1l06pbn"> true </code> , your <code class="leafygreen-ui-1l06pbn"> filter </code> expression can only filter based on a collection's name and type. No other fields are available. </p> </div> </div> </td> </tr> <tr class=""> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> authorizedCollections </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> boolean </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <p class="leafygreen-ui-1kp3ins"> Optional. A flag, when set to <code class="leafygreen-ui-1l06pbn"> true </code> and used with <code class="leafygreen-ui-1l06pbn"> nameOnly: true </code> , that allows a user without the required privilege (i.e. <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/privilege-actions/#mongodb-authaction-listCollections"> <code class="leafygreen-ui-1l06pbn"> listCollections </code> </a> action on the database) to run the command when access control is enforced. </p> <p class="leafygreen-ui-1kp3ins"> When both <code class="leafygreen-ui-1l06pbn"> authorizedCollections </code> and <code class="leafygreen-ui-1l06pbn"> nameOnly </code> options are set to true, the command returns only those collections for which the user has privileges. For example, if a user has <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/privilege-actions/#mongodb-authaction-find"> <code class="leafygreen-ui-1l06pbn"> find </code> </a> action on specific collections, the command returns only those collections; or, if a user has <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/privilege-actions/#mongodb-authaction-find"> <code class="leafygreen-ui-1l06pbn"> find </code> </a> or any other action, on the database resource, the command lists all collections in the database. </p> <p class="leafygreen-ui-1kp3ins"> The default value is <code class="leafygreen-ui-1l06pbn"> false </code> . That is, the user must have <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/privilege-actions/#mongodb-authaction-listCollections"> <code class="leafygreen-ui-1l06pbn"> listCollections </code> </a> action on the database to run the command. </p> <p class="leafygreen-ui-1kp3ins"> For a user who has <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/privilege-actions/#mongodb-authaction-listCollections"> <code class="leafygreen-ui-1l06pbn"> listCollections </code> </a> action on the database, this option has no effect since the user has privileges to list the collections in the database. </p> <p class="leafygreen-ui-1kp3ins"> When used without <code class="leafygreen-ui-1l06pbn"> nameOnly: true </code> , this option has no effect. That is, the user must have the required privileges to run the command when access control is enforced. Otherwise, the user is unauthorized to run the command. </p> </div> </div> </td> </tr> <tr class=""> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> comment </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> any </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <p class="leafygreen-ui-1kp3ins"> Optional. A user-provided comment to attach to this command. Once set, this comment appears alongside records of this command in the following locations: </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/log-messages/#std-label-log-messages-ref"> mongod log messages </a> , in the <code class="leafygreen-ui-1l06pbn"> attr.command.cursor.comment </code> field. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/database-profiler/#std-label-profiler"> Database profiler </a> output, in the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/database-profiler/#mongodb-data-system.profile.command"> <code class="leafygreen-ui-1l06pbn"> command.comment </code> </a> field. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/command/currentOp/#mongodb-dbcommand-dbcmd.currentOp"> <code class="leafygreen-ui-1l06pbn"> currentOp </code> </a> output, in the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/command/currentOp/#mongodb-data-currentOp.command"> <code class="leafygreen-ui-1l06pbn"> command.comment </code> </a> field. </p> </li> </ul> <p class="leafygreen-ui-1kp3ins"> A comment can be any valid <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/bson-types/#std-label-bson-types"> BSON type </a> (string, integer, object, array, etc). </p> <p class="leafygreen-ui-1kp3ins"> Any comment set on a <code class="leafygreen-ui-1l06pbn"> listCollections </code> command is inherited by any subsequent <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/command/getMore/#mongodb-dbcommand-dbcmd.getMore"> <code class="leafygreen-ui-1l06pbn"> getMore </code> </a> commands run on the <code class="leafygreen-ui-1l06pbn"> listCollections </code> cursor. </p> </div> </div> </td> </tr> </tbody> </table> </div> <span class="leafygreen-ui-1qnjd6d" id="std-label-listCollections-behavior"> </span> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Behavior <a class="headerlink leafygreen-ui-1kepx47" href="#behavior" 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="behavior"> </div> </a> </h2> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Filter <a class="headerlink leafygreen-ui-1kepx47" href="#filter" 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="filter"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> Use a filter to limit the results of <code class="leafygreen-ui-1l06pbn"> listCollections </code> . You can specify a <code class="leafygreen-ui-1l06pbn"> filter </code> on any of the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-list-collection-output" target="_self"> <span> fields returned </span> </a> in the <code class="leafygreen-ui-1l06pbn"> listCollections </code> result set. </p> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Locks <a class="headerlink leafygreen-ui-1kepx47" href="#locks" 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="locks"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> <code class="leafygreen-ui-1l06pbn"> listCollections </code> lock behavior: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Earlier than MongoDB 5.0, <code class="leafygreen-ui-1l06pbn"> listCollections </code> takes an <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-intent-lock"> intent shared lock </a> lock on each collection in the database when <code class="leafygreen-ui-1l06pbn"> listCollections </code> holds an intent shared lock on the database. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Starting in MongoDB 5.0, <code class="leafygreen-ui-1l06pbn"> listCollections </code> doesn't take an intent shared lock on a collection or database. <code class="leafygreen-ui-1l06pbn"> listCollections </code> isn't blocked by operations holding an exclusive write lock on a collection. </p> </li> </ul> <p class="leafygreen-ui-1kp3ins"> To learn about locks, see <a class="leafygreen-ui-tqgtui" href="/docs/manual/faq/concurrency/#std-label-faq-concurrency"> FAQ: Concurrency <!-- --> . </a> </p> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Client Disconnection <a class="headerlink leafygreen-ui-1kepx47" href="#client-disconnection" 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="client-disconnection"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> Starting in MongoDB 4.2, if the client that issued <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-dbcommand-dbcmd.listCollections" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> listCollections </code> </span> </a> disconnects before the operation completes, MongoDB marks <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-dbcommand-dbcmd.listCollections" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> listCollections </code> </span> </a> for termination using <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/command/killOp/#mongodb-dbcommand-dbcmd.killOp"> <code class="leafygreen-ui-1l06pbn"> killOp </code> . </a> </p> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Replica Set Member State Restriction <a class="headerlink leafygreen-ui-1kepx47" href="#replica-set-member-state-restriction" 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="replica-set-member-state-restriction"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> To run on a replica set member, <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-dbcommand-dbcmd.listCollections" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> listCollections </code> </span> </a> operations require the member to be in <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/replica-states/#mongodb-replstate-replstate.PRIMARY"> <code class="leafygreen-ui-1l06pbn"> PRIMARY </code> </a> or <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/replica-states/#mongodb-replstate-replstate.SECONDARY"> <code class="leafygreen-ui-1l06pbn"> SECONDARY </code> </a> state. If the member is in another state, such as <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/replica-states/#mongodb-replstate-replstate.STARTUP2"> <code class="leafygreen-ui-1l06pbn"> STARTUP2 </code> </a> , the operation errors. </p> </section> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Required Access <a class="headerlink leafygreen-ui-1kepx47" href="#required-access" 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="required-access"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> The <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-dbcommand-dbcmd.listCollections" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> listCollections </code> </span> </a> command requires the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/privilege-actions/#mongodb-authaction-listCollections"> <code class="leafygreen-ui-1l06pbn"> listCollections </code> </a> action when access control is enforced. Users must have privileges that grant the <code class="leafygreen-ui-1l06pbn"> listCollections </code> action on the database to run <code class="leafygreen-ui-1l06pbn"> listCollections </code> . </p> <p class="leafygreen-ui-1kp3ins"> For example, the following command grants the privilege to run <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/db.getCollectionInfos/#mongodb-method-db.getCollectionInfos"> <code class="leafygreen-ui-1l06pbn"> db.getCollectionInfos() </code> </a> against the <code class="leafygreen-ui-1l06pbn"> test </code> database: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ resource: { db: \"test\", collection: \"\" }, actions: [ \"listCollections\" ] }","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-1q4bxgx" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-attr">resource</span>: <!-- -->{ <span class="lg-highlight-attr">db</span>: <span class="lg-highlight-string">"test"</span>, <span class="lg-highlight-attr">collection</span>: <span class="lg-highlight-string">""</span> }<!-- -->, <span class="lg-highlight-attr">actions</span>: <!-- -->[ <span class="lg-highlight-string">"listCollections"</span> ] }</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 built-in role <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/built-in-roles/#mongodb-authrole-read"> <code class="leafygreen-ui-1l06pbn"> read </code> </a> provides the privilege to run <code class="leafygreen-ui-1l06pbn"> listCollections </code> for a specific database. </p> <p class="leafygreen-ui-1kp3ins"> Users without the required <code class="leafygreen-ui-1l06pbn"> read </code> privilege can run <code class="leafygreen-ui-1l06pbn"> listCollections </code> when <code class="leafygreen-ui-1l06pbn"> authorizedCollections </code> and <code class="leafygreen-ui-1l06pbn"> nameOnly </code> are both set to <code class="leafygreen-ui-1l06pbn"> true </code> . In this case, the command returns the names and types for collection(s) where the user has privileges. </p> <p class="leafygreen-ui-1kp3ins"> For example, consider a user with a role that grants the following <code class="leafygreen-ui-1l06pbn"> find </code> privilege: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ resource: { db: \"sales\", collection: \"currentQuarter\" }, actions: [ \"find\" ] }","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-1q4bxgx" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-attr">resource</span>: <!-- -->{ <span class="lg-highlight-attr">db</span>: <span class="lg-highlight-string">"sales"</span>, <span class="lg-highlight-attr">collection</span>: <span class="lg-highlight-string">"currentQuarter"</span> }<!-- -->, <span class="lg-highlight-attr">actions</span>: <!-- -->[ <span class="lg-highlight-string">"find"</span> ] }</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 user can run <code class="leafygreen-ui-1l06pbn"> listCollections </code> if <code class="leafygreen-ui-1l06pbn"> authorizedCollections </code> and <code class="leafygreen-ui-1l06pbn"> nameOnly </code> are both set to <code class="leafygreen-ui-1l06pbn"> true </code> . </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.runCommand(\n {\n listCollections: 1.0,\n authorizedCollections: true,\n nameOnly: true\n }\n)","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">runCommand</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">listCollections</span>: <span class="lg-highlight-number">1.0</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">authorizedCollections</span>: <span class="lg-highlight-literal">true</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">nameOnly</span>: <span class="lg-highlight-literal">true</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">)</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 operation returns the name and type of the <code class="leafygreen-ui-1l06pbn"> currentQuarter </code> collection. </p> <p class="leafygreen-ui-1kp3ins"> However, the following operations return an error if the user does not have the required access authorization: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.runCommand(\n {\n listCollections: 1.0,\n authorizedCollections: true\n }\n)\n\ndb.runCommand(\n {\n listCollections: 1.0,\n nameOnly: true\n }\n)","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">runCommand</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">listCollections</span>: <span class="lg-highlight-number">1.0</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">authorizedCollections</span>: <span class="lg-highlight-literal">true</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">)</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><div class="leafygreen-ui-ihxujy"></div></td></tr><tr class=""><td class="leafygreen-ui-7razhx">db.<span class="lg-highlight-title lg-highlight-function">runCommand</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">listCollections</span>: <span class="lg-highlight-number">1.0</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">nameOnly</span>: <span class="lg-highlight-literal">true</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">)</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> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> <code class="leafygreen-ui-1l06pbn"> show collections </code> <a class="headerlink leafygreen-ui-1kepx47" href="#show-collections" 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="show-collections"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> The <code class="leafygreen-ui-1l06pbn"> mongosh </code> method <code class="leafygreen-ui-1l06pbn"> show collections </code> is similar to: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.runCommand(\n {\n listCollections: 1.0,\n authorizedCollections: true,\n nameOnly: true\n }\n)","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">runCommand</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">listCollections</span>: <span class="lg-highlight-number">1.0</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">authorizedCollections</span>: <span class="lg-highlight-literal">true</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">nameOnly</span>: <span class="lg-highlight-literal">true</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">)</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> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> For users with the required access, <code class="leafygreen-ui-1l06pbn"> show collections </code> lists the non-system collections for the database. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> For users without the required access, <code class="leafygreen-ui-1l06pbn"> show collections </code> lists only the collections for which the users has privileges. </p> </li> </ul> <span class="leafygreen-ui-1qnjd6d" id="std-label-list-collection-output"> </span> </section> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Output <a class="headerlink leafygreen-ui-1kepx47" href="#output" 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="output"> </div> </a> </h2> <dl class="data"> <dt> <code class="leafygreen-ui-1l06pbn"> listCollections.cursor </code> <a class="headerlink leafygreen-ui-1kepx47" href="#mongodb-data-listCollections.cursor" title="Permalink to this definition"> <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="mongodb-data-listCollections.cursor"> </div> </a> </dt> <dd> <p class="leafygreen-ui-1kp3ins"> A document that contains information with which to create a cursor to documents that contain collection names and options. The cursor information includes the cursor id, the full namespace for the command, as well as the first batch of results. Each document in the batch output contains the following fields: </p> <div class="leafygreen-ui-skkc39" tabindex="0"> <table class="leafygreen-ui-hr8lsv"> <colgroup> <col style="width:15%"/> <col style="width:15%"/> <col style="width:30%"/> </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> Field </div> </div> </th> <th class="leafygreen-ui-13uteka" role="columnheader" scope="col"> <div class="leafygreen-ui-ui0te9"> <div> Type </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> name </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> String </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Name of the collection. </div> </div> </td> </tr> <tr class="leafygreen-ui-15dvrnp"> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> type </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> String </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Type of data store. Returns <code class="leafygreen-ui-1l06pbn"> collection </code> for <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/manual/core/databases-and-collections/#collections" target="_self"> <span> collections </span> </a> , <code class="leafygreen-ui-1l06pbn"> view </code> for <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/manual/core/views/" target="_self"> <span> views </span> </a> , and <code class="leafygreen-ui-1l06pbn"> timeseries </code> for <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/timeseries-collections/#std-label-manual-timeseries-collection"> time series collection <!-- --> . </a> </div> </div> </td> </tr> <tr class="leafygreen-ui-15dvrnp"> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> options </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Document </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <p class="leafygreen-ui-1kp3ins"> Collection options. </p> <p class="leafygreen-ui-1kp3ins"> These options correspond directly to the options available in <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/db.createCollection/#mongodb-method-db.createCollection"> <code class="leafygreen-ui-1l06pbn"> db.createCollection() </code> </a> . For the descriptions on the options, see <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/db.createCollection/#mongodb-method-db.createCollection"> <code class="leafygreen-ui-1l06pbn"> db.createCollection() </code> . </a> </p> </div> </div> </td> </tr> <tr class="leafygreen-ui-15dvrnp"> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> info </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Document </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <p class="leafygreen-ui-1kp3ins"> Lists the following fields related to the collection: </p> <dl> <dt> readOnly </dt> <dd class="css-1ufxuu7"> <code class="leafygreen-ui-1l06pbn"> boolean </code> . If <code class="leafygreen-ui-1l06pbn"> true </code> the data store is read only. </dd> <dt> uuid </dt> <dd class="css-1ufxuu7"> <span class="leafygreen-ui-vm4wms" tabindex="0"> UUID </span> . Once established, the collection UUID does not change. The collection UUID remains the same across replica set members and shards in a sharded cluster. </dd> </dl> </div> </div> </td> </tr> <tr class="leafygreen-ui-15dvrnp"> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> idIndex </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Document </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Provides information on the <code class="leafygreen-ui-1l06pbn"> _id </code> index for the collection. </div> </div> </td> </tr> </tbody> </table> </div> </dd> </dl> <dl class="data"> <dt> <code class="leafygreen-ui-1l06pbn"> listCollections.ok </code> <a class="headerlink leafygreen-ui-1kepx47" href="#mongodb-data-listCollections.ok" title="Permalink to this definition"> <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="mongodb-data-listCollections.ok"> </div> </a> </dt> <dd> <p class="leafygreen-ui-1kp3ins"> The return value for the command. A value of <code class="leafygreen-ui-1l06pbn"> 1 </code> indicates success. </p> </dd> </dl> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Example <a class="headerlink leafygreen-ui-1kepx47" href="#example" 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="example"> </div> </a> </h2> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> List All Collections <a class="headerlink leafygreen-ui-1kepx47" href="#list-all-collections" 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="list-all-collections"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> The <code class="leafygreen-ui-1l06pbn"> music </code> database contains three collections, <code class="leafygreen-ui-1l06pbn"> motorhead </code> , <code class="leafygreen-ui-1l06pbn"> taylorSwift </code> , and <code class="leafygreen-ui-1l06pbn"> ramones </code> . </p> <p class="leafygreen-ui-1kp3ins"> To list the collections in the database, you can use the built-in <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/mongodb-shell/#mongodb-binary-bin.mongosh" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongosh </code> </span> </a> command, <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/mongodb-shell/reference/access-mdb-shell-help/#std-label-mdb-shell-help" target="_self"> <span> show collections <!-- --> . </span> </a> </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"show collections","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">show collections</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 output is: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"motorhead\nramones\ntaylorSwift","programmingLanguage":"JavaScript"} </script> <div class="css-1lju8ps"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1jheeh3"> <pre class="leafygreen-ui-1453az5" 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">motorhead</td></tr><tr class=""><td class="leafygreen-ui-7razhx">ramones</td></tr><tr class=""><td class="leafygreen-ui-7razhx">taylorSwift</td></tr></tbody></table></code></pre> </div> </div> </div> <p class="leafygreen-ui-1kp3ins"> To get a similar list with the <code class="leafygreen-ui-1l06pbn"> listCollections </code> collections command, use the <code class="leafygreen-ui-1l06pbn"> nameOnly </code> option. </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.runCommand(\n {\n listCollections: 1.0,\n nameOnly: true\n }\n)","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">runCommand</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">listCollections</span>: <span class="lg-highlight-number">1.0</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">nameOnly</span>: <span class="lg-highlight-literal">true</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">)</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 output is: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{\n cursor: {\n id: Long(\"0\"),\n ns: 'music.$cmd.listCollections',\n firstBatch: [\n { name: 'motorhead', type: 'collection' },\n { name: 'taylorSwift', type: 'collection' },\n { name: 'ramones', type: 'collection' }\n ]\n },\n ok: 1\n}","programmingLanguage":"JavaScript"} </script> <div class="css-1lju8ps"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1jheeh3"> <pre class="leafygreen-ui-1453az5" 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">{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">cursor</span>: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">id</span>: <span class="lg-highlight-title lg-highlight-class">Long</span>(<span class="lg-highlight-string">"0"</span>)<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">ns</span>: <span class="lg-highlight-string">'music.$cmd.listCollections'</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">firstBatch</span>: <!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">name</span>: <span class="lg-highlight-string">'motorhead'</span>, <span class="lg-highlight-attr">type</span>: <span class="lg-highlight-string">'collection'</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">name</span>: <span class="lg-highlight-string">'taylorSwift'</span>, <span class="lg-highlight-attr">type</span>: <span class="lg-highlight-string">'collection'</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">name</span>: <span class="lg-highlight-string">'ramones'</span>, <span class="lg-highlight-attr">type</span>: <span class="lg-highlight-string">'collection'</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> ]</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">ok</span>: <span class="lg-highlight-number">1</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx">}</td></tr></tbody></table></code></pre> </div> </div> </div> <p class="leafygreen-ui-1kp3ins"> To get more detailed information, remove the <code class="leafygreen-ui-1l06pbn"> nameOnly </code> option. </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.runCommand(\n {\n listCollections: 1.0\n }\n)","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">runCommand</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">listCollections</span>: <span class="lg-highlight-number">1.0</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">)</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 output is: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{\n cursor: {\n id: Long(\"0\"),\n ns: 'music.$cmd.listCollections',\n firstBatch: [\n {\n name: 'motorhead',\n type: 'collection',\n options: {},\n info: {\n readOnly: false,\n uuid: new UUID(\"09ef1858-2831-47d2-a3a7-9a29a9cfeb94\")\n },\n idIndex: { v: 2, key: { _id: 1 }, name: '_id_' }\n },\n {\n name: 'taylorSwift',\n type: 'collection',\n options: {},\n info: {\n readOnly: false,\n uuid: new UUID(\"6c46c8b9-4999-4213-bcef-9a36b0cff228\")\n },\n idIndex: { v: 2, key: { _id: 1 }, name: '_id_' }\n },\n {\n name: 'ramones',\n type: 'collection',\n options: {},\n info: {\n readOnly: false,\n uuid: new UUID(\"7e1925ba-f2f9-4e42-90e4-8cafd434a6c4\")\n },\n idIndex: { v: 2, key: { _id: 1 }, name: '_id_' }\n }\n ]\n },\n ok: 1\n}","programmingLanguage":"JavaScript"} </script> <div class="css-1lju8ps"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-tyg50d"> <pre class="leafygreen-ui-1453az5" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">cursor</span>: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">id</span>: <span class="lg-highlight-title lg-highlight-class">Long</span>(<span class="lg-highlight-string">"0"</span>)<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">ns</span>: <span class="lg-highlight-string">'music.$cmd.listCollections'</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">firstBatch</span>: <!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">name</span>: <span class="lg-highlight-string">'motorhead'</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">type</span>: <span class="lg-highlight-string">'collection'</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">options</span>: <!-- -->{<!-- -->}<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">info</span>: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">readOnly</span>: <span class="lg-highlight-literal">false</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">uuid</span>: <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-function">UUID</span>(<span class="lg-highlight-string">"09ef1858-2831-47d2-a3a7-9a29a9cfeb94"</span>)</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">idIndex</span>: <!-- -->{ <span class="lg-highlight-attr">v</span>: <span class="lg-highlight-number">2</span>, <span class="lg-highlight-attr">key</span>: <!-- -->{ <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">1</span> }<!-- -->, <span class="lg-highlight-attr">name</span>: <span class="lg-highlight-string">'_id_'</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">name</span>: <span class="lg-highlight-string">'taylorSwift'</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">type</span>: <span class="lg-highlight-string">'collection'</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">options</span>: <!-- -->{<!-- -->}<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">info</span>: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">readOnly</span>: <span class="lg-highlight-literal">false</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">uuid</span>: <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-function">UUID</span>(<span class="lg-highlight-string">"6c46c8b9-4999-4213-bcef-9a36b0cff228"</span>)</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">idIndex</span>: <!-- -->{ <span class="lg-highlight-attr">v</span>: <span class="lg-highlight-number">2</span>, <span class="lg-highlight-attr">key</span>: <!-- -->{ <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">1</span> }<!-- -->, <span class="lg-highlight-attr">name</span>: <span class="lg-highlight-string">'_id_'</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">name</span>: <span class="lg-highlight-string">'ramones'</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">type</span>: <span class="lg-highlight-string">'collection'</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">options</span>: <!-- -->{<!-- -->}<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">info</span>: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">readOnly</span>: <span class="lg-highlight-literal">false</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">uuid</span>: <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-function">UUID</span>(<span class="lg-highlight-string">"7e1925ba-f2f9-4e42-90e4-8cafd434a6c4"</span>)</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">idIndex</span>: <!-- -->{ <span class="lg-highlight-attr">v</span>: <span class="lg-highlight-number">2</span>, <span class="lg-highlight-attr">key</span>: <!-- -->{ <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">1</span> }<!-- -->, <span class="lg-highlight-attr">name</span>: <span class="lg-highlight-string">'_id_'</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> ]</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">ok</span>: <span class="lg-highlight-number">1</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx">}</td></tr></tbody></table></code></pre> </div> </div> </div> </section> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Learn More <a class="headerlink leafygreen-ui-1kepx47" href="#learn-more" 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="learn-more"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> For collection options: </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/method/db.createCollection/#mongodb-method-db.createCollection"> <code class="leafygreen-ui-1l06pbn"> db.createCollection() </code> </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/command/create/#mongodb-dbcommand-dbcmd.create"> <code class="leafygreen-ui-1l06pbn"> create </code> </a> </p> </li> </ul> <p class="leafygreen-ui-1kp3ins"> For collection information: </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/method/db.getCollectionInfos/#mongodb-method-db.getCollectionInfos"> <code class="leafygreen-ui-1l06pbn"> db.getCollectionInfos() </code> </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/mongodb-shell/reference/access-mdb-shell-help/#std-label-mongosh-help" target="_self"> <span> mongosh built-in commands </span> </a> </p> </li> </ul> </section> </section>
https://www.mongodb.com/docs/manual/reference/command/cleanupReshardCollection/
<section> <h1 class="contains-headerlink leafygreen-ui-41fr9s" weight="medium"> cleanupReshardCollection <a class="headerlink leafygreen-ui-1kepx47" href="#cleanupreshardcollection" 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="cleanupreshardcollection"> </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="#definition" target="_self"> <span> Definition </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#compatibility" target="_self"> <span> Compatibility </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#syntax" target="_self"> <span> Syntax </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#example" target="_self"> <span> Example </span> </a> </li> </ul> </div> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Definition <a class="headerlink leafygreen-ui-1kepx47" href="#definition" 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="definition"> </div> </a> </h2> <dl class="dbcommand"> <dt> <code class="leafygreen-ui-1l06pbn"> cleanupReshardCollection </code> <a class="headerlink leafygreen-ui-1kepx47" href="#mongodb-dbcommand-dbcmd.cleanupReshardCollection" title="Permalink to this definition"> <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="mongodb-dbcommand-dbcmd.cleanupReshardCollection"> </div> </a> </dt> <dd> <div> <p> <em> New <!-- --> in version <!-- --> 5.0 </em> . </p> </div> <p class="leafygreen-ui-1kp3ins"> The <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-dbcommand-dbcmd.cleanupReshardCollection" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> cleanupReshardCollection </code> </span> </a> command cleans up metadata of a failed <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/sharding-reshard-a-collection/#std-label-sharding-resharding"> resharding operation </a> . You only need to run this command if a primary failover occurred while you ran a resharding operation. </p> </dd> </dl> </section> <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"> This command is available in 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> <div class="leafygreen-ui-15mdk4" role="note"> <h2 class="leafygreen-ui-6n7b7d"> Note </h2> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> This command is supported in all MongoDB Atlas clusters. For information on Atlas support for all commands, see <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/atlas/unsupported-commands/" target="_self"> <span> Unsupported Commands <!-- --> . </span> </a> </p> </div> </div> <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"> Syntax <a class="headerlink leafygreen-ui-1kepx47" href="#syntax" 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="syntax"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> The command has the following syntax: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.adminCommand(\n {\n cleanupReshardCollection: \"&lt;database&gt;.&lt;collection&gt;\"\n }\n)","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">adminCommand</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">cleanupReshardCollection</span>: <span class="lg-highlight-string">"&lt;database&gt;.&lt;collection&gt;"</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">)</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> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Example <a class="headerlink leafygreen-ui-1kepx47" href="#example" 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="example"> </div> </a> </h2> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Clean up a Failed Resharding Operation <a class="headerlink leafygreen-ui-1kepx47" href="#clean-up-a-failed-resharding-operation" 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="clean-up-a-failed-resharding-operation"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> The following example cleans up metadata of a failed <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/sharding-reshard-a-collection/#std-label-sharding-resharding"> resharding operation </a> on the <code class="leafygreen-ui-1l06pbn"> sales.orders </code> collection: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.adminCommand({\n cleanupReshardCollection: \"sales.orders\"\n})","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">adminCommand</span>(<!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">cleanupReshardCollection</span>: <span class="lg-highlight-string">"sales.orders"</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx">})</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-13vw3ie" role="note"> <h2 class="leafygreen-ui-1fn4p2b"> Tip </h2> <h3 class="leafygreen-ui-144d5kf"> <strong> See also: </strong> </h3> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/sharding-reshard-a-collection/#std-label-sharding-resharding"> Reshard a Collection </a> </p> </div> </div> </section> </section> </section>
https://www.mongodb.com/docs/manual/reference/command/mergeChunks/
<section> <h1 class="contains-headerlink leafygreen-ui-41fr9s" weight="medium"> mergeChunks <a class="headerlink leafygreen-ui-1kepx47" href="#mergechunks" 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="mergechunks"> </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="#definition" target="_self"> <span> Definition </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#compatibility" target="_self"> <span> Compatibility </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#syntax" target="_self"> <span> Syntax </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#command-fields" target="_self"> <span> Command Fields </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#access-control" target="_self"> <span> Access Control </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#behavior" target="_self"> <span> Behavior </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#return-messages" target="_self"> <span> Return Messages </span> </a> </li> </ul> </div> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Definition <a class="headerlink leafygreen-ui-1kepx47" href="#definition" 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="definition"> </div> </a> </h2> <dl class="dbcommand"> <dt> <code class="leafygreen-ui-1l06pbn"> mergeChunks </code> <a class="headerlink leafygreen-ui-1kepx47" href="#mongodb-dbcommand-dbcmd.mergeChunks" title="Permalink to this definition"> <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="mongodb-dbcommand-dbcmd.mergeChunks"> </div> </a> </dt> <dd> <p class="leafygreen-ui-1kp3ins"> For a sharded collection, <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-dbcommand-dbcmd.mergeChunks" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mergeChunks </code> </span> </a> combines contiguous <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-chunk"> chunk </a> ranges on a shard into a single chunk. Issue the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-dbcommand-dbcmd.mergeChunks" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mergeChunks </code> </span> </a> command on the <code class="leafygreen-ui-1l06pbn"> admin </code> database from a <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongos/#mongodb-binary-bin.mongos"> <code class="leafygreen-ui-1l06pbn"> mongos </code> </a> instance. </p> </dd> </dl> </section> <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"> This command is available in 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> <div class="leafygreen-ui-85da11" role="note"> <h2 class="leafygreen-ui-1ac4g5h"> Important </h2> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> This command is not supported in serverless instances. For more information, see <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/atlas/unsupported-commands/" target="_self"> <span> Unsupported Commands <!-- --> . </span> </a> </p> </div> </div> <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"> Syntax <a class="headerlink leafygreen-ui-1kepx47" href="#syntax" 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="syntax"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> The command has the following syntax: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.adminCommand(\n {\n mergeChunks: &lt;namespace&gt;,\n bounds : [\n { &lt;shardkeyfield&gt;: &lt;minfieldvalue&gt; },\n { &lt;shardkeyfield&gt;: &lt;maxfieldvalue&gt; }\n ]\n }\n)","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">adminCommand</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">mergeChunks</span>: &lt;<!-- -->namespace<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->bounds <!-- -->: <!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ &lt;<!-- -->shardKeyField<!-- -->&gt;<!-- -->: &lt;<!-- -->minFieldValue<!-- -->&gt; <!-- -->}<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ &lt;<!-- -->shardKeyField<!-- -->&gt;<!-- -->: &lt;<!-- -->maxFieldValue<!-- -->&gt; <!-- -->}</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> ]</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">)</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"> For compound shard keys, you must include the full shard key in the <code class="leafygreen-ui-1l06pbn"> bounds </code> specification. For example, if the shard key is <code class="leafygreen-ui-1l06pbn"> { x: 1, y: 1 } </code> , <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-dbcommand-dbcmd.mergeChunks" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mergeChunks </code> </span> </a> has the following form: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.adminCommand(\n {\n mergeChunks: &lt;namespace&gt;,\n bounds: [\n { x: &lt;minvalue&gt;, y: &lt;minvalue&gt; },\n { x: &lt;maxvalue&gt;, y: &lt;maxvalue&gt; }\n ]\n }\n )","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">adminCommand</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">mergeChunks</span>: &lt;<!-- -->namespace<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">bounds</span>: <!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">x</span>: &lt;<!-- -->minValue<!-- -->&gt;<!-- -->,<!-- --> <span class="lg-highlight-attr">y</span>: &lt;<!-- -->minValue<!-- -->&gt; <!-- -->}<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">x</span>: &lt;<!-- -->maxValue<!-- -->&gt;<!-- -->,<!-- --> <span class="lg-highlight-attr">y</span>: &lt;<!-- -->maxValue<!-- -->&gt; <!-- -->}</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> ]</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> )</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> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Command Fields <a class="headerlink leafygreen-ui-1kepx47" href="#command-fields" 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="command-fields"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> The command takes the following fields: </p> <div class="leafygreen-ui-skkc39" tabindex="0"> <table class="leafygreen-ui-hr8lsv"> <colgroup> <col style="width:20%"/> <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> Field </div> </div> </th> <th class="leafygreen-ui-13uteka" role="columnheader" scope="col"> <div class="leafygreen-ui-ui0te9"> <div> Type </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> <code class="leafygreen-ui-1l06pbn"> mergeChunks </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> namespace </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> The fully qualified <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-namespace"> namespace </a> of the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-collection"> collection </a> where both <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-chunk"> chunks </a> exist. Namespaces take form of <code class="leafygreen-ui-1l06pbn"> &lt;database&gt;.&lt;collection&gt; </code> . </div> </div> </td> </tr> <tr class=""> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> bounds </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> array </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> An array that contains the minimum and maximum key values of the new chunk. </div> </div> </td> </tr> </tbody> </table> </div> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Access Control <a class="headerlink leafygreen-ui-1kepx47" href="#access-control" 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="access-control"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> On deployments running with <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/configuration-options/#mongodb-setting-security.authorization"> <code class="leafygreen-ui-1l06pbn"> authorization </code> </a> , the built-in role <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/built-in-roles/#mongodb-authrole-clusterManager"> <code class="leafygreen-ui-1l06pbn"> clusterManager </code> </a> provides the required privileges. </p> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Behavior <a class="headerlink leafygreen-ui-1kepx47" href="#behavior" 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="behavior"> </div> </a> </h2> <div class="leafygreen-ui-15mdk4" role="note"> <h2 class="leafygreen-ui-6n7b7d"> Note </h2> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> Use the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-dbcommand-dbcmd.mergeChunks" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mergeChunks </code> </span> </a> only in special circumstances. For instance, when cleaning up your <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-sharded-cluster"> sharded cluster </a> after removing many documents. </p> </div> </div> <p class="leafygreen-ui-1kp3ins"> In order to successfully merge chunks, the following <em> must </em> be true: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> In the <code class="leafygreen-ui-1l06pbn"> bounds </code> field, <code class="leafygreen-ui-1l06pbn"> &lt;minkey&gt; </code> and <code class="leafygreen-ui-1l06pbn"> &lt;maxkey&gt; </code> must correspond to the lower and upper bounds of the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-chunk"> chunks </a> to merge. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> The chunks must reside on the same shard. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> The chunks must be contiguous. </p> </li> </ul> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-dbcommand-dbcmd.mergeChunks" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mergeChunks </code> </span> </a> returns an error if these conditions are not satisfied. </p> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Return Messages <a class="headerlink leafygreen-ui-1kepx47" href="#return-messages" 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="return-messages"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> On success, <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-dbcommand-dbcmd.mergeChunks" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mergeChunks </code> </span> </a> returns this document: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{\n \"ok\" : 1,\n \"$clusterTime\" : {\n \"clusterTime\" : Timestamp(1510767081, 1),\n \"signature\" : {\n \"hash\" : BinData(0,\"okKHD0QuzcpbVQg7mP2YFw6lM04=\"),\n \"keyId\" : NumberLong(\"6488693018630029321\")\n }\n },\n \"operationTime\" : Timestamp(1510767081, 1)\n}","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"ok"</span> <!-- -->: <span class="lg-highlight-number">1</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"$clusterTime"</span> <!-- -->: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"clusterTime"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">Timestamp</span>(<span class="lg-highlight-number">1510767081</span>, <span class="lg-highlight-number">1</span>)<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"signature"</span> <!-- -->: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"hash"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">BinData</span>(<span class="lg-highlight-number">0</span>,<span class="lg-highlight-string">"okKHD0QuzcpbVQg7mP2YFw6lM04="</span>)<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"keyId"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">NumberLong</span>(<span class="lg-highlight-string">"6488693018630029321"</span>)</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"operationTime"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">Timestamp</span>(<span class="lg-highlight-number">1510767081</span>, <span class="lg-highlight-number">1</span>)</td></tr><tr class=""><td class="leafygreen-ui-7razhx">}</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> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Another Operation in Progress <a class="headerlink leafygreen-ui-1kepx47" href="#another-operation-in-progress" 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="another-operation-in-progress"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-dbcommand-dbcmd.mergeChunks" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mergeChunks </code> </span> </a> returns the following error message if another metadata operation is in progress on the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/config-database/#mongodb-data-config.chunks"> <code class="leafygreen-ui-1l06pbn"> chunks </code> </a> collection: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"errmsg: \"The collection's metadata lock is already taken.\""} </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 none leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">errmsg: "The collection's metadata lock is already taken."</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"> If another process, such as balancer process, changes metadata while <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-dbcommand-dbcmd.mergeChunks" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mergeChunks </code> </span> </a> is running, you may see this error. You can retry the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-dbcommand-dbcmd.mergeChunks" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mergeChunks </code> </span> </a> operation without side effects. </p> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Chunks on Different Shards <a class="headerlink leafygreen-ui-1kepx47" href="#chunks-on-different-shards" 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="chunks-on-different-shards"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> If the input <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-chunk"> chunks </a> are not on the same <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-shard"> shard </a> , <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-dbcommand-dbcmd.mergeChunks" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mergeChunks </code> </span> </a> returns an error similar to the following: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{\n \"ok\" : 0,\n \"errmsg\" : \"could not merge chunks, collection test.users does not contain a chunk ending at { username: \\\"user63169\\\" }\",\n \"$clusterTime\" : {\n \"clusterTime\" : Timestamp(1510767081, 1),\n \"signature\" : {\n \"hash\" : BinData(0,\"okKHD0QuzcpbVQg7mP2YFw6lM04=\"),\n \"keyId\" : NumberLong(\"6488693018630029321\")\n }\n },\n \"operationTime\" : Timestamp(1510767081, 1)\n}","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"ok"</span> <!-- -->: <span class="lg-highlight-number">0</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"errmsg"</span> <!-- -->: <span class="lg-highlight-string">"could not merge chunks, collection test.users does not contain a chunk ending at { username: </span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">user63169</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string"> }"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"$clusterTime"</span> <!-- -->: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"clusterTime"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">Timestamp</span>(<span class="lg-highlight-number">1510767081</span>, <span class="lg-highlight-number">1</span>)<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"signature"</span> <!-- -->: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"hash"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">BinData</span>(<span class="lg-highlight-number">0</span>,<span class="lg-highlight-string">"okKHD0QuzcpbVQg7mP2YFw6lM04="</span>)<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"keyId"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">NumberLong</span>(<span class="lg-highlight-string">"6488693018630029321"</span>)</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"operationTime"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">Timestamp</span>(<span class="lg-highlight-number">1510767081</span>, <span class="lg-highlight-number">1</span>)</td></tr><tr class=""><td class="leafygreen-ui-7razhx">}</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> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Noncontiguous Chunks <a class="headerlink leafygreen-ui-1kepx47" href="#noncontiguous-chunks" 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="noncontiguous-chunks"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> If the input <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-chunk"> chunks </a> are not contiguous, <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-dbcommand-dbcmd.mergeChunks" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mergeChunks </code> </span> </a> returns an error similar to the following: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{\n \"ok\" : 0,\n \"errmsg\" : \"could not merge chunks, collection test.users has more than 2 chunks between [{ username: \\\"user29937\\\" }, { username: \\\"user49877\\\" })\"\n \"$clusterTime\" : {\n \"clusterTime\" : Timestamp(1510767081, 1),\n \"signature\" : {\n \"hash\" : BinData(0,\"okKHD0QuzcpbVQg7mP2YFw6lM04=\"),\n \"keyId\" : NumberLong(\"6488693018630029321\")\n }\n },\n \"operationTime\" : Timestamp(1510767081, 1)\n\n}","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"ok"</span> <!-- -->: <span class="lg-highlight-number">0</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"errmsg"</span> <!-- -->: <span class="lg-highlight-string">"could not merge chunks, collection test.users has more than 2 chunks between [{ username: </span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">user29937</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string"> }, { username: </span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">user49877</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string"> })"</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"$clusterTime"</span> <!-- -->: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"clusterTime"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">Timestamp</span>(<span class="lg-highlight-number">1510767081</span>, <span class="lg-highlight-number">1</span>)<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"signature"</span> <!-- -->: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"hash"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">BinData</span>(<span class="lg-highlight-number">0</span>,<span class="lg-highlight-string">"okKHD0QuzcpbVQg7mP2YFw6lM04="</span>)<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"keyId"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">NumberLong</span>(<span class="lg-highlight-string">"6488693018630029321"</span>)</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"operationTime"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">Timestamp</span>(<span class="lg-highlight-number">1510767081</span>, <span class="lg-highlight-number">1</span>)</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><div class="leafygreen-ui-ihxujy"></div></td></tr><tr class=""><td class="leafygreen-ui-7razhx">}</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> </section> </section> </section>
https://www.mongodb.com/docs/manual/reference/operator/projection/positional/
<section> <h1 class="contains-headerlink leafygreen-ui-41fr9s" weight="medium"> $ (projection) <a class="headerlink leafygreen-ui-1kepx47" href="#---projection-" 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="---projection-"> </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="#definition" target="_self"> <span> Definition </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#usage-considerations" target="_self"> <span> Usage Considerations </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#behavior" target="_self"> <span> Behavior </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#examples" target="_self"> <span> Examples </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#further-reading" target="_self"> <span> Further Reading </span> </a> </li> </ul> </div> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Definition <a class="headerlink leafygreen-ui-1kepx47" href="#definition" 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="definition"> </div> </a> </h2> <dl class="projection"> <dt> <code class="leafygreen-ui-1l06pbn"> $ </code> <a class="headerlink leafygreen-ui-1kepx47" href="#mongodb-projection-proj.-" title="Permalink to this definition"> <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="mongodb-projection-proj.-"> </div> </a> </dt> <dd> <p class="leafygreen-ui-1kp3ins"> The positional <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-projection-proj.-" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $ </code> </span> </a> operator limits the contents of an <code class="leafygreen-ui-1l06pbn"> &lt;array&gt; </code> to return the first element that matches the query condition on the array. </p> <p class="leafygreen-ui-1kp3ins"> Use <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-projection-proj.-" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $ </code> </span> </a> in the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-projection"> projection </a> document of the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/db.collection.find/#mongodb-method-db.collection.find"> <code class="leafygreen-ui-1l06pbn"> find() </code> </a> method or the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/db.collection.findOne/#mongodb-method-db.collection.findOne"> <code class="leafygreen-ui-1l06pbn"> findOne() </code> </a> method when you only need one particular array element in selected documents. </p> <p class="leafygreen-ui-1kp3ins"> See the aggregation operator <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/filter/#mongodb-expression-exp.-filter"> <code class="leafygreen-ui-1l06pbn"> $filter </code> </a> to return an array with only those elements that match the specified condition. </p> <div class="leafygreen-ui-15mdk4" role="note"> <h2 class="leafygreen-ui-6n7b7d"> Note </h2> <h3 class="leafygreen-ui-144d5kf"> <strong> Disambiguation </strong> </h3> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> To specify an array element to update, see the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/update/positional/"> positional $ operator for updates <!-- --> . </a> </p> </div> </div> </dd> </dl> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Usage Considerations <a class="headerlink leafygreen-ui-1kepx47" href="#usage-considerations" 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="usage-considerations"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> Both the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-projection-proj.-" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $ </code> </span> </a> operator and the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/projection/elemMatch/#mongodb-projection-proj.-elemMatch"> <code class="leafygreen-ui-1l06pbn"> $elemMatch </code> </a> operator project the <strong> first </strong> matching element from an array based on a condition. </p> <p class="leafygreen-ui-1kp3ins"> The <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-projection-proj.-" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $ </code> </span> </a> operator projects the first matching array element from each document in a collection based on some condition from the query statement. </p> <p class="leafygreen-ui-1kp3ins"> The <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/projection/elemMatch/#mongodb-projection-proj.-elemMatch"> <code class="leafygreen-ui-1l06pbn"> $elemMatch </code> </a> projection operator takes an explicit condition argument. This allows you to project based on a condition not in the query, or if you need to project based on multiple fields in the array's embedded documents. See <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-array-field-limitation" target="_self"> <span> Array Field Limitations </span> </a> for an example. </p> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/db.collection.find/#mongodb-method-db.collection.find"> <code class="leafygreen-ui-1l06pbn"> db.collection.find() </code> </a> operations on <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/views/#std-label-views-landing-page"> views </a> do not support <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-projection-proj.-" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $ </code> </span> </a> projection operator. </p> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Behavior <a class="headerlink leafygreen-ui-1kepx47" href="#behavior" 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="behavior"> </div> </a> </h2> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Syntax <a class="headerlink leafygreen-ui-1kepx47" href="#syntax" 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="syntax"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> To return the first array element that matches the specified query condition on the array: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.collection.find( { &lt;array&gt;: &lt;condition&gt; ... },\n { \"&lt;array&gt;.$\": 1 } )\ndb.collection.find( { &lt;array.field&gt;: &lt;condition&gt; ...},\n { \"&lt;array&gt;.$\": 1 } )","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">find</span>( <!-- -->{ &lt;<!-- -->array<!-- -->&gt;<!-- -->: &lt;<!-- -->condition<!-- -->&gt; <!-- -->...<!-- --> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"&lt;array&gt;.$"</span>: <span class="lg-highlight-number">1</span> } )</td></tr><tr class=""><td class="leafygreen-ui-7razhx">db.<span class="lg-highlight-property">collection</span>.<span class="lg-highlight-title lg-highlight-function">find</span>( <!-- -->{ &lt;<!-- -->array.<span class="lg-highlight-property">field</span>&gt;<!-- -->: &lt;<!-- -->condition<!-- -->&gt; <!-- -->...<!-- -->}<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"&lt;array&gt;.$"</span>: <span class="lg-highlight-number">1</span> } )</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"> You can use the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-projection-proj.-" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $ </code> </span> </a> operator to limit an <code class="leafygreen-ui-1l06pbn"> &lt;array&gt; </code> field, which does not appear in the <a class="leafygreen-ui-tqgtui" href="/docs/manual/tutorial/query-documents/#std-label-read-operations-query-argument"> query document </a> . In previous versions of MongoDB, the <code class="leafygreen-ui-1l06pbn"> &lt;array&gt; </code> field being limited <strong> must </strong> appear in the query document. </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.collection.find( { &lt;someotherarray&gt;: &lt;condition&gt; ... },\n { \"&lt;array&gt;.$\" : 1 } )","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">find</span>( <!-- -->{ &lt;<!-- -->someOtherArray<!-- -->&gt;<!-- -->: &lt;<!-- -->condition<!-- -->&gt; <!-- -->...<!-- --> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"&lt;array&gt;.$"</span> <!-- -->: <span class="lg-highlight-number">1</span> } )</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-85da11" role="note"> <h2 class="leafygreen-ui-1ac4g5h"> Important </h2> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> To ensure expected behavior, the arrays used in the query document and the projection document must be the same length. If the arrays are different lengths, the operation may error in certain scenarios. </p> </div> </div> <span class="leafygreen-ui-1qnjd6d" id="std-label-array-field-limitation"> </span> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Array Field Limitations <a class="headerlink leafygreen-ui-1kepx47" href="#array-field-limitations" 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="array-field-limitations"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> MongoDB requires the following when dealing with projection over arrays: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Only one positional <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-projection-proj.-" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $ </code> </span> </a> operator may appear in the projection document. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Only one array field should appear in the <a class="leafygreen-ui-tqgtui" href="/docs/manual/tutorial/query-documents/#std-label-read-operations-query-argument"> query document </a> . Additional array fields in the query document may lead to undefined behavior. </p> <p class="leafygreen-ui-1kp3ins"> For example, the following projection may lead to undefined behavior: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.collection.find( { &lt;array&gt;: &lt;value&gt;, &lt;someotherarray&gt;: &lt;value2&gt; },\n { \"&lt;array&gt;.$\": 1 } )","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><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">find</span>( <!-- -->{ &lt;<!-- -->array<!-- -->&gt;<!-- -->: &lt;<!-- -->value<!-- -->&gt;<!-- -->,<!-- --> <!-- -->&lt;<!-- -->someOtherArray<!-- -->&gt;<!-- -->: &lt;<!-- -->value2<!-- -->&gt; <!-- -->}<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"&lt;array&gt;.$"</span>: <span class="lg-highlight-number">1</span> } )</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> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> The <a class="leafygreen-ui-tqgtui" href="/docs/manual/tutorial/query-documents/#std-label-read-operations-query-argument"> query document </a> should only contain a single condition on the array field to which it is applied. Multiple conditions may override each other internally and lead to undefined behavior. </p> <p class="leafygreen-ui-1kp3ins"> To specify criteria on multiple fields of documents inside that array, use the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/query/elemMatch/#mongodb-query-op.-elemMatch"> <code class="leafygreen-ui-1l06pbn"> $elemMatch </code> </a> query operator. The following query returns the first document inside a <code class="leafygreen-ui-1l06pbn"> grades </code> array that has a <code class="leafygreen-ui-1l06pbn"> mean </code> of greater than 70 and a <code class="leafygreen-ui-1l06pbn"> grade </code> of greater than 90. </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.students.find( { grades: { $elemMatch: {\n mean: { $gt: 70 },\n grade: { $gt:90 }\n } } },\n { \"grades.$\": 1 } )","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><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">students</span>.<span class="lg-highlight-title lg-highlight-function">find</span>( <!-- -->{ <span class="lg-highlight-attr">grades</span>: <!-- -->{ <span class="lg-highlight-attr">$elemMatch</span>: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">mean</span>: <!-- -->{ <span class="lg-highlight-attr">$gt</span>: <span class="lg-highlight-number">70</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">grade</span>: <!-- -->{ <span class="lg-highlight-attr">$gt</span>:<span class="lg-highlight-number">90</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> } } }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"grades.$"</span>: <span class="lg-highlight-number">1</span> } )</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"> You must use the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/projection/elemMatch/#mongodb-projection-proj.-elemMatch"> <code class="leafygreen-ui-1l06pbn"> $elemMatch </code> </a> operator if you need separate conditions for selecting documents and for choosing fields within those documents. </p> </li> </ul> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Sorts and the Positional Operator <a class="headerlink leafygreen-ui-1kepx47" href="#sorts-and-the-positional-operator" 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="sorts-and-the-positional-operator"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> When the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/db.collection.find/#mongodb-method-db.collection.find"> <code class="leafygreen-ui-1l06pbn"> find() </code> </a> method includes a <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/cursor.sort/#mongodb-method-cursor.sort"> <code class="leafygreen-ui-1l06pbn"> sort() </code> </a> , the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/db.collection.find/#mongodb-method-db.collection.find"> <code class="leafygreen-ui-1l06pbn"> find() </code> </a> method applies the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/cursor.sort/#mongodb-method-cursor.sort"> <code class="leafygreen-ui-1l06pbn"> sort() </code> </a> to order the matching documents <strong> before </strong> it applies the positional <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-projection-proj.-" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $ </code> </span> </a> projection operator. </p> <p class="leafygreen-ui-1kp3ins"> If an array field contains multiple documents with the same field name and the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/db.collection.find/#mongodb-method-db.collection.find"> <code class="leafygreen-ui-1l06pbn"> find() </code> </a> method includes a <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/cursor.sort/#mongodb-method-cursor.sort"> <code class="leafygreen-ui-1l06pbn"> sort() </code> </a> on that repeating field, the returned documents may not reflect the sort order because the sort was applied to the elements of the array before the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-projection-proj.-" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $ </code> </span> </a> projection operator. </p> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Positional Operator Placement Restriction <a class="headerlink leafygreen-ui-1kepx47" href="#positional-operator-placement-restriction" 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="positional-operator-placement-restriction"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> The <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-projection-proj.-" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $ </code> </span> </a> projection operator can only appear at the end of the field path, for example <code class="leafygreen-ui-1l06pbn"> "field.$" </code> or <code class="leafygreen-ui-1l06pbn"> "fieldA.fieldB.$" </code> . </p> <p class="leafygreen-ui-1kp3ins"> For example, the following operation is invalid: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.inventory.find( { }, { \"instock.$.qty\": 1 } )","programmingLanguage":"JavaScript"} </script> <div class="css-1lju8ps"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1jheeh3"> <pre class="leafygreen-ui-1agdxuk" 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">inventory</span>.<span class="lg-highlight-title lg-highlight-function">find</span>( <!-- -->{ <!-- -->}<!-- -->, <!-- -->{ <span class="lg-highlight-string">"instock.$.qty"</span>: <span class="lg-highlight-number">1</span> } )</td></tr></tbody></table></code></pre> </div> </div> </div> <p class="leafygreen-ui-1kp3ins"> To resolve, remove the component of the field path that follows the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-projection-proj.-" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $ </code> </span> </a> projection operator. </p> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Positional Operator and <code class="leafygreen-ui-1l06pbn"> $slice </code> Restriction <a class="headerlink leafygreen-ui-1kepx47" href="#positional-operator-and--slice-restriction" 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="positional-operator-and--slice-restriction"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/db.collection.find/#mongodb-method-db.collection.find"> <code class="leafygreen-ui-1l06pbn"> find </code> </a> and <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/db.collection.findAndModify/#mongodb-method-db.collection.findAndModify"> <code class="leafygreen-ui-1l06pbn"> findAndModify </code> </a> projection cannot include <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/projection/slice/#mongodb-projection-proj.-slice"> <code class="leafygreen-ui-1l06pbn"> $slice </code> </a> projection expression as part of a <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-projection-proj.-" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $ </code> </span> </a> projection expression. </p> <p class="leafygreen-ui-1kp3ins"> For example, the following operation is invalid: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.inventory.find( { \"instock.qty\": { $gt: 25 } }, { \"instock.$\": { $slice: 1 } } )","programmingLanguage":"JavaScript"} </script> <div class="css-1lju8ps"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-tyg50d"> <pre class="leafygreen-ui-1agdxuk" tabindex="0"><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">inventory</span>.<span class="lg-highlight-title lg-highlight-function">find</span>( <!-- -->{ <span class="lg-highlight-string">"instock.qty"</span>: <!-- -->{ <span class="lg-highlight-attr">$gt</span>: <span class="lg-highlight-number">25</span> } }<!-- -->, <!-- -->{ <span class="lg-highlight-string">"instock.$"</span>: <!-- -->{ <span class="lg-highlight-attr">$slice</span>: <span class="lg-highlight-number">1</span> } } )</td></tr></tbody></table></code></pre> </div> </div> </div> <p class="leafygreen-ui-1kp3ins"> In previous versions, MongoDB returns the first element ( <code class="leafygreen-ui-1l06pbn"> instock.$ </code> ) in the <code class="leafygreen-ui-1l06pbn"> instock </code> array that matches the query condition; i.e. the positional projection <code class="leafygreen-ui-1l06pbn"> "instock.$" </code> takes precedence and the <code class="leafygreen-ui-1l06pbn"> $slice:1 </code> is a no-op. The <code class="leafygreen-ui-1l06pbn"> "instock.$": { $slice: 1 } </code> does not exclude any other document field. </p> </section> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Examples <a class="headerlink leafygreen-ui-1kepx47" href="#examples" 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="examples"> </div> </a> </h2> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Project Array Values <a class="headerlink leafygreen-ui-1kepx47" href="#project-array-values" 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="project-array-values"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> A collection <code class="leafygreen-ui-1l06pbn"> students </code> contains the following documents: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ \"_id\" : 1, \"semester\" : 1, \"grades\" : [ 70, 87, 90 ] }\n{ \"_id\" : 2, \"semester\" : 1, \"grades\" : [ 90, 88, 92 ] }\n{ \"_id\" : 3, \"semester\" : 1, \"grades\" : [ 85, 100, 90 ] }\n{ \"_id\" : 4, \"semester\" : 2, \"grades\" : [ 79, 85, 80 ] }\n{ \"_id\" : 5, \"semester\" : 2, \"grades\" : [ 88, 88, 92 ] }\n{ \"_id\" : 6, \"semester\" : 2, \"grades\" : [ 95, 90, 96 ] }","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">1</span>, <span class="lg-highlight-string">"semester"</span> <!-- -->: <span class="lg-highlight-number">1</span>, <span class="lg-highlight-string">"grades"</span> <!-- -->: <!-- -->[ <span class="lg-highlight-number">70</span>, <span class="lg-highlight-number">87</span>, <span class="lg-highlight-number">90</span> ] }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">2</span>, <span class="lg-highlight-string">"semester"</span> <!-- -->: <span class="lg-highlight-number">1</span>, <span class="lg-highlight-string">"grades"</span> <!-- -->: <!-- -->[ <span class="lg-highlight-number">90</span>, <span class="lg-highlight-number">88</span>, <span class="lg-highlight-number">92</span> ] }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">3</span>, <span class="lg-highlight-string">"semester"</span> <!-- -->: <span class="lg-highlight-number">1</span>, <span class="lg-highlight-string">"grades"</span> <!-- -->: <!-- -->[ <span class="lg-highlight-number">85</span>, <span class="lg-highlight-number">100</span>, <span class="lg-highlight-number">90</span> ] }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">4</span>, <span class="lg-highlight-string">"semester"</span> <!-- -->: <span class="lg-highlight-number">2</span>, <span class="lg-highlight-string">"grades"</span> <!-- -->: <!-- -->[ <span class="lg-highlight-number">79</span>, <span class="lg-highlight-number">85</span>, <span class="lg-highlight-number">80</span> ] }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">5</span>, <span class="lg-highlight-string">"semester"</span> <!-- -->: <span class="lg-highlight-number">2</span>, <span class="lg-highlight-string">"grades"</span> <!-- -->: <!-- -->[ <span class="lg-highlight-number">88</span>, <span class="lg-highlight-number">88</span>, <span class="lg-highlight-number">92</span> ] }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">6</span>, <span class="lg-highlight-string">"semester"</span> <!-- -->: <span class="lg-highlight-number">2</span>, <span class="lg-highlight-string">"grades"</span> <!-- -->: <!-- -->[ <span class="lg-highlight-number">95</span>, <span class="lg-highlight-number">90</span>, <span class="lg-highlight-number">96</span> ] }</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"> In the following query, the projection <code class="leafygreen-ui-1l06pbn"> { "grades.$": 1 } </code> returns only the first element greater than or equal to <code class="leafygreen-ui-1l06pbn"> 85 </code> for the <code class="leafygreen-ui-1l06pbn"> grades </code> field. </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.students.find( { semester: 1, grades: { $gte: 85 } },\n { \"grades.$\": 1 } )","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">students</span>.<span class="lg-highlight-title lg-highlight-function">find</span>( <!-- -->{ <span class="lg-highlight-attr">semester</span>: <span class="lg-highlight-number">1</span>, <span class="lg-highlight-attr">grades</span>: <!-- -->{ <span class="lg-highlight-attr">$gte</span>: <span class="lg-highlight-number">85</span> } }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"grades.$"</span>: <span class="lg-highlight-number">1</span> } )</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 operation returns the following documents: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ \"_id\" : 1, \"grades\" : [ 87 ] }\n{ \"_id\" : 2, \"grades\" : [ 90 ] }\n{ \"_id\" : 3, \"grades\" : [ 85 ] }","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">1</span>, <span class="lg-highlight-string">"grades"</span> <!-- -->: <!-- -->[ <span class="lg-highlight-number">87</span> ] }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">2</span>, <span class="lg-highlight-string">"grades"</span> <!-- -->: <!-- -->[ <span class="lg-highlight-number">90</span> ] }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">3</span>, <span class="lg-highlight-string">"grades"</span> <!-- -->: <!-- -->[ <span class="lg-highlight-number">85</span> ] }</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"> Although the array field <code class="leafygreen-ui-1l06pbn"> grades </code> may contain multiple elements that are greater than or equal to <code class="leafygreen-ui-1l06pbn"> 85 </code> , the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-projection-proj.-" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $ </code> </span> </a> projection operator returns only the first matching element from the array. </p> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Project Array Documents <a class="headerlink leafygreen-ui-1kepx47" href="#project-array-documents" 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="project-array-documents"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> A <code class="leafygreen-ui-1l06pbn"> students </code> collection contains the following documents where the <code class="leafygreen-ui-1l06pbn"> grades </code> field is an array of documents; each document contain the three field names <code class="leafygreen-ui-1l06pbn"> grade </code> , <code class="leafygreen-ui-1l06pbn"> mean </code> , and <code class="leafygreen-ui-1l06pbn"> std </code> : </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ \"_id\" : 7, semester: 3, \"grades\" : [ { grade: 80, mean: 75, std: 8 },\n { grade: 85, mean: 90, std: 5 },\n { grade: 90, mean: 85, std: 3 } ] }\n\n{ \"_id\" : 8, semester: 3, \"grades\" : [ { grade: 92, mean: 88, std: 8 },\n { grade: 78, mean: 90, std: 5 },\n { grade: 88, mean: 85, std: 3 } ] }","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">7</span>, <span class="lg-highlight-attr">semester</span>: <span class="lg-highlight-number">3</span>, <span class="lg-highlight-string">"grades"</span> <!-- -->: <!-- -->[ <!-- -->{ <span class="lg-highlight-attr">grade</span>: <span class="lg-highlight-number">80</span>, <span class="lg-highlight-attr">mean</span>: <span class="lg-highlight-number">75</span>, <span class="lg-highlight-attr">std</span>: <span class="lg-highlight-number">8</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">grade</span>: <span class="lg-highlight-number">85</span>, <span class="lg-highlight-attr">mean</span>: <span class="lg-highlight-number">90</span>, <span class="lg-highlight-attr">std</span>: <span class="lg-highlight-number">5</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">grade</span>: <span class="lg-highlight-number">90</span>, <span class="lg-highlight-attr">mean</span>: <span class="lg-highlight-number">85</span>, <span class="lg-highlight-attr">std</span>: <span class="lg-highlight-number">3</span> } ] }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><div class="leafygreen-ui-ihxujy"></div></td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">8</span>, <span class="lg-highlight-attr">semester</span>: <span class="lg-highlight-number">3</span>, <span class="lg-highlight-string">"grades"</span> <!-- -->: <!-- -->[ <!-- -->{ <span class="lg-highlight-attr">grade</span>: <span class="lg-highlight-number">92</span>, <span class="lg-highlight-attr">mean</span>: <span class="lg-highlight-number">88</span>, <span class="lg-highlight-attr">std</span>: <span class="lg-highlight-number">8</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">grade</span>: <span class="lg-highlight-number">78</span>, <span class="lg-highlight-attr">mean</span>: <span class="lg-highlight-number">90</span>, <span class="lg-highlight-attr">std</span>: <span class="lg-highlight-number">5</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">grade</span>: <span class="lg-highlight-number">88</span>, <span class="lg-highlight-attr">mean</span>: <span class="lg-highlight-number">85</span>, <span class="lg-highlight-attr">std</span>: <span class="lg-highlight-number">3</span> } ] }</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"> In the following query, the projection <code class="leafygreen-ui-1l06pbn"> { "grades.$": 1 } </code> returns only the first element with the <code class="leafygreen-ui-1l06pbn"> mean </code> greater than <code class="leafygreen-ui-1l06pbn"> 70 </code> for the <code class="leafygreen-ui-1l06pbn"> grades </code> field: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.students.find(\n { \"grades.mean\": { $gt: 70 } },\n { \"grades.$\": 1 }\n)","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">students</span>.<span class="lg-highlight-title lg-highlight-function">find</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"grades.mean"</span>: <!-- -->{ <span class="lg-highlight-attr">$gt</span>: <span class="lg-highlight-number">70</span> } }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"grades.$"</span>: <span class="lg-highlight-number">1</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">)</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 operation returns the following documents: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ \"_id\" : 7, \"grades\" : [ { \"grade\" : 80, \"mean\" : 75, \"std\" : 8 } ] }\n{ \"_id\" : 8, \"grades\" : [ { \"grade\" : 92, \"mean\" : 88, \"std\" : 8 } ] }","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">7</span>, <span class="lg-highlight-string">"grades"</span> <!-- -->: <!-- -->[ <!-- -->{ <span class="lg-highlight-string">"grade"</span> <!-- -->: <span class="lg-highlight-number">80</span>, <span class="lg-highlight-string">"mean"</span> <!-- -->: <span class="lg-highlight-number">75</span>, <span class="lg-highlight-string">"std"</span> <!-- -->: <span class="lg-highlight-number">8</span> } ] }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">8</span>, <span class="lg-highlight-string">"grades"</span> <!-- -->: <!-- -->[ <!-- -->{ <span class="lg-highlight-string">"grade"</span> <!-- -->: <span class="lg-highlight-number">92</span>, <span class="lg-highlight-string">"mean"</span> <!-- -->: <span class="lg-highlight-number">88</span>, <span class="lg-highlight-string">"std"</span> <!-- -->: <span class="lg-highlight-number">8</span> } ] }</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> </section> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Further Reading <a class="headerlink leafygreen-ui-1kepx47" href="#further-reading" 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="further-reading"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/projection/elemMatch/#mongodb-projection-proj.-elemMatch"> <code class="leafygreen-ui-1l06pbn"> $elemMatch (projection) </code> </a> </p> </section> </section>
https://www.mongodb.com/docs/manual/tutorial/map-reduce-examples/
<section> <h1 class="contains-headerlink leafygreen-ui-41fr9s" weight="medium"> Map-Reduce Examples <a class="headerlink leafygreen-ui-1kepx47" href="#map-reduce-examples" 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="map-reduce-examples"> </div> </a> </h1> <div class="leafygreen-ui-15mdk4" role="note"> <h2 class="leafygreen-ui-6n7b7d"> Note </h2> <h3 class="leafygreen-ui-144d5kf"> <strong> Aggregation Pipeline as Alternative to Map-Reduce </strong> </h3> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> An <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/aggregation-pipeline/#std-label-aggregation-pipeline"> aggregation pipeline </a> provides better performance and usability than a <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/map-reduce/"> map-reduce </a> operation. </p> <p class="leafygreen-ui-1kp3ins"> Map-reduce operations can be rewritten using <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation-pipeline/#std-label-aggregation-pipeline-operator-reference"> aggregation pipeline stages </a> such as <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/group/#mongodb-pipeline-pipe.-group"> <code class="leafygreen-ui-1l06pbn"> $group </code> </a> and <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/merge/#mongodb-pipeline-pipe.-merge"> <code class="leafygreen-ui-1l06pbn"> $merge </code> . </a> </p> <p class="leafygreen-ui-1kp3ins"> For map-reduce operations that require custom functionality, MongoDB provides the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/accumulator/#mongodb-group-grp.-accumulator"> <code class="leafygreen-ui-1l06pbn"> $accumulator </code> </a> and <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/function/#mongodb-expression-exp.-function"> <code class="leafygreen-ui-1l06pbn"> $function </code> </a> aggregation operators. Use these operators to define custom aggregation expressions in JavaScript. </p> </div> </div> <p class="leafygreen-ui-1kp3ins"> In <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/mongodb-shell/#mongodb-binary-bin.mongosh" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongosh </code> </span> </a> , the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/db.collection.mapReduce/#mongodb-method-db.collection.mapReduce"> <code class="leafygreen-ui-1l06pbn"> db.collection.mapReduce() </code> </a> method is a wrapper around the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/command/mapReduce/#mongodb-dbcommand-dbcmd.mapReduce"> <code class="leafygreen-ui-1l06pbn"> mapReduce </code> </a> command. The following examples use the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/db.collection.mapReduce/#mongodb-method-db.collection.mapReduce"> <code class="leafygreen-ui-1l06pbn"> db.collection.mapReduce() </code> </a> method. </p> <section> <p class="leafygreen-ui-1kp3ins"> The examples in this section include aggregation pipeline alternatives without custom aggregation expressions. For alternatives that use custom expressions, see <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/map-reduce-to-aggregation-pipeline/#std-label-mr-to-agg-examples"> Map-Reduce to Aggregation Pipeline Translation Examples <!-- --> . </a> </p> <p class="leafygreen-ui-1kp3ins"> Create a sample collection <code class="leafygreen-ui-1l06pbn"> orders </code> with these documents: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.orders.insertMany([\n { _id: 1, cust_id: \"Ant O. Knee\", ord_date: new Date(\"2020-03-01\"), price: 25, items: [ { sku: \"oranges\", qty: 5, price: 2.5 }, { sku: \"apples\", qty: 5, price: 2.5 } ], status: \"A\" },\n { _id: 2, cust_id: \"Ant O. Knee\", ord_date: new Date(\"2020-03-08\"), price: 70, items: [ { sku: \"oranges\", qty: 8, price: 2.5 }, { sku: \"chocolates\", qty: 5, price: 10 } ], status: \"A\" },\n { _id: 3, cust_id: \"Busby Bee\", ord_date: new Date(\"2020-03-08\"), price: 50, items: [ { sku: \"oranges\", qty: 10, price: 2.5 }, { sku: \"pears\", qty: 10, price: 2.5 } ], status: \"A\" },\n { _id: 4, cust_id: \"Busby Bee\", ord_date: new Date(\"2020-03-18\"), price: 25, items: [ { sku: \"oranges\", qty: 10, price: 2.5 } ], status: \"A\" },\n { _id: 5, cust_id: \"Busby Bee\", ord_date: new Date(\"2020-03-19\"), price: 50, items: [ { sku: \"chocolates\", qty: 5, price: 10 } ], status: \"A\"},\n { _id: 6, cust_id: \"Cam Elot\", ord_date: new Date(\"2020-03-19\"), price: 35, items: [ { sku: \"carrots\", qty: 10, price: 1.0 }, { sku: \"apples\", qty: 10, price: 2.5 } ], status: \"A\" },\n { _id: 7, cust_id: \"Cam Elot\", ord_date: new Date(\"2020-03-20\"), price: 25, items: [ { sku: \"oranges\", qty: 10, price: 2.5 } ], status: \"A\" },\n { _id: 8, cust_id: \"Don Quis\", ord_date: new Date(\"2020-03-20\"), price: 75, items: [ { sku: \"chocolates\", qty: 5, price: 10 }, { sku: \"apples\", qty: 10, price: 2.5 } ], status: \"A\" },\n { _id: 9, cust_id: \"Don Quis\", ord_date: new Date(\"2020-03-20\"), price: 55, items: [ { sku: \"carrots\", qty: 5, price: 1.0 }, { sku: \"apples\", qty: 10, price: 2.5 }, { sku: \"oranges\", qty: 10, price: 2.5 } ], status: \"A\" },\n { _id: 10, cust_id: \"Don Quis\", ord_date: new Date(\"2020-03-23\"), price: 25, items: [ { sku: \"oranges\", qty: 10, price: 2.5 } ], status: \"A\" }\n])","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><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">orders</span>.<span class="lg-highlight-title lg-highlight-function">insertMany</span>(<!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">1</span>, <span class="lg-highlight-attr">cust_id</span>: <span class="lg-highlight-string">"Ant O. Knee"</span>, <span class="lg-highlight-attr">ord_date</span>: <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">Date</span>(<span class="lg-highlight-string">"2020-03-01"</span>)<!-- -->, <span class="lg-highlight-attr">price</span>: <span class="lg-highlight-number">25</span>, <span class="lg-highlight-attr">items</span>: <!-- -->[ <!-- -->{ <span class="lg-highlight-attr">sku</span>: <span class="lg-highlight-string">"oranges"</span>, <span class="lg-highlight-attr">qty</span>: <span class="lg-highlight-number">5</span>, <span class="lg-highlight-attr">price</span>: <span class="lg-highlight-number">2.5</span> }<!-- -->, <!-- -->{ <span class="lg-highlight-attr">sku</span>: <span class="lg-highlight-string">"apples"</span>, <span class="lg-highlight-attr">qty</span>: <span class="lg-highlight-number">5</span>, <span class="lg-highlight-attr">price</span>: <span class="lg-highlight-number">2.5</span> } ]<!-- -->, <span class="lg-highlight-attr">status</span>: <span class="lg-highlight-string">"A"</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">2</span>, <span class="lg-highlight-attr">cust_id</span>: <span class="lg-highlight-string">"Ant O. Knee"</span>, <span class="lg-highlight-attr">ord_date</span>: <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">Date</span>(<span class="lg-highlight-string">"2020-03-08"</span>)<!-- -->, <span class="lg-highlight-attr">price</span>: <span class="lg-highlight-number">70</span>, <span class="lg-highlight-attr">items</span>: <!-- -->[ <!-- -->{ <span class="lg-highlight-attr">sku</span>: <span class="lg-highlight-string">"oranges"</span>, <span class="lg-highlight-attr">qty</span>: <span class="lg-highlight-number">8</span>, <span class="lg-highlight-attr">price</span>: <span class="lg-highlight-number">2.5</span> }<!-- -->, <!-- -->{ <span class="lg-highlight-attr">sku</span>: <span class="lg-highlight-string">"chocolates"</span>, <span class="lg-highlight-attr">qty</span>: <span class="lg-highlight-number">5</span>, <span class="lg-highlight-attr">price</span>: <span class="lg-highlight-number">10</span> } ]<!-- -->, <span class="lg-highlight-attr">status</span>: <span class="lg-highlight-string">"A"</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">3</span>, <span class="lg-highlight-attr">cust_id</span>: <span class="lg-highlight-string">"Busby Bee"</span>, <span class="lg-highlight-attr">ord_date</span>: <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">Date</span>(<span class="lg-highlight-string">"2020-03-08"</span>)<!-- -->, <span class="lg-highlight-attr">price</span>: <span class="lg-highlight-number">50</span>, <span class="lg-highlight-attr">items</span>: <!-- -->[ <!-- -->{ <span class="lg-highlight-attr">sku</span>: <span class="lg-highlight-string">"oranges"</span>, <span class="lg-highlight-attr">qty</span>: <span class="lg-highlight-number">10</span>, <span class="lg-highlight-attr">price</span>: <span class="lg-highlight-number">2.5</span> }<!-- -->, <!-- -->{ <span class="lg-highlight-attr">sku</span>: <span class="lg-highlight-string">"pears"</span>, <span class="lg-highlight-attr">qty</span>: <span class="lg-highlight-number">10</span>, <span class="lg-highlight-attr">price</span>: <span class="lg-highlight-number">2.5</span> } ]<!-- -->, <span class="lg-highlight-attr">status</span>: <span class="lg-highlight-string">"A"</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">4</span>, <span class="lg-highlight-attr">cust_id</span>: <span class="lg-highlight-string">"Busby Bee"</span>, <span class="lg-highlight-attr">ord_date</span>: <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">Date</span>(<span class="lg-highlight-string">"2020-03-18"</span>)<!-- -->, <span class="lg-highlight-attr">price</span>: <span class="lg-highlight-number">25</span>, <span class="lg-highlight-attr">items</span>: <!-- -->[ <!-- -->{ <span class="lg-highlight-attr">sku</span>: <span class="lg-highlight-string">"oranges"</span>, <span class="lg-highlight-attr">qty</span>: <span class="lg-highlight-number">10</span>, <span class="lg-highlight-attr">price</span>: <span class="lg-highlight-number">2.5</span> } ]<!-- -->, <span class="lg-highlight-attr">status</span>: <span class="lg-highlight-string">"A"</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">5</span>, <span class="lg-highlight-attr">cust_id</span>: <span class="lg-highlight-string">"Busby Bee"</span>, <span class="lg-highlight-attr">ord_date</span>: <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">Date</span>(<span class="lg-highlight-string">"2020-03-19"</span>)<!-- -->, <span class="lg-highlight-attr">price</span>: <span class="lg-highlight-number">50</span>, <span class="lg-highlight-attr">items</span>: <!-- -->[ <!-- -->{ <span class="lg-highlight-attr">sku</span>: <span class="lg-highlight-string">"chocolates"</span>, <span class="lg-highlight-attr">qty</span>: <span class="lg-highlight-number">5</span>, <span class="lg-highlight-attr">price</span>: <span class="lg-highlight-number">10</span> } ]<!-- -->, <span class="lg-highlight-attr">status</span>: <span class="lg-highlight-string">"A"</span>}<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">6</span>, <span class="lg-highlight-attr">cust_id</span>: <span class="lg-highlight-string">"Cam Elot"</span>, <span class="lg-highlight-attr">ord_date</span>: <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">Date</span>(<span class="lg-highlight-string">"2020-03-19"</span>)<!-- -->, <span class="lg-highlight-attr">price</span>: <span class="lg-highlight-number">35</span>, <span class="lg-highlight-attr">items</span>: <!-- -->[ <!-- -->{ <span class="lg-highlight-attr">sku</span>: <span class="lg-highlight-string">"carrots"</span>, <span class="lg-highlight-attr">qty</span>: <span class="lg-highlight-number">10</span>, <span class="lg-highlight-attr">price</span>: <span class="lg-highlight-number">1.0</span> }<!-- -->, <!-- -->{ <span class="lg-highlight-attr">sku</span>: <span class="lg-highlight-string">"apples"</span>, <span class="lg-highlight-attr">qty</span>: <span class="lg-highlight-number">10</span>, <span class="lg-highlight-attr">price</span>: <span class="lg-highlight-number">2.5</span> } ]<!-- -->, <span class="lg-highlight-attr">status</span>: <span class="lg-highlight-string">"A"</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">7</span>, <span class="lg-highlight-attr">cust_id</span>: <span class="lg-highlight-string">"Cam Elot"</span>, <span class="lg-highlight-attr">ord_date</span>: <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">Date</span>(<span class="lg-highlight-string">"2020-03-20"</span>)<!-- -->, <span class="lg-highlight-attr">price</span>: <span class="lg-highlight-number">25</span>, <span class="lg-highlight-attr">items</span>: <!-- -->[ <!-- -->{ <span class="lg-highlight-attr">sku</span>: <span class="lg-highlight-string">"oranges"</span>, <span class="lg-highlight-attr">qty</span>: <span class="lg-highlight-number">10</span>, <span class="lg-highlight-attr">price</span>: <span class="lg-highlight-number">2.5</span> } ]<!-- -->, <span class="lg-highlight-attr">status</span>: <span class="lg-highlight-string">"A"</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">8</span>, <span class="lg-highlight-attr">cust_id</span>: <span class="lg-highlight-string">"Don Quis"</span>, <span class="lg-highlight-attr">ord_date</span>: <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">Date</span>(<span class="lg-highlight-string">"2020-03-20"</span>)<!-- -->, <span class="lg-highlight-attr">price</span>: <span class="lg-highlight-number">75</span>, <span class="lg-highlight-attr">items</span>: <!-- -->[ <!-- -->{ <span class="lg-highlight-attr">sku</span>: <span class="lg-highlight-string">"chocolates"</span>, <span class="lg-highlight-attr">qty</span>: <span class="lg-highlight-number">5</span>, <span class="lg-highlight-attr">price</span>: <span class="lg-highlight-number">10</span> }<!-- -->, <!-- -->{ <span class="lg-highlight-attr">sku</span>: <span class="lg-highlight-string">"apples"</span>, <span class="lg-highlight-attr">qty</span>: <span class="lg-highlight-number">10</span>, <span class="lg-highlight-attr">price</span>: <span class="lg-highlight-number">2.5</span> } ]<!-- -->, <span class="lg-highlight-attr">status</span>: <span class="lg-highlight-string">"A"</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">9</span>, <span class="lg-highlight-attr">cust_id</span>: <span class="lg-highlight-string">"Don Quis"</span>, <span class="lg-highlight-attr">ord_date</span>: <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">Date</span>(<span class="lg-highlight-string">"2020-03-20"</span>)<!-- -->, <span class="lg-highlight-attr">price</span>: <span class="lg-highlight-number">55</span>, <span class="lg-highlight-attr">items</span>: <!-- -->[ <!-- -->{ <span class="lg-highlight-attr">sku</span>: <span class="lg-highlight-string">"carrots"</span>, <span class="lg-highlight-attr">qty</span>: <span class="lg-highlight-number">5</span>, <span class="lg-highlight-attr">price</span>: <span class="lg-highlight-number">1.0</span> }<!-- -->, <!-- -->{ <span class="lg-highlight-attr">sku</span>: <span class="lg-highlight-string">"apples"</span>, <span class="lg-highlight-attr">qty</span>: <span class="lg-highlight-number">10</span>, <span class="lg-highlight-attr">price</span>: <span class="lg-highlight-number">2.5</span> }<!-- -->, <!-- -->{ <span class="lg-highlight-attr">sku</span>: <span class="lg-highlight-string">"oranges"</span>, <span class="lg-highlight-attr">qty</span>: <span class="lg-highlight-number">10</span>, <span class="lg-highlight-attr">price</span>: <span class="lg-highlight-number">2.5</span> } ]<!-- -->, <span class="lg-highlight-attr">status</span>: <span class="lg-highlight-string">"A"</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">10</span>, <span class="lg-highlight-attr">cust_id</span>: <span class="lg-highlight-string">"Don Quis"</span>, <span class="lg-highlight-attr">ord_date</span>: <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">Date</span>(<span class="lg-highlight-string">"2020-03-23"</span>)<!-- -->, <span class="lg-highlight-attr">price</span>: <span class="lg-highlight-number">25</span>, <span class="lg-highlight-attr">items</span>: <!-- -->[ <!-- -->{ <span class="lg-highlight-attr">sku</span>: <span class="lg-highlight-string">"oranges"</span>, <span class="lg-highlight-attr">qty</span>: <span class="lg-highlight-number">10</span>, <span class="lg-highlight-attr">price</span>: <span class="lg-highlight-number">2.5</span> } ]<!-- -->, <span class="lg-highlight-attr">status</span>: <span class="lg-highlight-string">"A"</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">])</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> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Return the Total Price Per Customer <a class="headerlink leafygreen-ui-1kepx47" href="#return-the-total-price-per-customer" 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="return-the-total-price-per-customer"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> Perform the map-reduce operation on the <code class="leafygreen-ui-1l06pbn"> orders </code> collection to group by the <code class="leafygreen-ui-1l06pbn"> cust_id </code> , and calculate the sum of the <code class="leafygreen-ui-1l06pbn"> price </code> for each <code class="leafygreen-ui-1l06pbn"> cust_id </code> : </p> <ol class="leafygreen-ui-rioki0" type="1"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Define the map function to process each input document: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> In the function, <code class="leafygreen-ui-1l06pbn"> this </code> refers to the document that the map-reduce operation is processing. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> The function maps the <code class="leafygreen-ui-1l06pbn"> price </code> to the <code class="leafygreen-ui-1l06pbn"> cust_id </code> for each document and emits the <code class="leafygreen-ui-1l06pbn"> cust_id </code> and <code class="leafygreen-ui-1l06pbn"> price </code> . </p> </li> </ul> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"var mapFunction1 = function() {\n emit(this.cust_id, this.price);\n};","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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"><span class="lg-highlight-keyword">var</span> mapFunction1 <!-- -->= <span class="lg-highlight-keyword lg-highlight-function">function</span>(<!-- -->)<!-- --> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-title lg-highlight-function">emit</span>(<span class="lg-highlight-variable lg-highlight-language">this</span>.<span class="lg-highlight-property">cust_id</span>, <span class="lg-highlight-variable lg-highlight-language">this</span>.<span class="lg-highlight-property">price</span>)<!-- -->;</td></tr><tr class=""><td class="leafygreen-ui-7razhx">}<!-- -->;</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> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Define the corresponding reduce function with two arguments <code class="leafygreen-ui-1l06pbn"> keyCustId </code> and <code class="leafygreen-ui-1l06pbn"> valuesPrices </code> : </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> The <code class="leafygreen-ui-1l06pbn"> valuesPrices </code> is an array whose elements are the <code class="leafygreen-ui-1l06pbn"> price </code> values emitted by the map function and grouped by <code class="leafygreen-ui-1l06pbn"> keyCustId </code> . </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> The function reduces the <code class="leafygreen-ui-1l06pbn"> valuesPrice </code> array to the sum of its elements. </p> </li> </ul> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"var reduceFunction1 = function(keyCustId, valuesPrices) {\n return Array.sum(valuesPrices);\n};","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-keyword">var</span> reduceFunction1 <!-- -->= <span class="lg-highlight-keyword lg-highlight-function">function</span>(<span class="lg-highlight-params">keyCustId, valuesPrices</span>)<!-- --> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-keyword">return</span> <span class="lg-highlight-title lg-highlight-class">Array</span>.<span class="lg-highlight-title lg-highlight-function">sum</span>(<!-- -->valuesPrices)<!-- -->;</td></tr><tr class=""><td class="leafygreen-ui-7razhx">}<!-- -->;</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> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Perform map-reduce on all documents in the <code class="leafygreen-ui-1l06pbn"> orders </code> collection using the <code class="leafygreen-ui-1l06pbn"> mapFunction1 </code> map function and the <code class="leafygreen-ui-1l06pbn"> reduceFunction1 </code> reduce function: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.orders.mapReduce(\n mapFunction1,\n reduceFunction1,\n { out: \"map_reduce_example\" }\n)","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">orders</span>.<span class="lg-highlight-title lg-highlight-function">mapReduce</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->mapFunction1<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->reduceFunction1<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">out</span>: <span class="lg-highlight-string">"map_reduce_example"</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">)</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"> This operation outputs the results to a collection named <code class="leafygreen-ui-1l06pbn"> map_reduce_example </code> . If the <code class="leafygreen-ui-1l06pbn"> map_reduce_example </code> collection already exists, the operation will replace the contents with the results of this map-reduce operation. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Query the <code class="leafygreen-ui-1l06pbn"> map_reduce_example </code> collection to verify the results: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.map_reduce_example.find().sort( { _id: 1 } )","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">map_reduce_example</span>.<span class="lg-highlight-title lg-highlight-function">find</span>(<!-- -->).<span class="lg-highlight-title lg-highlight-function">sort</span>( <!-- -->{ <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">1</span> } )</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 operation returns these documents: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ \"_id\" : \"Ant O. Knee\", \"value\" : 95 }\n{ \"_id\" : \"Busby Bee\", \"value\" : 125 }\n{ \"_id\" : \"Cam Elot\", \"value\" : 60 }\n{ \"_id\" : \"Don Quis\", \"value\" : 155 }","programmingLanguage":"JavaScript"} </script> <div class="css-1lju8ps"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1jheeh3"> <pre class="leafygreen-ui-1453az5" 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">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-string">"Ant O. Knee"</span>, <span class="lg-highlight-string">"value"</span> <!-- -->: <span class="lg-highlight-number">95</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-string">"Busby Bee"</span>, <span class="lg-highlight-string">"value"</span> <!-- -->: <span class="lg-highlight-number">125</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-string">"Cam Elot"</span>, <span class="lg-highlight-string">"value"</span> <!-- -->: <span class="lg-highlight-number">60</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-string">"Don Quis"</span>, <span class="lg-highlight-string">"value"</span> <!-- -->: <span class="lg-highlight-number">155</span> }</td></tr></tbody></table></code></pre> </div> </div> </div> </li> </ol> <section> <h4 class="contains-headerlink leafygreen-ui-1vzlt5f"> Aggregation Alternative <a class="headerlink leafygreen-ui-1kepx47" href="#aggregation-alternative" 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-alternative"> </div> </a> </h4> <p class="leafygreen-ui-1kp3ins"> Using the available aggregation pipeline operators, you can rewrite the map-reduce operation without defining custom functions: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.orders.aggregate([\n { $group: { _id: \"$cust_id\", value: { $sum: \"$price\" } } },\n { $out: \"agg_alternative_1\" }\n])","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><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">orders</span>.<span class="lg-highlight-title lg-highlight-function">aggregate</span>(<!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">$group</span>: <!-- -->{ <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-string">"$cust_id"</span>, <span class="lg-highlight-attr">value</span>: <!-- -->{ <span class="lg-highlight-attr">$sum</span>: <span class="lg-highlight-string">"$price"</span> } } }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">$out</span>: <span class="lg-highlight-string">"agg_alternative_1"</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">])</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> <ol class="leafygreen-ui-rioki0" type="1"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> The <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/group/#mongodb-pipeline-pipe.-group"> <code class="leafygreen-ui-1l06pbn"> $group </code> </a> stage groups by the <code class="leafygreen-ui-1l06pbn"> cust_id </code> and calculates the <code class="leafygreen-ui-1l06pbn"> value </code> field (See also <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/sum/#mongodb-group-grp.-sum"> <code class="leafygreen-ui-1l06pbn"> $sum </code> </a> ). The <code class="leafygreen-ui-1l06pbn"> value </code> field contains the total <code class="leafygreen-ui-1l06pbn"> price </code> for each <code class="leafygreen-ui-1l06pbn"> cust_id </code> . </p> <p class="leafygreen-ui-1kp3ins"> The stage output the following documents to the next stage: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ \"_id\" : \"Don Quis\", \"value\" : 155 }\n{ \"_id\" : \"Ant O. Knee\", \"value\" : 95 }\n{ \"_id\" : \"Cam Elot\", \"value\" : 60 }\n{ \"_id\" : \"Busby Bee\", \"value\" : 125 }","programmingLanguage":"JavaScript"} </script> <div class="css-1lju8ps"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1jheeh3"> <pre class="leafygreen-ui-1453az5" 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">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-string">"Don Quis"</span>, <span class="lg-highlight-string">"value"</span> <!-- -->: <span class="lg-highlight-number">155</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-string">"Ant O. Knee"</span>, <span class="lg-highlight-string">"value"</span> <!-- -->: <span class="lg-highlight-number">95</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-string">"Cam Elot"</span>, <span class="lg-highlight-string">"value"</span> <!-- -->: <span class="lg-highlight-number">60</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-string">"Busby Bee"</span>, <span class="lg-highlight-string">"value"</span> <!-- -->: <span class="lg-highlight-number">125</span> }</td></tr></tbody></table></code></pre> </div> </div> </div> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Then, 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> writes the output to the collection <code class="leafygreen-ui-1l06pbn"> agg_alternative_1 </code> . Alternatively, you could use <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/merge/#mongodb-pipeline-pipe.-merge"> <code class="leafygreen-ui-1l06pbn"> $merge </code> </a> instead of <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/out/#mongodb-pipeline-pipe.-out"> <code class="leafygreen-ui-1l06pbn"> $out </code> . </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Query the <code class="leafygreen-ui-1l06pbn"> agg_alternative_1 </code> collection to verify the results: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.agg_alternative_1.find().sort( { _id: 1 } )","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">agg_alternative_1</span>.<span class="lg-highlight-title lg-highlight-function">find</span>(<!-- -->).<span class="lg-highlight-title lg-highlight-function">sort</span>( <!-- -->{ <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">1</span> } )</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 operation returns the following documents: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ \"_id\" : \"Ant O. Knee\", \"value\" : 95 }\n{ \"_id\" : \"Busby Bee\", \"value\" : 125 }\n{ \"_id\" : \"Cam Elot\", \"value\" : 60 }\n{ \"_id\" : \"Don Quis\", \"value\" : 155 }","programmingLanguage":"JavaScript"} </script> <div class="css-1lju8ps"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1jheeh3"> <pre class="leafygreen-ui-1453az5" 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">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-string">"Ant O. Knee"</span>, <span class="lg-highlight-string">"value"</span> <!-- -->: <span class="lg-highlight-number">95</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-string">"Busby Bee"</span>, <span class="lg-highlight-string">"value"</span> <!-- -->: <span class="lg-highlight-number">125</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-string">"Cam Elot"</span>, <span class="lg-highlight-string">"value"</span> <!-- -->: <span class="lg-highlight-number">60</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-string">"Don Quis"</span>, <span class="lg-highlight-string">"value"</span> <!-- -->: <span class="lg-highlight-number">155</span> }</td></tr></tbody></table></code></pre> </div> </div> </div> </li> </ol> <div class="leafygreen-ui-13vw3ie" role="note"> <h2 class="leafygreen-ui-1fn4p2b"> Tip </h2> <h3 class="leafygreen-ui-144d5kf"> <strong> See also: </strong> </h3> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> For an alternative that uses custom aggregation expressions, see <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/map-reduce-to-aggregation-pipeline/#std-label-mr-to-agg-examples1"> Map-Reduce to Aggregation Pipeline Translation Examples <!-- --> . </a> </p> </div> </div> </section> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Calculate Order and Total Quantity with Average Quantity Per Item <a class="headerlink leafygreen-ui-1kepx47" href="#calculate-order-and-total-quantity-with-average-quantity-per-item" 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="calculate-order-and-total-quantity-with-average-quantity-per-item"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> In the following example, you will see a map-reduce operation on the <code class="leafygreen-ui-1l06pbn"> orders </code> collection for all documents that have an <code class="leafygreen-ui-1l06pbn"> ord_date </code> value greater than or equal to <code class="leafygreen-ui-1l06pbn"> 2020-03-01 </code> . </p> <p class="leafygreen-ui-1kp3ins"> The operation in the example: </p> <ol class="leafygreen-ui-rioki0" type="1"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Groups by the <code class="leafygreen-ui-1l06pbn"> item.sku </code> field, and calculates the number of orders and the total quantity ordered for each <code class="leafygreen-ui-1l06pbn"> sku </code> . </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Calculates the average quantity per order for each <code class="leafygreen-ui-1l06pbn"> sku </code> value and merges the results into the output collection. </p> </li> </ol> <p class="leafygreen-ui-1kp3ins"> When merging results, if an existing document has the same key as the new result, the operation overwrites the existing document. If there is no existing document with the same key, the operation inserts the document. </p> <p class="leafygreen-ui-1kp3ins"> Example steps: </p> <ol class="leafygreen-ui-rioki0" type="1"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Define the map function to process each input document: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> In the function, <code class="leafygreen-ui-1l06pbn"> this </code> refers to the document that the map-reduce operation is processing. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> For each item, the function associates the <code class="leafygreen-ui-1l06pbn"> sku </code> with a new object <code class="leafygreen-ui-1l06pbn"> value </code> that contains the <code class="leafygreen-ui-1l06pbn"> count </code> of <code class="leafygreen-ui-1l06pbn"> 1 </code> and the item <code class="leafygreen-ui-1l06pbn"> qty </code> for the order and emits the <code class="leafygreen-ui-1l06pbn"> sku </code> (stored in the <code class="leafygreen-ui-1l06pbn"> key </code> ) and the <code class="leafygreen-ui-1l06pbn"> value </code> . </p> </li> </ul> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":" var mapFunction2 = function() {\n for (var idx = 0; idx &lt; this.items.length; idx++) {\n var key = this.items[idx].sku;\n var value = { count: 1, qty: this.items[idx].qty };\n\n emit(key, value);\n }\n};","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-keyword">var</span> mapFunction2 <!-- -->= <span class="lg-highlight-keyword lg-highlight-function">function</span>(<!-- -->)<!-- --> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-keyword">for</span> <!-- -->(<span class="lg-highlight-keyword">var</span> idx <!-- -->= <span class="lg-highlight-number">0</span>; <!-- -->idx <!-- -->&lt; <span class="lg-highlight-variable lg-highlight-language">this</span>.<span class="lg-highlight-property">items</span>.<span class="lg-highlight-property">length</span>; <!-- -->idx<!-- -->+<!-- -->+<!-- -->) <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-keyword">var</span> key <!-- -->= <span class="lg-highlight-variable lg-highlight-language">this</span>.<span class="lg-highlight-property">items</span>[<!-- -->idx].<span class="lg-highlight-property">sku</span>;</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-keyword">var</span> value <!-- -->= <!-- -->{ <span class="lg-highlight-attr">count</span>: <span class="lg-highlight-number">1</span>, <span class="lg-highlight-attr">qty</span>: <span class="lg-highlight-variable lg-highlight-language">this</span>.<span class="lg-highlight-property">items</span>[<!-- -->idx].<span class="lg-highlight-property">qty</span> }<!-- -->;</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><div class="leafygreen-ui-ihxujy"></div></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-title lg-highlight-function">emit</span>(<!-- -->key<!-- -->, <!-- -->value)<!-- -->;</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->}</td></tr><tr class=""><td class="leafygreen-ui-7razhx">}<!-- -->;</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> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Define the corresponding reduce function with two arguments <code class="leafygreen-ui-1l06pbn"> keySKU </code> and <code class="leafygreen-ui-1l06pbn"> countObjVals </code> : </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <code class="leafygreen-ui-1l06pbn"> countObjVals </code> is an array whose elements are the objects mapped to the grouped <code class="leafygreen-ui-1l06pbn"> keySKU </code> values passed by map function to the reducer function. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> The function reduces the <code class="leafygreen-ui-1l06pbn"> countObjVals </code> array to a single object <code class="leafygreen-ui-1l06pbn"> reducedValue </code> that contains the <code class="leafygreen-ui-1l06pbn"> count </code> and the <code class="leafygreen-ui-1l06pbn"> qty </code> fields. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> In <code class="leafygreen-ui-1l06pbn"> reducedVal </code> , the <code class="leafygreen-ui-1l06pbn"> count </code> field contains the sum of the <code class="leafygreen-ui-1l06pbn"> count </code> fields from the individual array elements, and the <code class="leafygreen-ui-1l06pbn"> qty </code> field contains the sum of the <code class="leafygreen-ui-1l06pbn"> qty </code> fields from the individual array elements. </p> </li> </ul> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"var reduceFunction2 = function(keySKU, countObjVals) {\n reducedVal = { count: 0, qty: 0 };\n\n for (var idx = 0; idx &lt; countObjVals.length; idx++) {\n reducedVal.count += countObjVals[idx].count;\n reducedVal.qty += countObjVals[idx].qty;\n }\n\n return reducedVal;\n};","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-keyword">var</span> reduceFunction2 <!-- -->= <span class="lg-highlight-keyword lg-highlight-function">function</span>(<span class="lg-highlight-params">keySKU, countObjVals</span>)<!-- --> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->reducedVal <!-- -->= <!-- -->{ <span class="lg-highlight-attr">count</span>: <span class="lg-highlight-number">0</span>, <span class="lg-highlight-attr">qty</span>: <span class="lg-highlight-number">0</span> }<!-- -->;</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><div class="leafygreen-ui-ihxujy"></div></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-keyword">for</span> <!-- -->(<span class="lg-highlight-keyword">var</span> idx <!-- -->= <span class="lg-highlight-number">0</span>; <!-- -->idx <!-- -->&lt; <!-- -->countObjVals.<span class="lg-highlight-property">length</span>; <!-- -->idx<!-- -->+<!-- -->+<!-- -->) <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->reducedVal.<span class="lg-highlight-property">count</span> <!-- -->+<!-- -->= <!-- -->countObjVals<!-- -->[<!-- -->idx].<span class="lg-highlight-property">count</span>;</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->reducedVal.<span class="lg-highlight-property">qty</span> <!-- -->+<!-- -->= <!-- -->countObjVals<!-- -->[<!-- -->idx].<span class="lg-highlight-property">qty</span>;</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->}</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><div class="leafygreen-ui-ihxujy"></div></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-keyword">return</span> <!-- -->reducedVal<!-- -->;</td></tr><tr class=""><td class="leafygreen-ui-7razhx">}<!-- -->;</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> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Define a finalize function with two arguments <code class="leafygreen-ui-1l06pbn"> key </code> and <code class="leafygreen-ui-1l06pbn"> reducedVal </code> . The function modifies the <code class="leafygreen-ui-1l06pbn"> reducedVal </code> object to add a computed field named <code class="leafygreen-ui-1l06pbn"> avg </code> and returns the modified object: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"var finalizeFunction2 = function (key, reducedVal) {\n reducedVal.avg = reducedVal.qty/reducedVal.count;\n return reducedVal;\n};","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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"><span class="lg-highlight-keyword">var</span> finalizeFunction2 <!-- -->= <span class="lg-highlight-keyword lg-highlight-function">function</span> <!-- -->(<span class="lg-highlight-params">key, reducedVal</span>)<!-- --> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->reducedVal.<span class="lg-highlight-property">avg</span> <!-- -->= <!-- -->reducedVal.<span class="lg-highlight-property">qty</span>/<!-- -->reducedVal.<span class="lg-highlight-property">count</span>;</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-keyword">return</span> <!-- -->reducedVal<!-- -->;</td></tr><tr class=""><td class="leafygreen-ui-7razhx">}<!-- -->;</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> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Perform the map-reduce operation on the <code class="leafygreen-ui-1l06pbn"> orders </code> collection using the <code class="leafygreen-ui-1l06pbn"> mapFunction2 </code> , <code class="leafygreen-ui-1l06pbn"> reduceFunction2 </code> , and <code class="leafygreen-ui-1l06pbn"> finalizeFunction2 </code> functions: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.orders.mapReduce(\n mapFunction2,\n reduceFunction2,\n {\n out: { merge: \"map_reduce_example2\" },\n query: { ord_date: { $gte: new Date(\"2020-03-01\") } },\n finalize: finalizeFunction2\n }\n );","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><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">orders</span>.<span class="lg-highlight-title lg-highlight-function">mapReduce</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->mapFunction2<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->reduceFunction2<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">out</span>: <!-- -->{ <span class="lg-highlight-attr">merge</span>: <span class="lg-highlight-string">"map_reduce_example2"</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">query</span>: <!-- -->{ <span class="lg-highlight-attr">ord_date</span>: <!-- -->{ <span class="lg-highlight-attr">$gte</span>: <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">Date</span>(<span class="lg-highlight-string">"2020-03-01"</span>) } }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">finalize</span>: <!-- -->finalizeFunction2</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> )<!-- -->;</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"> This operation uses the <code class="leafygreen-ui-1l06pbn"> query </code> field to select only those documents with <code class="leafygreen-ui-1l06pbn"> ord_date </code> greater than or equal to <code class="leafygreen-ui-1l06pbn"> new Date("2020-03-01") </code> . Then it outputs the results to a collection <code class="leafygreen-ui-1l06pbn"> map_reduce_example2 </code> . </p> <p class="leafygreen-ui-1kp3ins"> If the <code class="leafygreen-ui-1l06pbn"> map_reduce_example2 </code> collection already exists, the operation will merge the existing contents with the results of this map-reduce operation. That is, if an existing document has the same key as the new result, the operation overwrites the existing document. If there is no existing document with the same key, the operation inserts the document. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Query the <code class="leafygreen-ui-1l06pbn"> map_reduce_example2 </code> collection to verify the results: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.map_reduce_example2.find().sort( { _id: 1 } )","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">map_reduce_example2</span>.<span class="lg-highlight-title lg-highlight-function">find</span>(<!-- -->).<span class="lg-highlight-title lg-highlight-function">sort</span>( <!-- -->{ <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">1</span> } )</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 operation returns these documents: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ \"_id\" : \"apples\", \"value\" : { \"count\" : 4, \"qty\" : 35, \"avg\" : 8.75 } }\n{ \"_id\" : \"carrots\", \"value\" : { \"count\" : 2, \"qty\" : 15, \"avg\" : 7.5 } }\n{ \"_id\" : \"chocolates\", \"value\" : { \"count\" : 3, \"qty\" : 15, \"avg\" : 5 } }\n{ \"_id\" : \"oranges\", \"value\" : { \"count\" : 7, \"qty\" : 63, \"avg\" : 9 } }\n{ \"_id\" : \"pears\", \"value\" : { \"count\" : 1, \"qty\" : 10, \"avg\" : 10 } }","programmingLanguage":"JavaScript"} </script> <div class="css-1lju8ps"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-tyg50d"> <pre class="leafygreen-ui-1453az5" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-string">"apples"</span>, <span class="lg-highlight-string">"value"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-string">"count"</span> <!-- -->: <span class="lg-highlight-number">4</span>, <span class="lg-highlight-string">"qty"</span> <!-- -->: <span class="lg-highlight-number">35</span>, <span class="lg-highlight-string">"avg"</span> <!-- -->: <span class="lg-highlight-number">8.75</span> } }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-string">"carrots"</span>, <span class="lg-highlight-string">"value"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-string">"count"</span> <!-- -->: <span class="lg-highlight-number">2</span>, <span class="lg-highlight-string">"qty"</span> <!-- -->: <span class="lg-highlight-number">15</span>, <span class="lg-highlight-string">"avg"</span> <!-- -->: <span class="lg-highlight-number">7.5</span> } }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-string">"chocolates"</span>, <span class="lg-highlight-string">"value"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-string">"count"</span> <!-- -->: <span class="lg-highlight-number">3</span>, <span class="lg-highlight-string">"qty"</span> <!-- -->: <span class="lg-highlight-number">15</span>, <span class="lg-highlight-string">"avg"</span> <!-- -->: <span class="lg-highlight-number">5</span> } }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-string">"oranges"</span>, <span class="lg-highlight-string">"value"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-string">"count"</span> <!-- -->: <span class="lg-highlight-number">7</span>, <span class="lg-highlight-string">"qty"</span> <!-- -->: <span class="lg-highlight-number">63</span>, <span class="lg-highlight-string">"avg"</span> <!-- -->: <span class="lg-highlight-number">9</span> } }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-string">"pears"</span>, <span class="lg-highlight-string">"value"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-string">"count"</span> <!-- -->: <span class="lg-highlight-number">1</span>, <span class="lg-highlight-string">"qty"</span> <!-- -->: <span class="lg-highlight-number">10</span>, <span class="lg-highlight-string">"avg"</span> <!-- -->: <span class="lg-highlight-number">10</span> } }</td></tr></tbody></table></code></pre> </div> </div> </div> </li> </ol> <section> <h4 class="contains-headerlink leafygreen-ui-1vzlt5f"> Aggregation Alternative <a class="headerlink leafygreen-ui-1kepx47" href="#aggregation-alternative-1" 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-alternative-1"> </div> </a> </h4> <p class="leafygreen-ui-1kp3ins"> Using the available aggregation pipeline operators, you can rewrite the map-reduce operation without defining custom functions: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.orders.aggregate( [\n { $match: { ord_date: { $gte: new Date(\"2020-03-01\") } } },\n { $unwind: \"$items\" },\n { $group: { _id: \"$items.sku\", qty: { $sum: \"$items.qty\" }, orders_ids: { $addToSet: \"$_id\" } } },\n { $project: { value: { count: { $size: \"$orders_ids\" }, qty: \"$qty\", avg: { $divide: [ \"$qty\", { $size: \"$orders_ids\" } ] } } } },\n { $merge: { into: \"agg_alternative_3\", on: \"_id\", whenMatched: \"replace\", whenNotMatched: \"insert\" } }\n] )","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><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">orders</span>.<span class="lg-highlight-title lg-highlight-function">aggregate</span>( <!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">$match</span>: <!-- -->{ <span class="lg-highlight-attr">ord_date</span>: <!-- -->{ <span class="lg-highlight-attr">$gte</span>: <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">Date</span>(<span class="lg-highlight-string">"2020-03-01"</span>) } } }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">$unwind</span>: <span class="lg-highlight-string">"$items"</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">$group</span>: <!-- -->{ <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-string">"$items.sku"</span>, <span class="lg-highlight-attr">qty</span>: <!-- -->{ <span class="lg-highlight-attr">$sum</span>: <span class="lg-highlight-string">"$items.qty"</span> }<!-- -->, <span class="lg-highlight-attr">orders_ids</span>: <!-- -->{ <span class="lg-highlight-attr">$addToSet</span>: <span class="lg-highlight-string">"$_id"</span> } } }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">$project</span>: <!-- -->{ <span class="lg-highlight-attr">value</span>: <!-- -->{ <span class="lg-highlight-attr">count</span>: <!-- -->{ <span class="lg-highlight-attr">$size</span>: <span class="lg-highlight-string">"$orders_ids"</span> }<!-- -->, <span class="lg-highlight-attr">qty</span>: <span class="lg-highlight-string">"$qty"</span>, <span class="lg-highlight-attr">avg</span>: <!-- -->{ <span class="lg-highlight-attr">$divide</span>: <!-- -->[ <span class="lg-highlight-string">"$qty"</span>, <!-- -->{ <span class="lg-highlight-attr">$size</span>: <span class="lg-highlight-string">"$orders_ids"</span> } ] } } } }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">$merge</span>: <!-- -->{ <span class="lg-highlight-attr">into</span>: <span class="lg-highlight-string">"agg_alternative_3"</span>, <span class="lg-highlight-attr">on</span>: <span class="lg-highlight-string">"_id"</span>, <span class="lg-highlight-attr">whenMatched</span>: <span class="lg-highlight-string">"replace"</span>, <span class="lg-highlight-attr">whenNotMatched</span>: <span class="lg-highlight-string">"insert"</span> } }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">] )</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> <ol class="leafygreen-ui-rioki0" type="1"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> The <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/match/#mongodb-pipeline-pipe.-match"> <code class="leafygreen-ui-1l06pbn"> $match </code> </a> stage selects only those documents with <code class="leafygreen-ui-1l06pbn"> ord_date </code> greater than or equal to <code class="leafygreen-ui-1l06pbn"> new Date("2020-03-01") </code> . </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> The <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/unwind/#mongodb-pipeline-pipe.-unwind"> <code class="leafygreen-ui-1l06pbn"> $unwind </code> </a> stage breaks down the document by the <code class="leafygreen-ui-1l06pbn"> items </code> array field to output a document for each array element. For example: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ \"_id\" : 1, \"cust_id\" : \"Ant O. Knee\", \"ord_date\" : ISODate(\"2020-03-01T00:00:00Z\"), \"price\" : 25, \"items\" : { \"sku\" : \"oranges\", \"qty\" : 5, \"price\" : 2.5 }, \"status\" : \"A\" }\n{ \"_id\" : 1, \"cust_id\" : \"Ant O. Knee\", \"ord_date\" : ISODate(\"2020-03-01T00:00:00Z\"), \"price\" : 25, \"items\" : { \"sku\" : \"apples\", \"qty\" : 5, \"price\" : 2.5 }, \"status\" : \"A\" }\n{ \"_id\" : 2, \"cust_id\" : \"Ant O. Knee\", \"ord_date\" : ISODate(\"2020-03-08T00:00:00Z\"), \"price\" : 70, \"items\" : { \"sku\" : \"oranges\", \"qty\" : 8, \"price\" : 2.5 }, \"status\" : \"A\" }\n{ \"_id\" : 2, \"cust_id\" : \"Ant O. Knee\", \"ord_date\" : ISODate(\"2020-03-08T00:00:00Z\"), \"price\" : 70, \"items\" : { \"sku\" : \"chocolates\", \"qty\" : 5, \"price\" : 10 }, \"status\" : \"A\" }\n{ \"_id\" : 3, \"cust_id\" : \"Busby Bee\", \"ord_date\" : ISODate(\"2020-03-08T00:00:00Z\"), \"price\" : 50, \"items\" : { \"sku\" : \"oranges\", \"qty\" : 10, \"price\" : 2.5 }, \"status\" : \"A\" }\n{ \"_id\" : 3, \"cust_id\" : \"Busby Bee\", \"ord_date\" : ISODate(\"2020-03-08T00:00:00Z\"), \"price\" : 50, \"items\" : { \"sku\" : \"pears\", \"qty\" : 10, \"price\" : 2.5 }, \"status\" : \"A\" }\n{ \"_id\" : 4, \"cust_id\" : \"Busby Bee\", \"ord_date\" : ISODate(\"2020-03-18T00:00:00Z\"), \"price\" : 25, \"items\" : { \"sku\" : \"oranges\", \"qty\" : 10, \"price\" : 2.5 }, \"status\" : \"A\" }\n{ \"_id\" : 5, \"cust_id\" : \"Busby Bee\", \"ord_date\" : ISODate(\"2020-03-19T00:00:00Z\"), \"price\" : 50, \"items\" : { \"sku\" : \"chocolates\", \"qty\" : 5, \"price\" : 10 }, \"status\" : \"A\" }\n...","programmingLanguage":"JavaScript"} </script> <div class="css-1lju8ps"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-tyg50d"> <pre class="leafygreen-ui-1453az5" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">1</span>, <span class="lg-highlight-string">"cust_id"</span> <!-- -->: <span class="lg-highlight-string">"Ant O. Knee"</span>, <span class="lg-highlight-string">"ord_date"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">ISODate</span>(<span class="lg-highlight-string">"2020-03-01T00:00:00Z"</span>)<!-- -->, <span class="lg-highlight-string">"price"</span> <!-- -->: <span class="lg-highlight-number">25</span>, <span class="lg-highlight-string">"items"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-string">"sku"</span> <!-- -->: <span class="lg-highlight-string">"oranges"</span>, <span class="lg-highlight-string">"qty"</span> <!-- -->: <span class="lg-highlight-number">5</span>, <span class="lg-highlight-string">"price"</span> <!-- -->: <span class="lg-highlight-number">2.5</span> }<!-- -->, <span class="lg-highlight-string">"status"</span> <!-- -->: <span class="lg-highlight-string">"A"</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">1</span>, <span class="lg-highlight-string">"cust_id"</span> <!-- -->: <span class="lg-highlight-string">"Ant O. Knee"</span>, <span class="lg-highlight-string">"ord_date"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">ISODate</span>(<span class="lg-highlight-string">"2020-03-01T00:00:00Z"</span>)<!-- -->, <span class="lg-highlight-string">"price"</span> <!-- -->: <span class="lg-highlight-number">25</span>, <span class="lg-highlight-string">"items"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-string">"sku"</span> <!-- -->: <span class="lg-highlight-string">"apples"</span>, <span class="lg-highlight-string">"qty"</span> <!-- -->: <span class="lg-highlight-number">5</span>, <span class="lg-highlight-string">"price"</span> <!-- -->: <span class="lg-highlight-number">2.5</span> }<!-- -->, <span class="lg-highlight-string">"status"</span> <!-- -->: <span class="lg-highlight-string">"A"</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">2</span>, <span class="lg-highlight-string">"cust_id"</span> <!-- -->: <span class="lg-highlight-string">"Ant O. Knee"</span>, <span class="lg-highlight-string">"ord_date"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">ISODate</span>(<span class="lg-highlight-string">"2020-03-08T00:00:00Z"</span>)<!-- -->, <span class="lg-highlight-string">"price"</span> <!-- -->: <span class="lg-highlight-number">70</span>, <span class="lg-highlight-string">"items"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-string">"sku"</span> <!-- -->: <span class="lg-highlight-string">"oranges"</span>, <span class="lg-highlight-string">"qty"</span> <!-- -->: <span class="lg-highlight-number">8</span>, <span class="lg-highlight-string">"price"</span> <!-- -->: <span class="lg-highlight-number">2.5</span> }<!-- -->, <span class="lg-highlight-string">"status"</span> <!-- -->: <span class="lg-highlight-string">"A"</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">2</span>, <span class="lg-highlight-string">"cust_id"</span> <!-- -->: <span class="lg-highlight-string">"Ant O. Knee"</span>, <span class="lg-highlight-string">"ord_date"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">ISODate</span>(<span class="lg-highlight-string">"2020-03-08T00:00:00Z"</span>)<!-- -->, <span class="lg-highlight-string">"price"</span> <!-- -->: <span class="lg-highlight-number">70</span>, <span class="lg-highlight-string">"items"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-string">"sku"</span> <!-- -->: <span class="lg-highlight-string">"chocolates"</span>, <span class="lg-highlight-string">"qty"</span> <!-- -->: <span class="lg-highlight-number">5</span>, <span class="lg-highlight-string">"price"</span> <!-- -->: <span class="lg-highlight-number">10</span> }<!-- -->, <span class="lg-highlight-string">"status"</span> <!-- -->: <span class="lg-highlight-string">"A"</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">3</span>, <span class="lg-highlight-string">"cust_id"</span> <!-- -->: <span class="lg-highlight-string">"Busby Bee"</span>, <span class="lg-highlight-string">"ord_date"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">ISODate</span>(<span class="lg-highlight-string">"2020-03-08T00:00:00Z"</span>)<!-- -->, <span class="lg-highlight-string">"price"</span> <!-- -->: <span class="lg-highlight-number">50</span>, <span class="lg-highlight-string">"items"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-string">"sku"</span> <!-- -->: <span class="lg-highlight-string">"oranges"</span>, <span class="lg-highlight-string">"qty"</span> <!-- -->: <span class="lg-highlight-number">10</span>, <span class="lg-highlight-string">"price"</span> <!-- -->: <span class="lg-highlight-number">2.5</span> }<!-- -->, <span class="lg-highlight-string">"status"</span> <!-- -->: <span class="lg-highlight-string">"A"</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">3</span>, <span class="lg-highlight-string">"cust_id"</span> <!-- -->: <span class="lg-highlight-string">"Busby Bee"</span>, <span class="lg-highlight-string">"ord_date"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">ISODate</span>(<span class="lg-highlight-string">"2020-03-08T00:00:00Z"</span>)<!-- -->, <span class="lg-highlight-string">"price"</span> <!-- -->: <span class="lg-highlight-number">50</span>, <span class="lg-highlight-string">"items"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-string">"sku"</span> <!-- -->: <span class="lg-highlight-string">"pears"</span>, <span class="lg-highlight-string">"qty"</span> <!-- -->: <span class="lg-highlight-number">10</span>, <span class="lg-highlight-string">"price"</span> <!-- -->: <span class="lg-highlight-number">2.5</span> }<!-- -->, <span class="lg-highlight-string">"status"</span> <!-- -->: <span class="lg-highlight-string">"A"</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">4</span>, <span class="lg-highlight-string">"cust_id"</span> <!-- -->: <span class="lg-highlight-string">"Busby Bee"</span>, <span class="lg-highlight-string">"ord_date"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">ISODate</span>(<span class="lg-highlight-string">"2020-03-18T00:00:00Z"</span>)<!-- -->, <span class="lg-highlight-string">"price"</span> <!-- -->: <span class="lg-highlight-number">25</span>, <span class="lg-highlight-string">"items"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-string">"sku"</span> <!-- -->: <span class="lg-highlight-string">"oranges"</span>, <span class="lg-highlight-string">"qty"</span> <!-- -->: <span class="lg-highlight-number">10</span>, <span class="lg-highlight-string">"price"</span> <!-- -->: <span class="lg-highlight-number">2.5</span> }<!-- -->, <span class="lg-highlight-string">"status"</span> <!-- -->: <span class="lg-highlight-string">"A"</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">5</span>, <span class="lg-highlight-string">"cust_id"</span> <!-- -->: <span class="lg-highlight-string">"Busby Bee"</span>, <span class="lg-highlight-string">"ord_date"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">ISODate</span>(<span class="lg-highlight-string">"2020-03-19T00:00:00Z"</span>)<!-- -->, <span class="lg-highlight-string">"price"</span> <!-- -->: <span class="lg-highlight-number">50</span>, <span class="lg-highlight-string">"items"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-string">"sku"</span> <!-- -->: <span class="lg-highlight-string">"chocolates"</span>, <span class="lg-highlight-string">"qty"</span> <!-- -->: <span class="lg-highlight-number">5</span>, <span class="lg-highlight-string">"price"</span> <!-- -->: <span class="lg-highlight-number">10</span> }<!-- -->, <span class="lg-highlight-string">"status"</span> <!-- -->: <span class="lg-highlight-string">"A"</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">...</td></tr></tbody></table></code></pre> </div> </div> </div> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> The <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/group/#mongodb-pipeline-pipe.-group"> <code class="leafygreen-ui-1l06pbn"> $group </code> </a> stage groups by the <code class="leafygreen-ui-1l06pbn"> items.sku </code> , calculating for each sku: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <dl> <dt> The <code class="leafygreen-ui-1l06pbn"> qty </code> field. The <code class="leafygreen-ui-1l06pbn"> qty </code> field contains the </dt> <dd class="css-1ufxuu7"> total <code class="leafygreen-ui-1l06pbn"> qty </code> ordered per each <code class="leafygreen-ui-1l06pbn"> items.sku </code> (See <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/sum/#mongodb-group-grp.-sum"> <code class="leafygreen-ui-1l06pbn"> $sum </code> </a> ). </dd> </dl> </li> <li class="leafygreen-ui-d7p7b6"> <dl> <dt> The <code class="leafygreen-ui-1l06pbn"> orders_ids </code> array. The <code class="leafygreen-ui-1l06pbn"> orders_ids </code> field contains an </dt> <dd class="css-1ufxuu7"> array of distinct order <code class="leafygreen-ui-1l06pbn"> _id </code> 's for the <code class="leafygreen-ui-1l06pbn"> items.sku </code> (See <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/addToSet/#mongodb-group-grp.-addToSet"> <code class="leafygreen-ui-1l06pbn"> $addToSet </code> </a> ). </dd> </dl> </li> </ul> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ \"_id\" : \"chocolates\", \"qty\" : 15, \"orders_ids\" : [ 2, 5, 8 ] }\n{ \"_id\" : \"oranges\", \"qty\" : 63, \"orders_ids\" : [ 4, 7, 3, 2, 9, 1, 10 ] }\n{ \"_id\" : \"carrots\", \"qty\" : 15, \"orders_ids\" : [ 6, 9 ] }\n{ \"_id\" : \"apples\", \"qty\" : 35, \"orders_ids\" : [ 9, 8, 1, 6 ] }\n{ \"_id\" : \"pears\", \"qty\" : 10, \"orders_ids\" : [ 3 ] }","programmingLanguage":"JavaScript"} </script> <div class="css-1lju8ps"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-tyg50d"> <pre class="leafygreen-ui-1453az5" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-string">"chocolates"</span>, <span class="lg-highlight-string">"qty"</span> <!-- -->: <span class="lg-highlight-number">15</span>, <span class="lg-highlight-string">"orders_ids"</span> <!-- -->: <!-- -->[ <span class="lg-highlight-number">2</span>, <span class="lg-highlight-number">5</span>, <span class="lg-highlight-number">8</span> ] }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-string">"oranges"</span>, <span class="lg-highlight-string">"qty"</span> <!-- -->: <span class="lg-highlight-number">63</span>, <span class="lg-highlight-string">"orders_ids"</span> <!-- -->: <!-- -->[ <span class="lg-highlight-number">4</span>, <span class="lg-highlight-number">7</span>, <span class="lg-highlight-number">3</span>, <span class="lg-highlight-number">2</span>, <span class="lg-highlight-number">9</span>, <span class="lg-highlight-number">1</span>, <span class="lg-highlight-number">10</span> ] }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-string">"carrots"</span>, <span class="lg-highlight-string">"qty"</span> <!-- -->: <span class="lg-highlight-number">15</span>, <span class="lg-highlight-string">"orders_ids"</span> <!-- -->: <!-- -->[ <span class="lg-highlight-number">6</span>, <span class="lg-highlight-number">9</span> ] }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-string">"apples"</span>, <span class="lg-highlight-string">"qty"</span> <!-- -->: <span class="lg-highlight-number">35</span>, <span class="lg-highlight-string">"orders_ids"</span> <!-- -->: <!-- -->[ <span class="lg-highlight-number">9</span>, <span class="lg-highlight-number">8</span>, <span class="lg-highlight-number">1</span>, <span class="lg-highlight-number">6</span> ] }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-string">"pears"</span>, <span class="lg-highlight-string">"qty"</span> <!-- -->: <span class="lg-highlight-number">10</span>, <span class="lg-highlight-string">"orders_ids"</span> <!-- -->: <!-- -->[ <span class="lg-highlight-number">3</span> ] }</td></tr></tbody></table></code></pre> </div> </div> </div> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> The <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 reshapes the output document to mirror the map-reduce's output to have two fields <code class="leafygreen-ui-1l06pbn"> _id </code> and <code class="leafygreen-ui-1l06pbn"> value </code> . The <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/project/#mongodb-pipeline-pipe.-project"> <code class="leafygreen-ui-1l06pbn"> $project </code> </a> sets: </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> The <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/unwind/#mongodb-pipeline-pipe.-unwind"> <code class="leafygreen-ui-1l06pbn"> $unwind </code> </a> stage breaks down the document by the <code class="leafygreen-ui-1l06pbn"> items </code> array field to output a document for each array element. For example: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ \"_id\" : 1, \"cust_id\" : \"Ant O. Knee\", \"ord_date\" : ISODate(\"2020-03-01T00:00:00Z\"), \"price\" : 25, \"items\" : { \"sku\" : \"oranges\", \"qty\" : 5, \"price\" : 2.5 }, \"status\" : \"A\" }\n{ \"_id\" : 1, \"cust_id\" : \"Ant O. Knee\", \"ord_date\" : ISODate(\"2020-03-01T00:00:00Z\"), \"price\" : 25, \"items\" : { \"sku\" : \"apples\", \"qty\" : 5, \"price\" : 2.5 }, \"status\" : \"A\" }\n{ \"_id\" : 2, \"cust_id\" : \"Ant O. Knee\", \"ord_date\" : ISODate(\"2020-03-08T00:00:00Z\"), \"price\" : 70, \"items\" : { \"sku\" : \"oranges\", \"qty\" : 8, \"price\" : 2.5 }, \"status\" : \"A\" }\n{ \"_id\" : 2, \"cust_id\" : \"Ant O. Knee\", \"ord_date\" : ISODate(\"2020-03-08T00:00:00Z\"), \"price\" : 70, \"items\" : { \"sku\" : \"chocolates\", \"qty\" : 5, \"price\" : 10 }, \"status\" : \"A\" }\n{ \"_id\" : 3, \"cust_id\" : \"Busby Bee\", \"ord_date\" : ISODate(\"2020-03-08T00:00:00Z\"), \"price\" : 50, \"items\" : { \"sku\" : \"oranges\", \"qty\" : 10, \"price\" : 2.5 }, \"status\" : \"A\" }\n{ \"_id\" : 3, \"cust_id\" : \"Busby Bee\", \"ord_date\" : ISODate(\"2020-03-08T00:00:00Z\"), \"price\" : 50, \"items\" : { \"sku\" : \"pears\", \"qty\" : 10, \"price\" : 2.5 }, \"status\" : \"A\" }\n{ \"_id\" : 4, \"cust_id\" : \"Busby Bee\", \"ord_date\" : ISODate(\"2020-03-18T00:00:00Z\"), \"price\" : 25, \"items\" : { \"sku\" : \"oranges\", \"qty\" : 10, \"price\" : 2.5 }, \"status\" : \"A\" }\n{ \"_id\" : 5, \"cust_id\" : \"Busby Bee\", \"ord_date\" : ISODate(\"2020-03-19T00:00:00Z\"), \"price\" : 50, \"items\" : { \"sku\" : \"chocolates\", \"qty\" : 5, \"price\" : 10 }, \"status\" : \"A\" }\n...","programmingLanguage":"JavaScript"} </script> <div class="css-1lju8ps"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-tyg50d"> <pre class="leafygreen-ui-1453az5" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">1</span>, <span class="lg-highlight-string">"cust_id"</span> <!-- -->: <span class="lg-highlight-string">"Ant O. Knee"</span>, <span class="lg-highlight-string">"ord_date"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">ISODate</span>(<span class="lg-highlight-string">"2020-03-01T00:00:00Z"</span>)<!-- -->, <span class="lg-highlight-string">"price"</span> <!-- -->: <span class="lg-highlight-number">25</span>, <span class="lg-highlight-string">"items"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-string">"sku"</span> <!-- -->: <span class="lg-highlight-string">"oranges"</span>, <span class="lg-highlight-string">"qty"</span> <!-- -->: <span class="lg-highlight-number">5</span>, <span class="lg-highlight-string">"price"</span> <!-- -->: <span class="lg-highlight-number">2.5</span> }<!-- -->, <span class="lg-highlight-string">"status"</span> <!-- -->: <span class="lg-highlight-string">"A"</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">1</span>, <span class="lg-highlight-string">"cust_id"</span> <!-- -->: <span class="lg-highlight-string">"Ant O. Knee"</span>, <span class="lg-highlight-string">"ord_date"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">ISODate</span>(<span class="lg-highlight-string">"2020-03-01T00:00:00Z"</span>)<!-- -->, <span class="lg-highlight-string">"price"</span> <!-- -->: <span class="lg-highlight-number">25</span>, <span class="lg-highlight-string">"items"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-string">"sku"</span> <!-- -->: <span class="lg-highlight-string">"apples"</span>, <span class="lg-highlight-string">"qty"</span> <!-- -->: <span class="lg-highlight-number">5</span>, <span class="lg-highlight-string">"price"</span> <!-- -->: <span class="lg-highlight-number">2.5</span> }<!-- -->, <span class="lg-highlight-string">"status"</span> <!-- -->: <span class="lg-highlight-string">"A"</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">2</span>, <span class="lg-highlight-string">"cust_id"</span> <!-- -->: <span class="lg-highlight-string">"Ant O. Knee"</span>, <span class="lg-highlight-string">"ord_date"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">ISODate</span>(<span class="lg-highlight-string">"2020-03-08T00:00:00Z"</span>)<!-- -->, <span class="lg-highlight-string">"price"</span> <!-- -->: <span class="lg-highlight-number">70</span>, <span class="lg-highlight-string">"items"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-string">"sku"</span> <!-- -->: <span class="lg-highlight-string">"oranges"</span>, <span class="lg-highlight-string">"qty"</span> <!-- -->: <span class="lg-highlight-number">8</span>, <span class="lg-highlight-string">"price"</span> <!-- -->: <span class="lg-highlight-number">2.5</span> }<!-- -->, <span class="lg-highlight-string">"status"</span> <!-- -->: <span class="lg-highlight-string">"A"</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">2</span>, <span class="lg-highlight-string">"cust_id"</span> <!-- -->: <span class="lg-highlight-string">"Ant O. Knee"</span>, <span class="lg-highlight-string">"ord_date"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">ISODate</span>(<span class="lg-highlight-string">"2020-03-08T00:00:00Z"</span>)<!-- -->, <span class="lg-highlight-string">"price"</span> <!-- -->: <span class="lg-highlight-number">70</span>, <span class="lg-highlight-string">"items"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-string">"sku"</span> <!-- -->: <span class="lg-highlight-string">"chocolates"</span>, <span class="lg-highlight-string">"qty"</span> <!-- -->: <span class="lg-highlight-number">5</span>, <span class="lg-highlight-string">"price"</span> <!-- -->: <span class="lg-highlight-number">10</span> }<!-- -->, <span class="lg-highlight-string">"status"</span> <!-- -->: <span class="lg-highlight-string">"A"</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">3</span>, <span class="lg-highlight-string">"cust_id"</span> <!-- -->: <span class="lg-highlight-string">"Busby Bee"</span>, <span class="lg-highlight-string">"ord_date"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">ISODate</span>(<span class="lg-highlight-string">"2020-03-08T00:00:00Z"</span>)<!-- -->, <span class="lg-highlight-string">"price"</span> <!-- -->: <span class="lg-highlight-number">50</span>, <span class="lg-highlight-string">"items"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-string">"sku"</span> <!-- -->: <span class="lg-highlight-string">"oranges"</span>, <span class="lg-highlight-string">"qty"</span> <!-- -->: <span class="lg-highlight-number">10</span>, <span class="lg-highlight-string">"price"</span> <!-- -->: <span class="lg-highlight-number">2.5</span> }<!-- -->, <span class="lg-highlight-string">"status"</span> <!-- -->: <span class="lg-highlight-string">"A"</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">3</span>, <span class="lg-highlight-string">"cust_id"</span> <!-- -->: <span class="lg-highlight-string">"Busby Bee"</span>, <span class="lg-highlight-string">"ord_date"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">ISODate</span>(<span class="lg-highlight-string">"2020-03-08T00:00:00Z"</span>)<!-- -->, <span class="lg-highlight-string">"price"</span> <!-- -->: <span class="lg-highlight-number">50</span>, <span class="lg-highlight-string">"items"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-string">"sku"</span> <!-- -->: <span class="lg-highlight-string">"pears"</span>, <span class="lg-highlight-string">"qty"</span> <!-- -->: <span class="lg-highlight-number">10</span>, <span class="lg-highlight-string">"price"</span> <!-- -->: <span class="lg-highlight-number">2.5</span> }<!-- -->, <span class="lg-highlight-string">"status"</span> <!-- -->: <span class="lg-highlight-string">"A"</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">4</span>, <span class="lg-highlight-string">"cust_id"</span> <!-- -->: <span class="lg-highlight-string">"Busby Bee"</span>, <span class="lg-highlight-string">"ord_date"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">ISODate</span>(<span class="lg-highlight-string">"2020-03-18T00:00:00Z"</span>)<!-- -->, <span class="lg-highlight-string">"price"</span> <!-- -->: <span class="lg-highlight-number">25</span>, <span class="lg-highlight-string">"items"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-string">"sku"</span> <!-- -->: <span class="lg-highlight-string">"oranges"</span>, <span class="lg-highlight-string">"qty"</span> <!-- -->: <span class="lg-highlight-number">10</span>, <span class="lg-highlight-string">"price"</span> <!-- -->: <span class="lg-highlight-number">2.5</span> }<!-- -->, <span class="lg-highlight-string">"status"</span> <!-- -->: <span class="lg-highlight-string">"A"</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">5</span>, <span class="lg-highlight-string">"cust_id"</span> <!-- -->: <span class="lg-highlight-string">"Busby Bee"</span>, <span class="lg-highlight-string">"ord_date"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">ISODate</span>(<span class="lg-highlight-string">"2020-03-19T00:00:00Z"</span>)<!-- -->, <span class="lg-highlight-string">"price"</span> <!-- -->: <span class="lg-highlight-number">50</span>, <span class="lg-highlight-string">"items"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-string">"sku"</span> <!-- -->: <span class="lg-highlight-string">"chocolates"</span>, <span class="lg-highlight-string">"qty"</span> <!-- -->: <span class="lg-highlight-number">5</span>, <span class="lg-highlight-string">"price"</span> <!-- -->: <span class="lg-highlight-number">10</span> }<!-- -->, <span class="lg-highlight-string">"status"</span> <!-- -->: <span class="lg-highlight-string">"A"</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">...</td></tr></tbody></table></code></pre> </div> </div> </div> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> The <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/group/#mongodb-pipeline-pipe.-group"> <code class="leafygreen-ui-1l06pbn"> $group </code> </a> stage groups by the <code class="leafygreen-ui-1l06pbn"> items.sku </code> , calculating for each sku: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> The <code class="leafygreen-ui-1l06pbn"> qty </code> field. The <code class="leafygreen-ui-1l06pbn"> qty </code> field contains the total <code class="leafygreen-ui-1l06pbn"> qty </code> ordered per each <code class="leafygreen-ui-1l06pbn"> items.sku </code> using <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/sum/#mongodb-group-grp.-sum"> <code class="leafygreen-ui-1l06pbn"> $sum </code> . </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> The <code class="leafygreen-ui-1l06pbn"> orders_ids </code> array. The <code class="leafygreen-ui-1l06pbn"> orders_ids </code> field contains an array of distinct order <code class="leafygreen-ui-1l06pbn"> _id </code> 's for the <code class="leafygreen-ui-1l06pbn"> items.sku </code> using <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/addToSet/#mongodb-group-grp.-addToSet"> <code class="leafygreen-ui-1l06pbn"> $addToSet </code> . </a> </p> </li> </ul> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ \"_id\" : \"chocolates\", \"qty\" : 15, \"orders_ids\" : [ 2, 5, 8 ] }\n{ \"_id\" : \"oranges\", \"qty\" : 63, \"orders_ids\" : [ 4, 7, 3, 2, 9, 1, 10 ] }\n{ \"_id\" : \"carrots\", \"qty\" : 15, \"orders_ids\" : [ 6, 9 ] }\n{ \"_id\" : \"apples\", \"qty\" : 35, \"orders_ids\" : [ 9, 8, 1, 6 ] }\n{ \"_id\" : \"pears\", \"qty\" : 10, \"orders_ids\" : [ 3 ] }","programmingLanguage":"JavaScript"} </script> <div class="css-1lju8ps"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-tyg50d"> <pre class="leafygreen-ui-1453az5" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-string">"chocolates"</span>, <span class="lg-highlight-string">"qty"</span> <!-- -->: <span class="lg-highlight-number">15</span>, <span class="lg-highlight-string">"orders_ids"</span> <!-- -->: <!-- -->[ <span class="lg-highlight-number">2</span>, <span class="lg-highlight-number">5</span>, <span class="lg-highlight-number">8</span> ] }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-string">"oranges"</span>, <span class="lg-highlight-string">"qty"</span> <!-- -->: <span class="lg-highlight-number">63</span>, <span class="lg-highlight-string">"orders_ids"</span> <!-- -->: <!-- -->[ <span class="lg-highlight-number">4</span>, <span class="lg-highlight-number">7</span>, <span class="lg-highlight-number">3</span>, <span class="lg-highlight-number">2</span>, <span class="lg-highlight-number">9</span>, <span class="lg-highlight-number">1</span>, <span class="lg-highlight-number">10</span> ] }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-string">"carrots"</span>, <span class="lg-highlight-string">"qty"</span> <!-- -->: <span class="lg-highlight-number">15</span>, <span class="lg-highlight-string">"orders_ids"</span> <!-- -->: <!-- -->[ <span class="lg-highlight-number">6</span>, <span class="lg-highlight-number">9</span> ] }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-string">"apples"</span>, <span class="lg-highlight-string">"qty"</span> <!-- -->: <span class="lg-highlight-number">35</span>, <span class="lg-highlight-string">"orders_ids"</span> <!-- -->: <!-- -->[ <span class="lg-highlight-number">9</span>, <span class="lg-highlight-number">8</span>, <span class="lg-highlight-number">1</span>, <span class="lg-highlight-number">6</span> ] }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-string">"pears"</span>, <span class="lg-highlight-string">"qty"</span> <!-- -->: <span class="lg-highlight-number">10</span>, <span class="lg-highlight-string">"orders_ids"</span> <!-- -->: <!-- -->[ <span class="lg-highlight-number">3</span> ] }</td></tr></tbody></table></code></pre> </div> </div> </div> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> The <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 reshapes the output document to mirror the map-reduce's output to have two fields <code class="leafygreen-ui-1l06pbn"> _id </code> and <code class="leafygreen-ui-1l06pbn"> value </code> . The <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/project/#mongodb-pipeline-pipe.-project"> <code class="leafygreen-ui-1l06pbn"> $project </code> </a> sets: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> the <code class="leafygreen-ui-1l06pbn"> value.count </code> to the size of the <code class="leafygreen-ui-1l06pbn"> orders_ids </code> array using <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/size/#mongodb-expression-exp.-size"> <code class="leafygreen-ui-1l06pbn"> $size </code> . </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> the <code class="leafygreen-ui-1l06pbn"> value.qty </code> to the <code class="leafygreen-ui-1l06pbn"> qty </code> field of input document. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> the <code class="leafygreen-ui-1l06pbn"> value.avg </code> to the average number of qty per order using <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/divide/#mongodb-expression-exp.-divide"> <code class="leafygreen-ui-1l06pbn"> $divide </code> </a> and <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/size/#mongodb-expression-exp.-size"> <code class="leafygreen-ui-1l06pbn"> $size </code> . </a> </p> </li> </ul> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ \"_id\" : \"apples\", \"value\" : { \"count\" : 4, \"qty\" : 35, \"avg\" : 8.75 } }\n{ \"_id\" : \"pears\", \"value\" : { \"count\" : 1, \"qty\" : 10, \"avg\" : 10 } }\n{ \"_id\" : \"chocolates\", \"value\" : { \"count\" : 3, \"qty\" : 15, \"avg\" : 5 } }\n{ \"_id\" : \"oranges\", \"value\" : { \"count\" : 7, \"qty\" : 63, \"avg\" : 9 } }\n{ \"_id\" : \"carrots\", \"value\" : { \"count\" : 2, \"qty\" : 15, \"avg\" : 7.5 } }","programmingLanguage":"JavaScript"} </script> <div class="css-1lju8ps"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-tyg50d"> <pre class="leafygreen-ui-1453az5" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-string">"apples"</span>, <span class="lg-highlight-string">"value"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-string">"count"</span> <!-- -->: <span class="lg-highlight-number">4</span>, <span class="lg-highlight-string">"qty"</span> <!-- -->: <span class="lg-highlight-number">35</span>, <span class="lg-highlight-string">"avg"</span> <!-- -->: <span class="lg-highlight-number">8.75</span> } }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-string">"pears"</span>, <span class="lg-highlight-string">"value"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-string">"count"</span> <!-- -->: <span class="lg-highlight-number">1</span>, <span class="lg-highlight-string">"qty"</span> <!-- -->: <span class="lg-highlight-number">10</span>, <span class="lg-highlight-string">"avg"</span> <!-- -->: <span class="lg-highlight-number">10</span> } }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-string">"chocolates"</span>, <span class="lg-highlight-string">"value"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-string">"count"</span> <!-- -->: <span class="lg-highlight-number">3</span>, <span class="lg-highlight-string">"qty"</span> <!-- -->: <span class="lg-highlight-number">15</span>, <span class="lg-highlight-string">"avg"</span> <!-- -->: <span class="lg-highlight-number">5</span> } }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-string">"oranges"</span>, <span class="lg-highlight-string">"value"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-string">"count"</span> <!-- -->: <span class="lg-highlight-number">7</span>, <span class="lg-highlight-string">"qty"</span> <!-- -->: <span class="lg-highlight-number">63</span>, <span class="lg-highlight-string">"avg"</span> <!-- -->: <span class="lg-highlight-number">9</span> } }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-string">"carrots"</span>, <span class="lg-highlight-string">"value"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-string">"count"</span> <!-- -->: <span class="lg-highlight-number">2</span>, <span class="lg-highlight-string">"qty"</span> <!-- -->: <span class="lg-highlight-number">15</span>, <span class="lg-highlight-string">"avg"</span> <!-- -->: <span class="lg-highlight-number">7.5</span> } }</td></tr></tbody></table></code></pre> </div> </div> </div> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Finally, 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> writes the output to the collection <code class="leafygreen-ui-1l06pbn"> agg_alternative_3 </code> . If an existing document has the same key <code class="leafygreen-ui-1l06pbn"> _id </code> as the new result, the operation overwrites the existing document. If there is no existing document with the same key, the operation inserts the document. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Query the <code class="leafygreen-ui-1l06pbn"> agg_alternative_3 </code> collection to verify the results: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.agg_alternative_3.find().sort( { _id: 1 } )","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">agg_alternative_3</span>.<span class="lg-highlight-title lg-highlight-function">find</span>(<!-- -->).<span class="lg-highlight-title lg-highlight-function">sort</span>( <!-- -->{ <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">1</span> } )</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 operation returns the following documents: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ \"_id\" : \"apples\", \"value\" : { \"count\" : 4, \"qty\" : 35, \"avg\" : 8.75 } }\n{ \"_id\" : \"carrots\", \"value\" : { \"count\" : 2, \"qty\" : 15, \"avg\" : 7.5 } }\n{ \"_id\" : \"chocolates\", \"value\" : { \"count\" : 3, \"qty\" : 15, \"avg\" : 5 } }\n{ \"_id\" : \"oranges\", \"value\" : { \"count\" : 7, \"qty\" : 63, \"avg\" : 9 } }\n{ \"_id\" : \"pears\", \"value\" : { \"count\" : 1, \"qty\" : 10, \"avg\" : 10 } }","programmingLanguage":"JavaScript"} </script> <div class="css-1lju8ps"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-tyg50d"> <pre class="leafygreen-ui-1453az5" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-string">"apples"</span>, <span class="lg-highlight-string">"value"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-string">"count"</span> <!-- -->: <span class="lg-highlight-number">4</span>, <span class="lg-highlight-string">"qty"</span> <!-- -->: <span class="lg-highlight-number">35</span>, <span class="lg-highlight-string">"avg"</span> <!-- -->: <span class="lg-highlight-number">8.75</span> } }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-string">"carrots"</span>, <span class="lg-highlight-string">"value"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-string">"count"</span> <!-- -->: <span class="lg-highlight-number">2</span>, <span class="lg-highlight-string">"qty"</span> <!-- -->: <span class="lg-highlight-number">15</span>, <span class="lg-highlight-string">"avg"</span> <!-- -->: <span class="lg-highlight-number">7.5</span> } }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-string">"chocolates"</span>, <span class="lg-highlight-string">"value"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-string">"count"</span> <!-- -->: <span class="lg-highlight-number">3</span>, <span class="lg-highlight-string">"qty"</span> <!-- -->: <span class="lg-highlight-number">15</span>, <span class="lg-highlight-string">"avg"</span> <!-- -->: <span class="lg-highlight-number">5</span> } }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-string">"oranges"</span>, <span class="lg-highlight-string">"value"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-string">"count"</span> <!-- -->: <span class="lg-highlight-number">7</span>, <span class="lg-highlight-string">"qty"</span> <!-- -->: <span class="lg-highlight-number">63</span>, <span class="lg-highlight-string">"avg"</span> <!-- -->: <span class="lg-highlight-number">9</span> } }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-string">"pears"</span>, <span class="lg-highlight-string">"value"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-string">"count"</span> <!-- -->: <span class="lg-highlight-number">1</span>, <span class="lg-highlight-string">"qty"</span> <!-- -->: <span class="lg-highlight-number">10</span>, <span class="lg-highlight-string">"avg"</span> <!-- -->: <span class="lg-highlight-number">10</span> } }</td></tr></tbody></table></code></pre> </div> </div> </div> </li> </ol> <div class="leafygreen-ui-13vw3ie" role="note"> <h2 class="leafygreen-ui-1fn4p2b"> Tip </h2> <h3 class="leafygreen-ui-144d5kf"> <strong> See also: </strong> </h3> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> For an alternative that uses custom aggregation expressions, see <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/map-reduce-to-aggregation-pipeline/#std-label-mr-to-agg-examples2"> Map-Reduce to Aggregation Pipeline Translation Examples <!-- --> . </a> </p> </div> </div> </section> </section> </section> <div class="leafygreen-ui-13vw3ie" role="note"> <h2 class="leafygreen-ui-1fn4p2b"> Tip </h2> <h3 class="leafygreen-ui-144d5kf"> <strong> See also: </strong> </h3> <div class="leafygreen-ui-9mycqc"> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/tutorial/perform-incremental-map-reduce/"> Perform Incremental Map-Reduce </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/map-reduce-to-aggregation-pipeline/"> Map-Reduce to Aggregation Pipeline </a> </p> </li> </ul> </div> </div> </section>
https://www.mongodb.com/docs/manual/reference/method/cursor.isExhausted/
<section> <h1 class="contains-headerlink leafygreen-ui-41fr9s" weight="medium"> cursor.isExhausted() <a class="headerlink leafygreen-ui-1kepx47" href="#cursor.isexhausted--" 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="cursor.isexhausted--"> </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="#behavior" target="_self"> <span> Behavior </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#examples" target="_self"> <span> Examples </span> </a> </li> </ul> </div> <dl class="method"> <dt> <code class="leafygreen-ui-1l06pbn"> cursor.isExhausted() </code> <a class="headerlink leafygreen-ui-1kepx47" href="#mongodb-method-cursor.isExhausted" title="Permalink to this definition"> <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="mongodb-method-cursor.isExhausted"> </div> </a> </dt> <dd> <div class="leafygreen-ui-85da11" role="note"> <h2 class="leafygreen-ui-1ac4g5h"> Important </h2> <h3 class="leafygreen-ui-144d5kf"> <strong> mongosh Method </strong> </h3> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> This page documents a <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/mongodb-shell/#mongodb-binary-bin.mongosh" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongosh </code> </span> </a> method. This is <em> not </em> the documentation for a language-specific driver, such as Node.js. </p> <p class="leafygreen-ui-1kp3ins"> For MongoDB API drivers, refer to the language-specific <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/drivers/" target="_self"> <span> MongoDB driver documentation <!-- --> . </span> </a> </p> </div> </div> <table class="css-11h39yh e1nex8bq0"> <colgroup> <col class="field-name"/> <col class="field-body"/> </colgroup> <tbody> <tr class="css-x8snli"> <th> Returns <!-- --> : </th> <td> Boolean </td> </tr> </tbody> </table> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-method-cursor.isExhausted" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> cursor.isExhausted() </code> </span> </a> returns <code class="leafygreen-ui-1l06pbn"> false </code> if documents remain in the current document batch read by the cursor. Otherwise, returns <code class="leafygreen-ui-1l06pbn"> true </code> . </p> </dd> </dl> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Behavior <a class="headerlink leafygreen-ui-1kepx47" href="#behavior" 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="behavior"> </div> </a> </h2> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Tailable Cursors <a class="headerlink leafygreen-ui-1kepx47" href="#tailable-cursors" 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="tailable-cursors"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> You can use <code class="leafygreen-ui-1l06pbn"> isExhausted() </code> with a <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/tailable-cursors/#std-label-tailable-cursors-landing-page"> tailable cursor </a> . A tailable cursor stays open even if no documents remain in the current batch. Other cursors are automatically closed when no documents remain. </p> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Change Streams <a class="headerlink leafygreen-ui-1kepx47" href="#change-streams" 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="change-streams"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> You cannot use <code class="leafygreen-ui-1l06pbn"> isExhausted() </code> with <a class="leafygreen-ui-tqgtui" href="/docs/manual/changeStreams/#std-label-changeStreams"> change streams </a> . Instead, to examine if: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> documents remain in a change stream cursor, use <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/cursor.tryNext/#mongodb-method-cursor.tryNext"> <code class="leafygreen-ui-1l06pbn"> cursor.tryNext() </code> . </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> a change stream cursor is closed, use <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/cursor.isClosed/#mongodb-method-cursor.isClosed"> <code class="leafygreen-ui-1l06pbn"> cursor.isClosed() </code> . </a> </p> </li> </ul> <p class="leafygreen-ui-1kp3ins"> For change stream examples, see <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/db.watch/#std-label-db.watch-example"> Watch Example </a> and <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/db.collection.watch/#std-label-db.collection.watch-change-streams-pre-and-post-images-example"> Change Stream Images Example <!-- --> . </a> </p> </section> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Examples <a class="headerlink leafygreen-ui-1kepx47" href="#examples" 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="examples"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> This section contains examples that use a cursor to read documents from a collection with temperature readings from a weather sensor. You'll see examples of <code class="leafygreen-ui-1l06pbn"> isExhausted() </code> . </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"HowTo","steps":[{"@type":"HowToStep","text":"Run:","name":"Create the collection"},{"@type":"HowToStep","text":"Create a cursor variable named sensorCursor that reads the\ndocuments from the sensor collection:","name":"Create a cursor variable"},{"@type":"HowToStep","text":"Run:The output is 2 because there are two documents in the\ncollection.","name":"Count the number of documents in the cursor"},{"@type":"HowToStep","text":"Run:Output:","name":"Return the first document from the cursor"},{"@type":"HowToStep","text":"Run:The output is false because there is a remaining document\nin sensorCursor.","name":"Examine the isExhausted() value"},{"@type":"HowToStep","text":"Run:Output:","name":"Return the next document from the cursor"},{"@type":"HowToStep","text":"Run:There are no more documents and the example returns null.","name":"Attempt to return the next document from the cursor"},{"@type":"HowToStep","text":"Run:There are no more documents and isExhausted() returns\ntrue.","name":"Examine the isExhausted() value"}],"name":"Examples","image":"https://webimages.mongodb.com/_com_assets/cms/kuyj2focmkbxv7gh3-stacked_default_slate_blue.svg?auto=format%252Ccompress"} </script> <div class="css-4nyere eccljxs0"> <div class="css-1nuklj8 e1ckbxcu1"> <div class="css-18fui5z e1ckbxcu0"> <div class="css-19lsqsq e1ckbxcu2"> 1 </div> </div> <div class="css-1ed38mk"> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Create the collection <a class="headerlink leafygreen-ui-1kepx47" href="#create-the-collection" 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="create-the-collection"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> Run: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.sensor.insertMany( [\n { _id: 0, temperature: 12 },\n { _id: 1, temperature: 23 }\n] )","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">sensor</span>.<span class="lg-highlight-title lg-highlight-function">insertMany</span>( <!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">0</span>, <span class="lg-highlight-attr">temperature</span>: <span class="lg-highlight-number">12</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">1</span>, <span class="lg-highlight-attr">temperature</span>: <span class="lg-highlight-number">23</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">] )</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> </section> </div> </div> <div class="css-1nuklj8 e1ckbxcu1"> <div class="css-18fui5z e1ckbxcu0"> <div class="css-19lsqsq e1ckbxcu2"> 2 </div> </div> <div class="css-1ed38mk"> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Create a cursor variable <a class="headerlink leafygreen-ui-1kepx47" href="#create-a-cursor-variable" 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="create-a-cursor-variable"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> Create a cursor variable named <code class="leafygreen-ui-1l06pbn"> sensorCursor </code> that reads the documents from the <code class="leafygreen-ui-1l06pbn"> sensor </code> collection: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"var sensorCursor = db.sensor.find()","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"><span class="lg-highlight-keyword">var</span> sensorCursor <!-- -->= <!-- -->db.<span class="lg-highlight-property">sensor</span>.<span class="lg-highlight-title lg-highlight-function">find</span>(<!-- -->)</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> </section> </div> </div> <div class="css-1nuklj8 e1ckbxcu1"> <div class="css-18fui5z e1ckbxcu0"> <div class="css-19lsqsq e1ckbxcu2"> 3 </div> </div> <div class="css-1ed38mk"> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Count the number of documents in the cursor <a class="headerlink leafygreen-ui-1kepx47" href="#count-the-number-of-documents-in-the-cursor" 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="count-the-number-of-documents-in-the-cursor"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> Run: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"sensorCursor.count()","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">sensorCursor.<span class="lg-highlight-title lg-highlight-function">count</span>(<!-- -->)</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 output is <code class="leafygreen-ui-1l06pbn"> 2 </code> because there are two documents in the collection. </p> </section> </div> </div> <div class="css-1nuklj8 e1ckbxcu1"> <div class="css-18fui5z e1ckbxcu0"> <div class="css-19lsqsq e1ckbxcu2"> 4 </div> </div> <div class="css-1ed38mk"> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Return the first document from the cursor <a class="headerlink leafygreen-ui-1kepx47" href="#return-the-first-document-from-the-cursor" 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="return-the-first-document-from-the-cursor"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> Run: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"sensorCursor.next()","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">sensorCursor.<span class="lg-highlight-title lg-highlight-function">next</span>(<!-- -->)</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"> Output: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ _id: 0, temperature: 12 }","programmingLanguage":"JavaScript"} </script> <div class="css-1lju8ps"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1jheeh3"> <pre class="leafygreen-ui-1agdxuk" 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">{ <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">0</span>, <span class="lg-highlight-attr">temperature</span>: <span class="lg-highlight-number">12</span> }</td></tr></tbody></table></code></pre> </div> </div> </div> </section> </div> </div> <div class="css-1nuklj8 e1ckbxcu1"> <div class="css-18fui5z e1ckbxcu0"> <div class="css-19lsqsq e1ckbxcu2"> 5 </div> </div> <div class="css-1ed38mk"> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Examine the <code class="leafygreen-ui-1l06pbn"> isExhausted() </code> value <a class="headerlink leafygreen-ui-1kepx47" href="#examine-the-isexhausted---value" 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="examine-the-isexhausted---value"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> Run: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"sensorCursor.isExhausted()","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">sensorCursor.<span class="lg-highlight-title lg-highlight-function">isExhausted</span>(<!-- -->)</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 output is <code class="leafygreen-ui-1l06pbn"> false </code> because there is a remaining document in <code class="leafygreen-ui-1l06pbn"> sensorCursor </code> . </p> </section> </div> </div> <div class="css-1nuklj8 e1ckbxcu1"> <div class="css-18fui5z e1ckbxcu0"> <div class="css-19lsqsq e1ckbxcu2"> 6 </div> </div> <div class="css-1ed38mk"> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Return the next document from the cursor <a class="headerlink leafygreen-ui-1kepx47" href="#return-the-next-document-from-the-cursor" 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="return-the-next-document-from-the-cursor"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> Run: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"sensorCursor.next()","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">sensorCursor.<span class="lg-highlight-title lg-highlight-function">next</span>(<!-- -->)</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"> Output: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ _id: 1, temperature: 23 }","programmingLanguage":"JavaScript"} </script> <div class="css-1lju8ps"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1jheeh3"> <pre class="leafygreen-ui-1agdxuk" 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">{ <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">1</span>, <span class="lg-highlight-attr">temperature</span>: <span class="lg-highlight-number">23</span> }</td></tr></tbody></table></code></pre> </div> </div> </div> </section> </div> </div> <div class="css-1nuklj8 e1ckbxcu1"> <div class="css-18fui5z e1ckbxcu0"> <div class="css-19lsqsq e1ckbxcu2"> 7 </div> </div> <div class="css-1ed38mk"> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Attempt to return the next document from the cursor <a class="headerlink leafygreen-ui-1kepx47" href="#attempt-to-return-the-next-document-from-the-cursor" 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="attempt-to-return-the-next-document-from-the-cursor"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> Run: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"sensorCursor.next()","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">sensorCursor.<span class="lg-highlight-title lg-highlight-function">next</span>(<!-- -->)</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"> There are no more documents and the example returns <code class="leafygreen-ui-1l06pbn"> null </code> . </p> </section> </div> </div> <div class="css-1nuklj8 e1ckbxcu1"> <div class="css-18fui5z e1ckbxcu0"> <div class="css-19lsqsq e1ckbxcu2"> 8 </div> </div> <div class="css-1ed38mk"> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Examine the <code class="leafygreen-ui-1l06pbn"> isExhausted() </code> value <a class="headerlink leafygreen-ui-1kepx47" href="#examine-the-isexhausted---value-1" 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="examine-the-isexhausted---value-1"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> Run: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"sensorCursor.isExhausted()","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">sensorCursor.<span class="lg-highlight-title lg-highlight-function">isExhausted</span>(<!-- -->)</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"> There are no more documents and <code class="leafygreen-ui-1l06pbn"> isExhausted() </code> returns <code class="leafygreen-ui-1l06pbn"> true </code> . </p> </section> </div> </div> </div> </section> </section>
https://www.mongodb.com/docs/manual/tutorial/configure-scram-client-authentication/
<section> <h1 class="contains-headerlink leafygreen-ui-41fr9s" weight="medium"> Use SCRAM to Authenticate Clients on Self-Managed Deployments <a class="headerlink leafygreen-ui-1kepx47" href="#use-scram-to-authenticate-clients-on-self-managed-deployments" 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="use-scram-to-authenticate-clients-on-self-managed-deployments"> </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="#procedure" target="_self"> <span> Procedure </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#next-steps" target="_self"> <span> Next Steps </span> </a> </li> </ul> </div> <p class="leafygreen-ui-1kp3ins"> The following procedure sets up SCRAM for client authentication on a standalone <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> instance. </p> <p class="leafygreen-ui-1kp3ins"> To use SCRAM authentication for replica sets or sharded clusters, see <a class="leafygreen-ui-tqgtui" href="/docs/manual/tutorial/deploy-replica-set-with-keyfile-access-control/"> Deploy Self-Managed Replica Set With Keyfile Authentication <!-- --> . </a> </p> <span class="leafygreen-ui-1qnjd6d" id="std-label-enable-auth-procedure"> </span> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Procedure <a class="headerlink leafygreen-ui-1kepx47" href="#procedure" 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="procedure"> </div> </a> </h2> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"HowTo","steps":[{"@type":"HowToStep","text":"Start MongoDB without access controlStart a standalone mongod instance without access\ncontrol.Open a terminal and run the following command as the mongod user:The mongod instance in this tutorial uses\nport 27017 and the /var/lib/mongodb\ndata directory.The tutorial assumes that the /var/lib/mongodb directory exists\nand is the default dbPath. You may specify a\ndifferent data directory or port as needed.When mongod starts, it creates some system files in the\n/var/lib/mongodb directory. To ensure the system files have\nthe correct ownership, follow this tutorial as the mongod\nuser. If you start mongod as the root user you will\nhave to update file ownership later."},{"@type":"HowToStep","text":"Connect to the instanceOpen a new terminal and connect to the cluster with\nmongosh:If you are connecting to a different deployment, specify additional\ncommand line options, such as --host, as\nneeded to connect."},{"@type":"HowToStep","text":"Create the user administratorYou can create the user administrator either before or after\nenabling access control. If you enable access control before\ncreating any user, MongoDB provides a localhost exception which allows you to create a user\nadministrator in the admin database. Once created, you must\nauthenticate as the user administrator to create additional users.Using mongosh:switch to the admin databaseadd the myUserAdmin user with the\nuserAdminAnyDatabase and\nreadWriteAnyDatabase roles\":The passwordPrompt() method prompts you to enter the\npassword. You can also specify your password directly as a string. We\nrecommend to use the passwordPrompt() method to avoid the\npassword being visible on your screen and potentially leaking the\npassword to your shell history.The userAdminAnyDatabase role allows this user to:create usersgrant or revoke roles from userscreate or modify customs rolesYou can assign your user additional built-in roles or user-defined roles\nas needed.The database where you create the user, in this example admin,\nis the user's authentication database. Although the user needs to\nauthenticate to this database, the user can have roles in other\ndatabases. The user's authentication database doesn't limit the\nuser's privileges."},{"@type":"HowToStep","text":"Re-start the MongoDB instance with access controlShut down the mongod instance. Using\nmongosh, issue the following command:Exit mongosh.Start the mongod with access control enabled.If you start the mongod from the command line, add\nthe --auth command line option:If you start the mongod using a\nconfiguration file, add the\nsecurity.authorization configuration file setting:Clients that connect to this instance must now authenticate\nthemselves and can only perform actions as determined by their\nassigned roles.You can create users either before or after enabling access\ncontrol. If you enable access control before creating any user,\nMongoDB provides a localhost exception which allows you to create a user\nadministrator in the admin database. Once created, you must\nauthenticate as the user administrator to create additional users."},{"@type":"HowToStep","text":"Connect and authenticate as the user administratorUsing mongosh, you can:Start mongosh with the -u\n<username>, -p, and the\n--authenticationDatabase <database> command line options:Enter your password when prompted.Using mongosh, connect to your database\ndeployment:In mongosh, switch to the\nauthentication database (in this case, admin), and\nuse the db.auth(<username>, <pwd>) method to authenticate:The passwordPrompt() method prompts you to enter the\npassword. You can also specify your password directly as a string. We\nrecommend to use the passwordPrompt() method to avoid the\npassword being visible on your screen and potentially leaking the\npassword to your shell history.Enter the password when prompted."}],"name":"Procedure","image":"https://webimages.mongodb.com/_com_assets/cms/kuyj2focmkbxv7gh3-stacked_default_slate_blue.svg?auto=format%252Ccompress"} </script> <div class="css-4nyere eccljxs0"> <div class="css-1nuklj8 e1ckbxcu1"> <div class="css-18fui5z e1ckbxcu0"> <div class="css-19lsqsq e1ckbxcu2"> 1 </div> </div> <div class="css-1ed38mk"> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Start MongoDB without access control <a class="headerlink leafygreen-ui-1kepx47" href="#start-mongodb-without-access-control" 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="start-mongodb-without-access-control"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> Start a standalone <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> instance without access control. </p> <p class="leafygreen-ui-1kp3ins"> Open a terminal and run the following command as the <code class="leafygreen-ui-1l06pbn"> mongod </code> user: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"mongod --port 27017 --dbpath /var/lib/mongodb\n","programmingLanguage":"Shell"} </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 shell leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">mongod --port 27017 --dbpath /var/lib/mongodb</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 <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> instance in this tutorial uses <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#std-option-mongod.--port"> <code class="leafygreen-ui-1l06pbn"> port 27017 </code> </a> and the <code class="leafygreen-ui-1l06pbn"> /var/lib/mongodb </code> data directory. </p> <p class="leafygreen-ui-1kp3ins"> The tutorial assumes that the <code class="leafygreen-ui-1l06pbn"> /var/lib/mongodb </code> directory exists and is the default <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/configuration-options/#mongodb-setting-storage.dbPath"> <code class="leafygreen-ui-1l06pbn"> dbPath </code> </a> . You may specify a different data directory or port as needed. </p> <div class="leafygreen-ui-13vw3ie" role="note"> <h2 class="leafygreen-ui-1fn4p2b"> Tip </h2> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> When <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> starts, it creates some system files in the <code class="leafygreen-ui-1l06pbn"> /var/lib/mongodb </code> directory. To ensure the system files have the correct ownership, follow this tutorial as the <code class="leafygreen-ui-1l06pbn"> mongod </code> user. If you start <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> as the <code class="leafygreen-ui-1l06pbn"> root </code> user you will have to update file ownership later. </p> </div> </div> </section> </div> </div> <div class="css-1nuklj8 e1ckbxcu1"> <div class="css-18fui5z e1ckbxcu0"> <div class="css-19lsqsq e1ckbxcu2"> 2 </div> </div> <div class="css-1ed38mk"> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Connect to the instance <a class="headerlink leafygreen-ui-1kepx47" href="#connect-to-the-instance" 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="connect-to-the-instance"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> Open a new terminal and connect to the cluster with <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/mongodb-shell/#mongodb-binary-bin.mongosh" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongosh </code> : </span> </a> </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"mongosh --port 27017\n","programmingLanguage":"Shell"} </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 shell leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">mongosh --port 27017</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"> If you are connecting to a different deployment, specify additional command line options, such as <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/mongodb-shell/reference/options/#std-option-mongosh.--host" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> --host </code> </span> </a> , as needed to connect. </p> </section> </div> </div> <div class="css-1nuklj8 e1ckbxcu1"> <div class="css-18fui5z e1ckbxcu0"> <div class="css-19lsqsq e1ckbxcu2"> 3 </div> </div> <div class="css-1ed38mk"> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Create the user administrator <a class="headerlink leafygreen-ui-1kepx47" href="#create-the-user-administrator" 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="create-the-user-administrator"> </div> </a> </h3> <span class="leafygreen-ui-1qnjd6d" id="std-label-create-user-admin"> </span> <div class="leafygreen-ui-85da11" role="note"> <h2 class="leafygreen-ui-1ac4g5h"> Important </h2> <h3 class="leafygreen-ui-144d5kf"> <strong> Localhost Exception </strong> </h3> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> You can create the user administrator either before or after enabling access control. If you enable access control before creating any user, MongoDB provides a <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/localhost-exception/#std-label-localhost-exception"> localhost exception </a> which allows you to create a user administrator in the <code class="leafygreen-ui-1l06pbn"> admin </code> database. Once created, you must authenticate as the user administrator to create additional users. </p> </div> </div> <p class="leafygreen-ui-1kp3ins"> Using <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/mongodb-shell/#mongodb-binary-bin.mongosh" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongosh </code> : </span> </a> </p> <ol class="leafygreen-ui-rioki0" type="1"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> switch to the <code class="leafygreen-ui-1l06pbn"> admin </code> database </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> add the <code class="leafygreen-ui-1l06pbn"> myUserAdmin </code> user with the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/built-in-roles/#mongodb-authrole-userAdminAnyDatabase"> <code class="leafygreen-ui-1l06pbn"> userAdminAnyDatabase </code> </a> and <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/built-in-roles/#mongodb-authrole-readWriteAnyDatabase"> <code class="leafygreen-ui-1l06pbn"> readWriteAnyDatabase </code> </a> roles": </p> </li> </ol> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"\nuse admin\ndb.createUser(\n {\n user: \"myUserAdmin\",\n pwd: passwordPrompt(), // or cleartext password\n roles: [\n { role: \"userAdminAnyDatabase\", db: \"admin\" },\n { role: \"readWriteAnyDatabase\", db: \"admin\" }\n ]\n }\n)\n","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">use admin</td></tr><tr class=""><td class="leafygreen-ui-7razhx">db.<span class="lg-highlight-title lg-highlight-function">createUser</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">user</span>: <span class="lg-highlight-string">"myUserAdmin"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">pwd</span>: <span class="lg-highlight-title lg-highlight-function">passwordPrompt</span>(<!-- -->)<!-- -->, <span class="lg-highlight-comment">// or cleartext password</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">roles</span>: <!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">role</span>: <span class="lg-highlight-string">"userAdminAnyDatabase"</span>, <span class="lg-highlight-attr">db</span>: <span class="lg-highlight-string">"admin"</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">role</span>: <span class="lg-highlight-string">"readWriteAnyDatabase"</span>, <span class="lg-highlight-attr">db</span>: <span class="lg-highlight-string">"admin"</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> ]</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">)</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-13vw3ie" role="note"> <h2 class="leafygreen-ui-1fn4p2b"> Tip </h2> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> The <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/passwordPrompt/#mongodb-method-passwordPrompt"> <code class="leafygreen-ui-1l06pbn"> passwordPrompt() </code> </a> method prompts you to enter the password. You can also specify your password directly as a string. We recommend to use the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/passwordPrompt/#mongodb-method-passwordPrompt"> <code class="leafygreen-ui-1l06pbn"> passwordPrompt() </code> </a> method to avoid the password being visible on your screen and potentially leaking the password to your shell history. </p> </div> </div> <p class="leafygreen-ui-1kp3ins"> The <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/built-in-roles/#mongodb-authrole-userAdminAnyDatabase"> <code class="leafygreen-ui-1l06pbn"> userAdminAnyDatabase </code> </a> role allows this user to: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> create users </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> grant or revoke roles from users </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> create or modify customs roles </p> </li> </ul> <p class="leafygreen-ui-1kp3ins"> You can assign your user additional <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/built-in-roles/#std-label-built-in-roles"> built-in roles </a> or <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/security-user-defined-roles/#std-label-user-defined-roles"> user-defined roles </a> as needed. </p> <p class="leafygreen-ui-1kp3ins"> The database where you create the user, in this example <code class="leafygreen-ui-1l06pbn"> admin </code> , is the user's <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/security-users/#std-label-user-authentication-database"> authentication database </a> . Although the user needs to authenticate to this database, the user can have roles in other databases. The user's authentication database doesn't limit the user's privileges. </p> </section> </div> </div> <div class="css-1nuklj8 e1ckbxcu1"> <div class="css-18fui5z e1ckbxcu0"> <div class="css-19lsqsq e1ckbxcu2"> 4 </div> </div> <div class="css-1ed38mk"> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Re-start the MongoDB instance with access control <a class="headerlink leafygreen-ui-1kepx47" href="#re-start-the-mongodb-instance-with-access-control" 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="re-start-the-mongodb-instance-with-access-control"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> Shut down the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> instance. Using <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/mongodb-shell/#mongodb-binary-bin.mongosh" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongosh </code> </span> </a> , issue the following command: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.adminCommand( { shutdown: 1 } )","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">adminCommand</span>( <!-- -->{ <span class="lg-highlight-attr">shutdown</span>: <span class="lg-highlight-number">1</span> } )</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"> Exit <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/mongodb-shell/#mongodb-binary-bin.mongosh" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongosh </code> . </span> </a> </p> <p class="leafygreen-ui-1kp3ins"> Start the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> with access control enabled. </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> If you start the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> from the command line, add the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#std-option-mongod.--auth"> <code class="leafygreen-ui-1l06pbn"> --auth </code> </a> command line option: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"mongod --auth --port 27017 --dbpath /var/lib/mongodb","programmingLanguage":"Bash"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-1q4bxgx" tabindex="0"><code class="lg-highlight-hljs-light bash leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">mongod --auth --port 27017 --dbpath <!-- -->/var/lib/mongodb</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> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> If you start the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> using a <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/configuration-options/#std-label-configuration-options"> configuration file </a> , add the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/configuration-options/#mongodb-setting-security.authorization"> <code class="leafygreen-ui-1l06pbn"> security.authorization </code> </a> configuration file setting: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"security:\n authorization: enabled","programmingLanguage":"Bash"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" tabindex="-1"><code class="lg-highlight-hljs-light bash leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">security:</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> authorization: enabled</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> </li> </ul> <p class="leafygreen-ui-1kp3ins"> Clients that connect to this instance must now authenticate themselves and can only perform actions as determined by their assigned roles. </p> <div class="leafygreen-ui-85da11" role="note"> <h2 class="leafygreen-ui-1ac4g5h"> Important </h2> <h3 class="leafygreen-ui-144d5kf"> <strong> Localhost Exception </strong> </h3> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> You can create users either before or after enabling access control. If you enable access control before creating any user, MongoDB provides a <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/localhost-exception/#std-label-localhost-exception"> localhost exception </a> which allows you to create a user administrator in the <code class="leafygreen-ui-1l06pbn"> admin </code> database. Once created, you must authenticate as the user administrator to create additional users. </p> </div> </div> </section> </div> </div> <div class="css-1nuklj8 e1ckbxcu1"> <div class="css-18fui5z e1ckbxcu0"> <div class="css-19lsqsq e1ckbxcu2"> 5 </div> </div> <div class="css-1ed38mk"> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Connect and authenticate as the user administrator <a class="headerlink leafygreen-ui-1kepx47" href="#connect-and-authenticate-as-the-user-administrator" 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="connect-and-authenticate-as-the-user-administrator"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> Using <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/mongodb-shell/#mongodb-binary-bin.mongosh" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongosh </code> </span> </a> , you can: </p> <div aria-hidden="true"> </div> <div class="leafygreen-ui-1b75luy" data-lgid="lg-tabs"> <div class="leafygreen-ui-jp7pox" id="tabs-10"> <div aria-label="Tabs to describe usage of authafter/cmdline" aria-orientation="horizontal" class="leafygreen-ui-m8p1vb lg-ui-tab-list-0000" data-lgid="lg-tabs-tab_list" role="tablist"> <button aria-controls="_u2hxd4s28" aria-selected="true" class="leafygreen-ui-1l773z1" data-text="" id="_gtz9mvwq2" name="" role="tab" tabindex="0"> <div class="leafygreen-ui-1nxuzmg"> Authenticate during Connection </div> </button> <button aria-controls="_h245i0w0i" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_17hdbpv7r" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Authenticate after Connection </div> </button> </div> <div class="leafygreen-ui-ov1ktg"> <div class="leafygreen-ui-1sg2lsz"> </div> </div> </div> <div class="lg-ui-tab-panels-0000" data-lgid="lg-tabs-tab_panels"> <div> <div aria-labelledby="_ebnml6iks" class="" id="_wu8e0rlc5" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <p class="leafygreen-ui-1kp3ins"> Start <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/mongodb-shell/#mongodb-binary-bin.mongosh" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongosh </code> </span> </a> with the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/mongodb-shell/reference/options/#std-option-mongosh.--username" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> -u &lt;username&gt; </code> </span> </a> , <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/mongodb-shell/reference/options/#std-option-mongosh.--password" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> -p </code> </span> </a> , and the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/mongodb-shell/reference/options/#std-option-mongosh.--authenticationDatabase" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> --authenticationDatabase &lt;database&gt; </code> </span> </a> command line options: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"mongosh --port 27017 --authenticationDatabase \\\n \"admin\" -u \"myUserAdmin\" -p","programmingLanguage":"Bash"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" tabindex="-1"><code class="lg-highlight-hljs-light bash leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">mongosh --port 27017 --authenticationDatabase \</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"admin"</span> -u <span class="lg-highlight-string">"myUserAdmin"</span> -p</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"> Enter your password when prompted. </p> </div> </div> </div> <div> <div aria-labelledby="_jobovv7pm" class="leafygreen-ui-38lglc" id="_r4xetvqre" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <p class="leafygreen-ui-1kp3ins"> Using <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/mongodb-shell/#mongodb-binary-bin.mongosh" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongosh </code> </span> </a> , connect to your database deployment: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"mongosh --port 27017","programmingLanguage":"Bash"} </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 bash leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">mongosh --port 27017</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"> In <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/mongodb-shell/#mongodb-binary-bin.mongosh" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongosh </code> </span> </a> , switch to the authentication database (in this case, <code class="leafygreen-ui-1l06pbn"> admin </code> ), and use the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/db.auth/#mongodb-method-db.auth"> <code class="leafygreen-ui-1l06pbn"> db.auth(&lt;username&gt;, &lt;pwd&gt;) </code> </a> method to authenticate: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"use admin\ndb.auth(\"myUserAdmin\", passwordPrompt()) // or cleartext password","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">use admin</td></tr><tr class=""><td class="leafygreen-ui-7razhx">db.<span class="lg-highlight-title lg-highlight-function">auth</span>(<span class="lg-highlight-string">"myUserAdmin"</span>, <span class="lg-highlight-title lg-highlight-function">passwordPrompt</span>(<!-- -->)) <span class="lg-highlight-comment">// or cleartext password</span></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-13vw3ie" role="note"> <h2 class="leafygreen-ui-1fn4p2b"> Tip </h2> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> The <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/passwordPrompt/#mongodb-method-passwordPrompt"> <code class="leafygreen-ui-1l06pbn"> passwordPrompt() </code> </a> method prompts you to enter the password. You can also specify your password directly as a string. We recommend to use the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/passwordPrompt/#mongodb-method-passwordPrompt"> <code class="leafygreen-ui-1l06pbn"> passwordPrompt() </code> </a> method to avoid the password being visible on your screen and potentially leaking the password to your shell history. </p> </div> </div> <p class="leafygreen-ui-1kp3ins"> Enter the password when prompted. </p> </div> </div> </div> </div> </div> </section> </div> </div> </div> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Next Steps <a class="headerlink leafygreen-ui-1kepx47" href="#next-steps" 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="next-steps"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> To use SCRAM authentication for replica sets or sharded clusters, see <a class="leafygreen-ui-tqgtui" href="/docs/manual/tutorial/deploy-replica-set-with-keyfile-access-control/"> Deploy Self-Managed Replica Set With Keyfile Authentication <!-- --> . </a> </p> </section> </section>
https://www.mongodb.com/docs/manual/reference/method/passwordPrompt/
<section> <h1 class="contains-headerlink leafygreen-ui-41fr9s" weight="medium"> passwordPrompt() <a class="headerlink leafygreen-ui-1kepx47" href="#passwordprompt--" 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="passwordprompt--"> </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="#definition" target="_self"> <span> Definition </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#examples" target="_self"> <span> Examples </span> </a> </li> </ul> </div> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Definition <a class="headerlink leafygreen-ui-1kepx47" href="#definition" 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="definition"> </div> </a> </h2> <dl class="method"> <dt> <code class="leafygreen-ui-1l06pbn"> passwordPrompt() </code> <a class="headerlink leafygreen-ui-1kepx47" href="#mongodb-method-passwordPrompt" title="Permalink to this definition"> <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="mongodb-method-passwordPrompt"> </div> </a> </dt> <dd> <p class="leafygreen-ui-1kp3ins"> Prompts for the password in <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/mongodb-shell/#mongodb-binary-bin.mongosh" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongosh </code> </span> </a> . The entered password is not displayed in the shell. Use <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-method-passwordPrompt" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> passwordPrompt() </code> </span> </a> in conjunction with methods that accept password as a parameter instead of specifying the password in cleartext to those methods. </p> </dd> </dl> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Examples <a class="headerlink leafygreen-ui-1kepx47" href="#examples" 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="examples"> </div> </a> </h2> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Use <code class="leafygreen-ui-1l06pbn"> passwordPrompt() </code> with <code class="leafygreen-ui-1l06pbn"> db.createUser() </code> <a class="headerlink leafygreen-ui-1kepx47" href="#use-passwordprompt---with-db.createuser--" 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="use-passwordprompt---with-db.createuser--"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> The <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/db.createUser/#mongodb-method-db.createUser"> <code class="leafygreen-ui-1l06pbn"> db.createUser() </code> </a> requires a password to be specified. </p> <p class="leafygreen-ui-1kp3ins"> You can use <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-method-passwordPrompt" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> passwordPrompt() </code> </span> </a> as the value for the <code class="leafygreen-ui-1l06pbn"> pwd </code> instead of specifying the password. </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.createUser( {\n user:\"user123\",\n pwd: passwordPrompt(), // Instead of specifying the password in cleartext\n roles:[ \"readWrite\" ]\n} )","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><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">createUser</span>( <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">user</span>:<span class="lg-highlight-string">"user123"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">pwd</span>: <span class="lg-highlight-title lg-highlight-function">passwordPrompt</span>(<!-- -->)<!-- -->, <span class="lg-highlight-comment">// Instead of</span><span class="lg-highlight-comment"> specifying the password </span><span class="lg-highlight-comment">in cleartext</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">roles</span>:<!-- -->[ <span class="lg-highlight-string">"readWrite"</span> ]</td></tr><tr class=""><td class="leafygreen-ui-7razhx">} )</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"> Enter the password when prompted. </p> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Use <code class="leafygreen-ui-1l06pbn"> passwordPrompt() </code> with <code class="leafygreen-ui-1l06pbn"> db.auth() </code> <a class="headerlink leafygreen-ui-1kepx47" href="#use-passwordprompt---with-db.auth--" 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="use-passwordprompt---with-db.auth--"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> When you run the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/db.auth/#std-label-db-auth-syntax-username-password"> <code class="leafygreen-ui-1l06pbn"> db.auth(&lt;username&gt;, &lt;password&gt;) </code> </a> command you can replace the password with the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-method-passwordPrompt" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> passwordPrompt() </code> </span> </a> method. </p> <p class="leafygreen-ui-1kp3ins"> If you omit the password from the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/db.auth/#std-label-db-auth-syntax-username-password"> <code class="leafygreen-ui-1l06pbn"> db.auth(&lt;username&gt;, &lt;password&gt;) </code> </a> command, the user is prompted to enter a password. </p> <p class="leafygreen-ui-1kp3ins"> The following example prompts the user to enter a password which is not displayed in the shell: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.auth(\"user123\")","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">auth</span>(<span class="lg-highlight-string">"user123"</span>)</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> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Use <code class="leafygreen-ui-1l06pbn"> passwordPrompt() </code> with <code class="leafygreen-ui-1l06pbn"> db.changeUserPassword() </code> <a class="headerlink leafygreen-ui-1kepx47" href="#use-passwordprompt---with-db.changeuserpassword--" 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="use-passwordprompt---with-db.changeuserpassword--"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> The <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/db.changeUserPassword/#mongodb-method-db.changeUserPassword"> <code class="leafygreen-ui-1l06pbn"> db.changeUserPassword() </code> </a> requires a password to be specified. </p> <p class="leafygreen-ui-1kp3ins"> You can use <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-method-passwordPrompt" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> passwordPrompt() </code> </span> </a> instead of specifying the password. </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.changeUserPassword(\"user123\", passwordPrompt())","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">changeUserPassword</span>(<span class="lg-highlight-string">"user123"</span>, <span class="lg-highlight-title lg-highlight-function">passwordPrompt</span>(<!-- -->))</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"> Enter the password when prompted. </p> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Use <code class="leafygreen-ui-1l06pbn"> passwordPrompt() </code> with <code class="leafygreen-ui-1l06pbn"> db.updateUser() </code> <a class="headerlink leafygreen-ui-1kepx47" href="#use-passwordprompt---with-db.updateuser--" 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="use-passwordprompt---with-db.updateuser--"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> When changing the password with <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/db.updateUser/#mongodb-method-db.updateUser"> <code class="leafygreen-ui-1l06pbn"> db.updateUser() </code> </a> , the method requires a password to be specified. </p> <p class="leafygreen-ui-1kp3ins"> You can use <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-method-passwordPrompt" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> passwordPrompt() </code> </span> </a> as the value for the <code class="leafygreen-ui-1l06pbn"> pwd </code> instead of specifying the password. </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.updateUser(\n \"user123\",\n {\n pwd: passwordPrompt(),\n mechanisms: [ \"SCRAM-SHA-256\" ]\n }\n)","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">updateUser</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"user123"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">pwd</span>: <span class="lg-highlight-title lg-highlight-function">passwordPrompt</span>(<!-- -->)<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">mechanisms</span>: <!-- -->[ <span class="lg-highlight-string">"SCRAM-SHA-256"</span> ]</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">)</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"> Enter the password when prompted. </p> </section> </section> </section>
https://www.mongodb.com/docs/manual/reference/method/db.collection.findOneAndReplace/
<section> <h1 class="contains-headerlink leafygreen-ui-41fr9s" weight="medium"> db.collection.findOneAndReplace() <a class="headerlink leafygreen-ui-1kepx47" href="#db.collection.findoneandreplace--" 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.findoneandreplace--"> </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="#definition" target="_self"> <span> Definition </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#syntax" target="_self"> <span> Syntax </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#behavior" target="_self"> <span> Behavior </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#examples" target="_self"> <span> Examples </span> </a> </li> </ul> </div> <div class="leafygreen-ui-147elvs"> <p class="leafygreen-ui-1ronz74"> MongoDB with drivers </p> <div class="leafygreen-ui-18k5rfm"> <p class="leafygreen-ui-1kp3ins"> This page documents a <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/mongodb-shell/#mongodb-binary-bin.mongosh" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongosh </code> </span> </a> method. To see the equivalent method in a MongoDB driver, see the corresponding page for your programming language: </p> </div> <div class="leafygreen-ui-zgrwqu notranslate"> <a class="leafygreen-ui-v22cck" href="https://mongodb.github.io/mongo-csharp-driver/2.29.0/api/MongoDB.Driver/MongoDB.Driver.MongoCollectionBase-1.FindOneAndReplace.html" target="_self"> <svg class="leafygreen-ui-x3zji3" fill="none" height="24" viewbox="0 0 28 29" width="24" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_1351_59964)"> <g clip-path="url(#clip1_1351_59964)"> <path d="M25.7709 9.2495C25.7709 8.79827 25.678 8.39408 25.4827 8.04627C25.2874 7.70785 25.0084 7.42586 24.627 7.20025C21.465 5.35781 18.2937 3.51538 15.1317 1.67295C14.2761 1.17474 13.4484 1.19354 12.6021 1.70115C11.3466 2.45316 5.04112 6.10042 3.15321 7.20025C2.3813 7.65142 2 8.34705 2 9.24005C2 12.9531 2 16.6568 2 20.3698C2 20.8117 2.093 21.2064 2.279 21.5449C2.4743 21.8927 2.7626 22.1841 3.15321 22.4191C5.03182 23.5189 11.3373 27.1662 12.6021 27.9182C13.4484 28.4258 14.2761 28.4446 15.1317 27.9463C18.2937 26.1039 21.465 24.2615 24.627 22.4191C25.0177 22.1935 25.306 21.9021 25.5012 21.5449C25.6873 21.2064 25.7803 20.8117 25.7803 20.3698C25.7709 20.3698 25.7709 12.9531 25.7709 9.2495Z" fill="#A179DC"> </path> <path d="M13.9227 14.7673L2.27905 21.5449C2.47435 21.8927 2.76265 22.1841 3.15326 22.4191C5.03187 23.5189 11.3373 27.1662 12.6021 27.9182C13.4484 28.4258 14.2762 28.4445 15.1317 27.9463C18.2938 26.1039 21.4651 24.2615 24.6271 22.4191C25.0177 22.1935 25.306 21.9021 25.5013 21.5449L13.9227 14.7673Z" fill="#280068"> </path> <path d="M25.7711 9.24949C25.7711 8.79827 25.6781 8.39408 25.4828 8.04626L13.9229 14.7768L25.4921 21.5543C25.6781 21.2159 25.7711 20.8211 25.7711 20.3793C25.7711 20.3699 25.7711 12.9531 25.7711 9.24949Z" fill="#390091"> </path> <path d="M20.7771 12.2387V13.5078H22.0325V12.2387H22.6557V13.5078H23.9111V14.1376H22.6557V15.4066H23.9111V16.0364H22.6557V17.3054H22.0325V16.0364H20.7771V17.3054H20.1539V16.0364H18.8984V15.4066H20.1539V14.1376H18.8984V13.5078H20.1539V12.2387H20.7771ZM22.0325 14.1376H20.7771V15.4066H22.0325V14.1376Z" fill="white"> </path> <path d="M13.9508 5.87482C17.2151 5.87482 20.0702 7.67022 21.6047 10.3399L21.5861 10.3117L17.7452 12.5489C16.9919 11.2517 15.5969 10.3775 14.0066 10.3587H13.9601C11.5328 10.3587 9.56116 12.3515 9.56116 14.805C9.56116 15.604 9.77503 16.3654 10.1377 17.014C10.9004 18.3488 12.3232 19.2512 13.9601 19.2512C15.6062 19.2512 17.0384 18.3394 17.7917 16.9858L17.7731 17.014L21.614 19.2606C20.0981 21.9021 17.2895 23.6975 14.0531 23.7257H13.9508C10.6679 23.7257 7.81274 21.9209 6.28753 19.2418C5.54353 17.9352 5.11572 16.4124 5.11572 14.7956C5.11572 9.87931 9.06825 5.87482 13.9508 5.87482Z" fill="white"> </path> </g> </g> <defs> <clippath id="clip0_1351_59964"> <rect fill="white" height="28" transform="translate(0 0.809265)" width="28"> </rect> </clippath> <clippath id="clip1_1351_59964"> <rect fill="white" height="27" transform="translate(2 1.30966)" width="24"> </rect> </clippath> </defs> </svg> <span> C# </span> </a> <a class="leafygreen-ui-v22cck" href="https://www.mongodb.com/docs/drivers/java/sync/current/fundamentals/crud/compound-operations/#find-and-replace" target="_self"> <svg class="leafygreen-ui-x3zji3" fill="none" height="24" viewbox="0 0 30 41" width="24" xmlns="http://www.w3.org/2000/svg"> <path d="M10.0921 30.7949C10.0921 30.7949 8.57608 31.6793 11.166 31.9636C14.2929 32.311 15.9037 32.2794 19.3464 31.6161C19.3464 31.6161 20.2623 32.1846 21.5257 32.6901C13.7876 35.9748 4.02791 32.5005 10.0921 30.7949Z" fill="#0074BD"> </path> <path d="M9.14539 26.4678C9.14539 26.4678 7.43985 27.7312 10.0298 27.9838C13.3778 28.3312 15.9992 28.3628 20.579 27.4785C20.579 27.4785 21.2107 28.1101 22.1898 28.4576C12.8724 31.2054 2.44949 28.6787 9.14539 26.4678Z" fill="#0074BD"> </path> <path d="M17.1039 19.1398C18.9989 21.3191 16.5985 23.3089 16.5985 23.3089C16.5985 23.3089 21.431 20.8138 19.2201 17.6869C17.1355 14.7811 15.5563 13.3282 24.1788 8.33789C24.1473 8.33789 10.6607 11.6858 17.1039 19.1398Z" fill="#EA2D2E"> </path> <path d="M27.3377 33.9845C27.3377 33.9845 28.4431 34.9004 26.1059 35.6269C21.6525 36.985 7.53417 37.3957 3.61769 35.6901C2.19639 35.0899 4.84949 34.2372 5.67069 34.0477C6.52347 33.8582 7.02884 33.8898 7.02884 33.8898C5.44961 32.7843 -3.10981 36.0691 2.67016 36.9851C18.4308 39.5433 31.4121 35.8164 27.3377 33.9845Z" fill="#0074BD"> </path> <path d="M10.8194 21.983C10.8194 21.983 3.6497 23.6885 8.2926 24.3203C10.2509 24.5729 14.1357 24.5097 17.7995 24.2255C20.7685 23.9728 23.7375 23.4359 23.7375 23.4359C23.7375 23.4359 22.6951 23.8781 21.9372 24.415C14.6411 26.3416 0.585992 25.4257 4.62881 23.4675C8.00839 21.7935 10.8194 21.983 10.8194 21.983Z" fill="#0074BD"> </path> <path d="M23.6745 29.1846C31.0969 25.3313 27.6542 21.6359 25.2538 22.1413C24.6537 22.2676 24.401 22.3623 24.401 22.3623C24.401 22.3623 24.6221 22.0149 25.0327 21.8886C29.7703 20.2146 33.4025 26.7842 23.5166 29.4057C23.5482 29.3741 23.6429 29.2794 23.6745 29.1846Z" fill="#0074BD"> </path> <path d="M19.2206 0.25293C19.2206 0.25293 23.3266 4.35891 15.3357 10.6758C8.92404 15.7293 13.8828 18.6351 15.3357 21.9199C11.6087 18.5403 8.86088 15.5714 10.6928 12.792C13.3775 8.74919 20.863 6.79093 19.2206 0.25293Z" fill="#EA2D2E"> </path> <path d="M11.5455 39.6068C18.6521 40.049 29.5803 39.3541 29.833 35.9746C29.833 35.9746 29.3276 37.238 23.9583 38.2487C17.894 39.3858 10.4085 39.2594 5.95508 38.533C5.95508 38.5646 6.87103 39.3225 11.5455 39.6068Z" fill="#0074BD"> </path> </svg> <span> Java Sync </span> </a> <a class="leafygreen-ui-v22cck" href="https://www.mongodb.com/docs/drivers/node/current/fundamentals/crud/compound-operations/#built-in-methods" target="_self"> <svg class="leafygreen-ui-x3zji3" fill="none" height="24" viewbox="0 0 30 30" width="24" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:R2dt5qcmqn9:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":R2dt5qcmqn9:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":R2dt5qcmqn9:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":R2dt5qcmqn9:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <span> Node.js </span> </a> <a class="leafygreen-ui-v22cck" href="https://pymongo.readthedocs.io/en/4.8.0/api/pymongo/collection.html#pymongo.collection.Collection.find_one_and_replace" target="_self"> <svg class="leafygreen-ui-x3zji3" height="24" viewbox="0 0 111.6 147" width="24" xmlns="http://www.w3.org/2000/svg"> <lineargradient gradienttransform="matrix(.5625 0 0 -.568 -160.323 -146.09)" gradientunits="userSpaceOnUse" id=":R2ht5qcmqn9:aa" x1="280.848" x2="389.865" y1="-268.463" y2="-362.257"> <stop offset="0" stop-color="#5a9fd4"> </stop> <stop offset="1" stop-color="#306998"> </stop> </lineargradient> <path d="M55.3 3.2c-4.6 0-9 .4-12.8 1.1-11.3 2-13.4 6.2-13.4 13.9v10.2h26.8v3.4H19c-7.8 0-14.6 4.7-16.8 13.6C-.3 55.6-.4 62 2.2 72.7c1.9 7.9 6.5 13.6 14.2 13.6h9.2V74c0-8.8 7.7-16.7 16.7-16.7h26.8c7.5 0 13.4-6.1 13.4-13.6V18.2c0-7.3-6.1-12.7-13.4-13.9-4.4-.8-9.2-1.1-13.8-1.1zm-14.5 8.2c2.8 0 5 2.3 5 5.1s-2.3 5.1-5 5.1c-2.8 0-5-2.3-5-5.1s2.2-5.1 5-5.1z" fill="url(#:R2ht5qcmqn9:aa)"> </path> <lineargradient gradienttransform="matrix(.5625 0 0 -.568 -160.323 -146.09)" gradientunits="userSpaceOnUse" id=":R2ht5qcmqn9:bb" x1="432.011" x2="393.081" y1="-419.025" y2="-363.946"> <stop offset="0" stop-color="#ffd43b"> </stop> <stop offset="1" stop-color="#ffe873"> </stop> </lineargradient> <path d="M86 31.8v11.9c0 9.2-7.8 17-16.8 17H42.5c-7.3 0-13.4 6.3-13.4 13.6v25.5c0 7.3 6.3 11.5 13.4 13.6 8.5 2.5 16.6 2.9 26.8 0 6.8-2 13.4-5.9 13.4-13.6V89.7H55.9v-3.4h40.2c7.8 0 10.7-5.4 13.4-13.6 2.8-8.4 2.7-16.5 0-27.3-1.9-7.8-5.6-13.6-13.4-13.6H86zM71 96.5c2.8 0 5 2.3 5 5.1s-2.3 5.1-5 5.1c-2.8 0-5-2.3-5-5.1-.1-2.8 2.2-5.1 5-5.1z" fill="url(#:R2ht5qcmqn9:bb)"> </path> <radialgradient cx="-2274.721" cy="144.526" gradienttransform="matrix(0 -.2399 -1.0547 0 208.637 -414.922)" gradientunits="userSpaceOnUse" id=":R2ht5qcmqn9:cc" r="29.037"> <stop offset="0" stop-color="#b8b8b8" stop-opacity=".498"> </stop> <stop offset="1" stop-color="#7f7f7f" stop-opacity="0"> </stop> </radialgradient> <path d="M92.1 130.9c0 3.8-16.1 7-35.9 7s-35.9-3.1-35.9-7c0-3.8 16.1-7 35.9-7s35.9 3.1 35.9 7z" fill="url(#:R2ht5qcmqn9:cc)" opacity=".444"> </path> </svg> <span> PyMongo </span> </a> <a class="leafygreen-ui-18cpm0b" href="https://mongoc.org/libmongoc/current/mongoc_collection_replace_one.html" target="_self"> <svg class="leafygreen-ui-x3zji3" fill="none" height="24" viewbox="0 0 28 29" width="24" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_1351_59955)"> <g clip-path="url(#clip1_1351_59955)"> <path clip-rule="evenodd" d="M13.118 1.49532C13.5403 1.25103 14.0559 1.25103 14.4783 1.49532C16.5652 2.70389 22.8385 6.34889 24.9193 7.55748C25.3416 7.80172 25.6025 8.25176 25.6025 8.74672C25.6025 11.1703 25.6025 18.4539 25.6025 20.8774C25.6025 21.366 25.3416 21.8224 24.9193 22.0667C22.8385 23.2753 16.5652 26.9203 14.4783 28.1289C14.0559 28.3732 13.5403 28.3732 13.118 28.1289C11.0373 26.9139 4.76398 23.2689 2.68323 22.0603C2.26087 21.816 2 21.366 2 20.871C2 18.4474 2 11.1639 2 8.7403C2 8.25176 2.26087 7.7953 2.68323 7.55106C4.76398 6.34889 11.0373 2.70389 13.118 1.49532Z" fill="#004482" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M2.18634 21.4946C2.01863 21.2632 2 21.051 2 20.7553C2 18.351 2 11.1061 2 8.70176C2 8.21317 2.26087 7.76319 2.67702 7.51889C4.75776 6.31675 11.0062 2.69104 13.0807 1.4889C13.5031 1.24461 14.0683 1.25104 14.4907 1.49533C16.5652 2.69747 22.795 6.29104 24.8696 7.49319C25.0373 7.58963 25.1677 7.70535 25.2795 7.86606L2.18634 21.4946Z" fill="#659AD2" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M13.8011 5.8089C18.6024 5.8089 22.4968 9.83964 22.4968 14.8089C22.4968 19.7782 18.6024 23.8089 13.8011 23.8089C8.99986 23.8089 5.10547 19.7782 5.10547 14.8089C5.10547 9.83964 8.99986 5.8089 13.8011 5.8089ZM13.8011 10.3089C16.1987 10.3089 18.1489 12.3275 18.1489 14.8089C18.1489 17.2903 16.1987 19.3089 13.8011 19.3089C11.4036 19.3089 9.4533 17.2903 9.4533 14.8089C9.4533 12.3275 11.4036 10.3089 13.8011 10.3089Z" fill="white" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M25.2857 7.87247C25.6087 8.18102 25.6025 8.65034 25.6025 9.01673C25.6025 11.4596 25.5839 18.396 25.6087 20.8325C25.6087 21.0896 25.528 21.3532 25.4099 21.5589L13.5466 14.8089L25.2857 7.87247Z" fill="#00599C" fill-rule="evenodd"> </path> </g> </g> <defs> <clippath id="clip0_1351_59955"> <rect fill="white" height="28" transform="translate(0 0.809265)" width="28"> </rect> </clippath> <clippath id="clip1_1351_59955"> <rect fill="white" height="27" transform="translate(2 1.30887)" width="24"> </rect> </clippath> </defs> </svg> <span> C </span> </a> <a class="leafygreen-ui-18cpm0b" href="https://mongocxx.org/api/current/classmongocxx_1_1v__noabi_1_1collection.html#a3ffba5e95130cc31d5a9ddf57d57b9e6" target="_self"> <svg class="leafygreen-ui-x3zji3" fill="none" height="24" viewbox="0 0 28 29" width="24" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_1351_59959)"> <g clip-path="url(#clip1_1351_59959)"> <path d="M25.4013 21.5646C25.5872 21.2353 25.7034 20.8745 25.7034 20.5373V9.08012C25.7034 8.75078 25.5872 8.38217 25.4013 8.05283L13.8516 14.8127L25.4013 21.5646Z" fill="#00599C"> </path> <path d="M14.8738 28.0657L24.6729 22.3411C24.9517 22.1764 25.2151 21.8941 25.401 21.5647L13.8513 14.8127L2.30151 21.5647C2.48743 21.8941 2.74305 22.1764 3.02967 22.3411L12.8288 28.0657C13.3865 28.3951 14.316 28.3951 14.8738 28.0657Z" fill="#004482"> </path> <path d="M25.4011 8.06086C25.2152 7.73146 24.9596 7.44915 24.673 7.2845L14.8739 1.55983C14.3084 1.23046 13.3866 1.23046 12.8211 1.55983L3.02202 7.2845C2.46429 7.61385 1.99951 8.42158 1.99951 9.08033V20.5375C1.99951 20.8669 2.11571 21.2354 2.30162 21.5647L13.8514 14.8128L25.4011 8.06086Z" fill="#659AD2"> </path> <path d="M13.8512 22.8115C9.49778 22.8115 5.94995 19.2199 5.94995 14.8127C5.94995 10.4055 9.49778 6.81387 13.8512 6.81387C16.6631 6.81387 19.2813 8.34305 20.6912 10.8133L17.2751 12.813C16.5701 11.5818 15.261 10.8133 13.8512 10.8133C11.6745 10.8133 9.90055 12.6091 9.90055 14.8127C9.90055 17.0163 11.6745 18.8121 13.8512 18.8121C15.261 18.8121 16.5701 18.0436 17.2751 16.8124L20.6912 18.8121C19.2813 21.2745 16.6631 22.8115 13.8512 22.8115Z" fill="white"> </path> <path d="M21.7524 14.3657H20.8771V13.4796H19.994V14.3657H19.1187V15.2518H19.994V16.1458H20.8771V15.2518H21.7524V14.3657Z" fill="white"> </path> <path d="M25.0446 14.3657H24.1693V13.4796H23.2862V14.3657H22.4109V15.2518H23.2862V16.1458H24.1693V15.2518H25.0446V14.3657Z" fill="white"> </path> </g> </g> <defs> <clippath id="clip0_1351_59959"> <rect fill="white" height="28" transform="translate(0 0.809265)" width="28"> </rect> </clippath> <clippath id="clip1_1351_59959"> <rect fill="white" height="27" transform="translate(1.99951 1.30878)" width="24"> </rect> </clippath> </defs> </svg> <span> C++ </span> </a> <a class="leafygreen-ui-18cpm0b" href="https://pkg.go.dev/go.mongodb.org/[email protected]/mongo#Collection.FindOneAndReplace" target="_self"> <svg class="leafygreen-ui-x3zji3" height="24" id="Layer_1" style="fill:#00ACD7" version="1.1" viewbox="0 0 205.4 76.7" width="24" x="0" xmlns="http://www.w3.org/2000/svg" y="0"> <path class="st00" d="M15.5 23.2c-.4 0-.5-.2-.3-.5l2.1-2.7c.2-.3.7-.5 1.1-.5h35.7c.4 0 .5.3.3.6l-1.7 2.6c-.2.3-.7.6-1 .6l-36.2-.1zM.4 32.4c-.4 0-.5-.2-.3-.5l2.1-2.7c.2-.3.7-.5 1.1-.5h45.6c.4 0 .6.3.5.6l-.8 2.4c-.1.4-.5.6-.9.6l-47.3.1zM24.6 41.6c-.4 0-.5-.3-.3-.6l1.4-2.5c.2-.3.6-.6 1-.6h20c.4 0 .6.3.6.7l-.2 2.4c0 .4-.4.7-.7.7l-21.8-.1z"> </path> <g id="CXHf1q_3_"> <path class="st00" d="M128.4 21.4c-6.3 1.6-10.6 2.8-16.8 4.4-1.5.4-1.6.5-2.9-1-1.5-1.7-2.6-2.8-4.7-3.8-6.3-3.1-12.4-2.2-18.1 1.5-6.8 4.4-10.3 10.9-10.2 19 .1 8 5.6 14.6 13.5 15.7 6.8.9 12.5-1.5 17-6.6.9-1.1 1.7-2.3 2.7-3.7H89.6c-2.1 0-2.6-1.3-1.9-3 1.3-3.1 3.7-8.3 5.1-10.9.3-.6 1-1.6 2.5-1.6h36.4c-.2 2.7-.2 5.4-.6 8.1-1.1 7.2-3.8 13.8-8.2 19.6-7.2 9.5-16.6 15.4-28.5 17-9.8 1.3-18.9-.6-26.9-6.6-7.4-5.6-11.6-13-12.7-22.2-1.3-10.9 1.9-20.7 8.5-29.3C70.4 8.7 79.8 2.8 91.3.7c9.4-1.7 18.4-.6 26.5 4.9 5.3 3.5 9.1 8.3 11.6 14.1.6.9.2 1.4-1 1.7z"> </path> <path class="st00" d="M161.5 76.7c-9.1-.2-17.4-2.8-24.4-8.8-5.9-5.1-9.6-11.6-10.8-19.3-1.8-11.3 1.3-21.3 8.1-30.2 7.3-9.6 16.1-14.6 28-16.7 10.2-1.8 19.8-.8 28.5 5.1 7.9 5.4 12.8 12.7 14.1 22.3 1.7 13.5-2.2 24.5-11.5 33.9-6.6 6.7-14.7 10.9-24 12.8-2.7.5-5.4.6-8 .9zm23.8-40.4c-.1-1.3-.1-2.3-.3-3.3-1.8-9.9-10.9-15.5-20.4-13.3-9.3 2.1-15.3 8-17.5 17.4-1.8 7.8 2 15.7 9.2 18.9 5.5 2.4 11 2.1 16.3-.6 7.9-4.1 12.2-10.5 12.7-19.1z"> </path> </g> </svg> <span> Go </span> </a> <a class="leafygreen-ui-18cpm0b" href="https://mongodb.github.io/mongo-java-driver/5.2/apidocs/mongodb-driver-reactivestreams/com/mongodb/reactivestreams/client/MongoCollection.html#findOneAndReplace(org.bson.conversions.Bson,TDocument)" target="_self"> <svg class="leafygreen-ui-x3zji3" fill="none" height="24" viewbox="0 0 30 41" width="24" xmlns="http://www.w3.org/2000/svg"> <path d="M10.0921 30.7949C10.0921 30.7949 8.57608 31.6793 11.166 31.9636C14.2929 32.311 15.9037 32.2794 19.3464 31.6161C19.3464 31.6161 20.2623 32.1846 21.5257 32.6901C13.7876 35.9748 4.02791 32.5005 10.0921 30.7949Z" fill="#0074BD"> </path> <path d="M9.14539 26.4678C9.14539 26.4678 7.43985 27.7312 10.0298 27.9838C13.3778 28.3312 15.9992 28.3628 20.579 27.4785C20.579 27.4785 21.2107 28.1101 22.1898 28.4576C12.8724 31.2054 2.44949 28.6787 9.14539 26.4678Z" fill="#0074BD"> </path> <path d="M17.1039 19.1398C18.9989 21.3191 16.5985 23.3089 16.5985 23.3089C16.5985 23.3089 21.431 20.8138 19.2201 17.6869C17.1355 14.7811 15.5563 13.3282 24.1788 8.33789C24.1473 8.33789 10.6607 11.6858 17.1039 19.1398Z" fill="#EA2D2E"> </path> <path d="M27.3377 33.9845C27.3377 33.9845 28.4431 34.9004 26.1059 35.6269C21.6525 36.985 7.53417 37.3957 3.61769 35.6901C2.19639 35.0899 4.84949 34.2372 5.67069 34.0477C6.52347 33.8582 7.02884 33.8898 7.02884 33.8898C5.44961 32.7843 -3.10981 36.0691 2.67016 36.9851C18.4308 39.5433 31.4121 35.8164 27.3377 33.9845Z" fill="#0074BD"> </path> <path d="M10.8194 21.983C10.8194 21.983 3.6497 23.6885 8.2926 24.3203C10.2509 24.5729 14.1357 24.5097 17.7995 24.2255C20.7685 23.9728 23.7375 23.4359 23.7375 23.4359C23.7375 23.4359 22.6951 23.8781 21.9372 24.415C14.6411 26.3416 0.585992 25.4257 4.62881 23.4675C8.00839 21.7935 10.8194 21.983 10.8194 21.983Z" fill="#0074BD"> </path> <path d="M23.6745 29.1846C31.0969 25.3313 27.6542 21.6359 25.2538 22.1413C24.6537 22.2676 24.401 22.3623 24.401 22.3623C24.401 22.3623 24.6221 22.0149 25.0327 21.8886C29.7703 20.2146 33.4025 26.7842 23.5166 29.4057C23.5482 29.3741 23.6429 29.2794 23.6745 29.1846Z" fill="#0074BD"> </path> <path d="M19.2206 0.25293C19.2206 0.25293 23.3266 4.35891 15.3357 10.6758C8.92404 15.7293 13.8828 18.6351 15.3357 21.9199C11.6087 18.5403 8.86088 15.5714 10.6928 12.792C13.3775 8.74919 20.863 6.79093 19.2206 0.25293Z" fill="#EA2D2E"> </path> <path d="M11.5455 39.6068C18.6521 40.049 29.5803 39.3541 29.833 35.9746C29.833 35.9746 29.3276 37.238 23.9583 38.2487C17.894 39.3858 10.4085 39.2594 5.95508 38.533C5.95508 38.5646 6.87103 39.3225 11.5455 39.6068Z" fill="#0074BD"> </path> </svg> <span> Java RS </span> </a> <a class="leafygreen-ui-18cpm0b" href="https://www.mongodb.com/docs/drivers/kotlin/coroutine/current/fundamentals/crud/compound-operations/#find-and-replace" target="_self"> <svg class="leafygreen-ui-x3zji3" fill="none" height="24" viewbox="0 0 28 29" width="24" xmlns="http://www.w3.org/2000/svg"> <path d="M28 29H0V1H28L14 15L28 29Z" fill="url(#:R35t5qcmqn9:paint0_linear_211_40588)"> </path> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":R35t5qcmqn9:paint0_linear_211_40588" x1="28" x2="8.34465e-07" y1="0.999999" y2="29"> <stop offset="0.00343514" stop-color="#E44857"> </stop> <stop offset="0.4689" stop-color="#C711E1"> </stop> <stop offset="1" stop-color="#7F52FF"> </stop> </lineargradient> </defs> </svg> <span> Kotlin Coroutine </span> </a> <a class="leafygreen-ui-18cpm0b" href="https://mongodb.github.io/mongo-java-driver/5.2/apidocs/mongodb-driver-kotlin-sync/mongodb-driver-kotlin-sync/com.mongodb.kotlin.client/-mongo-collection/find-one-and-replace.html?query=fun%20findOneAndReplace(clientSession:%20ClientSession,%20filter:%20Bson,%20replacement:%20T,%20options:%20FindOneAndReplaceOptions%20=%20FindOneAndReplaceOptions()):%20T?" target="_self"> <svg class="leafygreen-ui-x3zji3" fill="none" height="24" viewbox="0 0 28 29" width="24" xmlns="http://www.w3.org/2000/svg"> <path d="M28 29H0V1H28L14 15L28 29Z" fill="url(#:R39t5qcmqn9:paint0_linear_211_40588)"> </path> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":R39t5qcmqn9:paint0_linear_211_40588" x1="28" x2="8.34465e-07" y1="0.999999" y2="29"> <stop offset="0.00343514" stop-color="#E44857"> </stop> <stop offset="0.4689" stop-color="#C711E1"> </stop> <stop offset="1" stop-color="#7F52FF"> </stop> </lineargradient> </defs> </svg> <span> Kotlin Sync </span> </a> <a class="leafygreen-ui-18cpm0b" href="https://www.mongodb.com/docs/php-library/current/reference/method/MongoDBCollection-findOneAndReplace/" target="_self"> <svg class="leafygreen-ui-x3zji3" height="24" viewbox="0 0 700 301" width="24" x="0" xmlns="http://www.w3.org/2000/svg" y="0"> <defs> <clippath clippathunits="userSpaceOnUse" id="a"> <path d="M11.52 162C11.52 81.677 135.307 16.561 288 16.561S564.481 81.677 564.481 162c0 80.322-123.788 145.439-276.481 145.439-152.693 0-276.48-65.117-276.48-145.439"> </path> </clippath> <clippath clippathunits="userSpaceOnUse" id="c"> <path d="M0 324h576V0H0v324z"> </path> </clippath> <clippath clippathunits="userSpaceOnUse" id="d"> <path d="M0 324h576V0H0v324z"> </path> </clippath> <radialgradient cx="0" cy="0" fx="0" fy="0" gradienttransform="matrix(363.05789 0 0 -363.05789 177.52 256.307)" gradientunits="userSpaceOnUse" id="b" r="1" spreadmethod="pad"> <stop offset="0" stop-color="#aeb2d5"> </stop> <stop offset=".3" stop-color="#aeb2d5"> </stop> <stop offset=".75" stop-color="#484c89"> </stop> <stop offset="1" stop-color="#484c89"> </stop> </radialgradient> </defs> <g clip-path="url(#a)" transform="matrix(1.25 0 0 -1.25 -4.4 394.299)"> <path d="M11.52 162C11.52 81.677 135.307 16.561 288 16.561S564.481 81.677 564.481 162c0 80.322-123.788 145.439-276.481 145.439-152.693 0-276.48-65.117-276.48-145.439" fill="url(#b)"> </path> </g> <g clip-path="url(#c)" transform="matrix(1.25 0 0 -1.25 -4.4 394.299)"> <path d="M288 27.36c146.729 0 265.68 60.28 265.68 134.64 0 74.36-118.951 134.641-265.68 134.641S22.32 236.36 22.32 162.001C22.32 87.64 141.271 27.358 288 27.358" fill="#777bb3"> </path> </g> <g clip-path="url(#d)" transform="matrix(1.25 0 0 -1.25 -4.4 394.299)"> <path d="M161.734 145.307c12.065 0 21.072 2.225 26.771 6.61 5.638 4.342 9.532 11.863 11.573 22.354 1.903 9.806 1.178 16.653-2.154 20.348-3.407 3.774-10.773 5.688-21.893 5.688h-19.28l-10.69-55h15.673zm-63.063-67.75a2.998 2.998 0 00-2.944 3.572l28.328 145.75a3 3 0 002.945 2.428h61.054c19.188 0 33.47-5.21 42.447-15.487 9.025-10.331 11.812-24.772 8.283-42.921-1.436-7.394-3.906-14.261-7.34-20.41-3.44-6.154-7.985-11.85-13.512-16.93-6.616-6.191-14.104-10.681-22.236-13.323-8.003-2.607-18.28-3.93-30.548-3.93h-24.722l-7.06-36.321a3 3 0 00-2.944-2.428h-31.75z"> </path> <path d="M159.224 197.307h16.808c13.42 0 18.083-2.945 19.667-4.7 2.628-2.914 3.124-9.058 1.435-17.767-1.898-9.75-5.416-16.663-10.458-20.545-5.162-3.974-13.554-5.988-24.941-5.988H149.7l9.523 49zm28.83 35H127a6 6 0 01-5.89-4.855L92.784 81.702a6 6 0 015.889-7.144h31.75a6 6 0 015.89 4.854l6.588 33.895h22.249c12.582 0 23.174 1.372 31.479 4.077 8.54 2.775 16.399 7.48 23.354 13.984 5.752 5.292 10.49 11.232 14.08 17.657 3.59 6.427 6.17 13.594 7.668 21.302 3.715 19.104.697 34.402-8.97 45.466-9.571 10.958-24.613 16.514-44.705 16.514m-45.633-90h19.313c12.8 0 22.336 2.411 28.6 7.234 6.267 4.824 10.493 12.875 12.689 24.157 2.1 10.832 1.144 18.476-2.871 22.93-4.02 4.452-12.06 6.68-24.121 6.68h-21.754l-11.856-61m45.633 84c18.367 0 31.766-4.82 40.188-14.462 8.42-9.64 10.957-23.098 7.597-40.375-1.383-7.117-3.722-13.624-7.015-19.519-3.297-5.899-7.602-11.293-12.922-16.184-6.34-5.933-13.383-10.16-21.133-12.679-7.75-2.525-17.621-3.782-29.621-3.782h-27.196l-7.531-38.75h-31.75L127 226.307h61.055" fill="#fff"> </path> <path d="M311.583 116.307c-.896 0-1.745.4-2.314 1.092a2.994 2.994 0 00-.631 2.48l12.531 64.489c1.192 6.133.898 10.535-.827 12.395-1.056 1.137-4.228 3.044-13.607 3.044h-22.702l-15.755-81.072a3 3 0 00-2.945-2.428h-31.5a2.998 2.998 0 00-2.945 3.572l28.328 145.75a3 3 0 002.945 2.428h31.5a3 3 0 002.945-3.572l-6.836-35.178h24.422c18.605 0 31.221-3.28 38.569-10.028 7.49-6.884 9.827-17.891 6.947-32.72l-13.18-67.824a3 3 0 00-2.945-2.428h-32z"> </path> <path d="M293.661 271.057h-31.5a6 6 0 01-5.89-4.855l-28.328-145.75a5.998 5.998 0 015.89-7.145h31.5a6 6 0 015.89 4.855l15.283 78.645h20.23c9.362 0 11.327-2 11.406-2.086.568-.61 1.315-3.44.082-9.78l-12.53-64.49a5.998 5.998 0 015.89-7.144h32a6 6 0 015.89 4.855l13.178 67.825c3.093 15.921.447 27.864-7.86 35.5-7.929 7.281-21.209 10.82-40.6 10.82h-20.784l6.143 31.605a6.001 6.001 0 01-5.89 7.145m0-6l-7.53-38.75h28.061c17.657 0 29.836-3.082 36.54-9.238 6.702-6.16 8.71-16.14 6.031-29.938l-13.18-67.824h-32l12.531 64.488c1.426 7.336.902 12.34-1.574 15.008-2.477 2.668-7.746 4.004-15.805 4.004H281.56l-16.226-83.5h-31.5l28.328 145.75h31.5" fill="#fff"> </path> <path d="M409.55 145.307c12.065 0 21.072 2.225 26.77 6.61 5.639 4.34 9.533 11.862 11.575 22.354 1.903 9.806 1.178 16.653-2.155 20.348-3.407 3.774-10.773 5.688-21.893 5.688h-19.281l-10.69-55h15.674zm-63.062-67.75a2.999 2.999 0 00-2.945 3.572l28.328 145.75a3.002 3.002 0 002.946 2.428h61.053c19.189 0 33.47-5.21 42.448-15.487 9.025-10.33 11.81-24.771 8.283-42.921-1.438-7.394-3.907-14.261-7.342-20.41-3.44-6.154-7.984-11.85-13.511-16.93-6.616-6.191-14.104-10.681-22.236-13.323-8.003-2.607-18.281-3.93-30.548-3.93H388.24l-7.057-36.321a3.001 3.001 0 00-2.946-2.428h-31.75z"> </path> <path d="M407.04 197.307h16.807c13.421 0 18.083-2.945 19.667-4.7 2.63-2.914 3.125-9.058 1.435-17.766-1.898-9.75-5.417-16.664-10.458-20.546-5.162-3.974-13.554-5.988-24.94-5.988h-12.034l9.522 49zm28.83 35h-61.054a6 6 0 01-5.889-4.855L340.6 81.702a6 6 0 015.889-7.144h31.75a6 6 0 015.89 4.854l6.587 33.895h22.25c12.581 0 23.173 1.372 31.478 4.077 8.541 2.775 16.401 7.481 23.356 13.986 5.752 5.291 10.488 11.23 14.078 17.655 3.591 6.427 6.171 13.594 7.668 21.302 3.715 19.105.697 34.403-8.969 45.467-9.572 10.957-24.613 16.513-44.706 16.513m-45.632-90h19.312c12.801 0 22.336 2.411 28.601 7.234 6.267 4.824 10.492 12.875 12.688 24.157 2.102 10.832 1.145 18.476-2.87 22.93-4.02 4.452-12.06 6.68-24.122 6.68h-21.754l-11.855-61m45.632 84c18.367 0 31.766-4.82 40.188-14.462 8.422-9.64 10.957-23.098 7.597-40.375-1.383-7.117-3.722-13.624-7.015-19.519-3.297-5.899-7.602-11.293-12.922-16.184-6.34-5.933-13.383-10.16-21.133-12.679-7.75-2.525-17.62-3.782-29.62-3.782h-27.197l-7.53-38.75h-31.75l28.328 145.75h61.054" fill="#fff"> </path> </g> </svg> <span> PHP </span> </a> <a class="leafygreen-ui-18cpm0b" href="https://www.mongodb.com/docs/mongoid/master/api/Mongoid/Contextual/Mongo.html#find_one_and_replace-instance_method" target="_self"> <svg class="leafygreen-ui-x3zji3" height="24" preserveaspectratio="xMidYMid" viewbox="0 0 300 240" width="24" xmlns="http://www.w3.org/2000/svg"> <defs> <lineargradient id=":R3ht5qcmqn9:a" x1="84.75%" x2="58.254%" y1="111.399%" y2="64.584%"> <stop offset="0%" stop-color="#FB7655"> </stop> <stop offset="0%" stop-color="#FB7655"> </stop> <stop offset="41%" stop-color="#E42B1E"> </stop> <stop offset="99%" stop-color="#900"> </stop> <stop offset="100%" stop-color="#900"> </stop> </lineargradient> <lineargradient id=":R3ht5qcmqn9:b" x1="116.651%" x2="1.746%" y1="60.89%" y2="19.288%"> <stop offset="0%" stop-color="#871101"> </stop> <stop offset="0%" stop-color="#871101"> </stop> <stop offset="99%" stop-color="#911209"> </stop> <stop offset="100%" stop-color="#911209"> </stop> </lineargradient> <lineargradient id=":R3ht5qcmqn9:c" x1="75.774%" x2="38.978%" y1="219.327%" y2="7.829%"> <stop offset="0%" stop-color="#871101"> </stop> <stop offset="0%" stop-color="#871101"> </stop> <stop offset="99%" stop-color="#911209"> </stop> <stop offset="100%" stop-color="#911209"> </stop> </lineargradient> <lineargradient id=":R3ht5qcmqn9:d" x1="50.012%" x2="66.483%" y1="7.234%" y2="79.135%"> <stop offset="0%" stop-color="#FFF"> </stop> <stop offset="0%" stop-color="#FFF"> </stop> <stop offset="23%" stop-color="#E57252"> </stop> <stop offset="46%" stop-color="#DE3B20"> </stop> <stop offset="99%" stop-color="#A60003"> </stop> <stop offset="100%" stop-color="#A60003"> </stop> </lineargradient> <lineargradient id=":R3ht5qcmqn9:e" x1="46.174%" x2="49.932%" y1="16.348%" y2="83.047%"> <stop offset="0%" stop-color="#FFF"> </stop> <stop offset="0%" stop-color="#FFF"> </stop> <stop offset="23%" stop-color="#E4714E"> </stop> <stop offset="56%" stop-color="#BE1A0D"> </stop> <stop offset="99%" stop-color="#A80D00"> </stop> <stop offset="100%" stop-color="#A80D00"> </stop> </lineargradient> <lineargradient id=":R3ht5qcmqn9:f" x1="36.965%" x2="49.528%" y1="15.594%" y2="92.478%"> <stop offset="0%" stop-color="#FFF"> </stop> <stop offset="0%" stop-color="#FFF"> </stop> <stop offset="18%" stop-color="#E46342"> </stop> <stop offset="40%" stop-color="#C82410"> </stop> <stop offset="99%" stop-color="#A80D00"> </stop> <stop offset="100%" stop-color="#A80D00"> </stop> </lineargradient> <lineargradient id=":R3ht5qcmqn9:g" x1="13.609%" x2="85.764%" y1="58.346%" y2="-46.717%"> <stop offset="0%" stop-color="#FFF"> </stop> <stop offset="0%" stop-color="#FFF"> </stop> <stop offset="54%" stop-color="#C81F11"> </stop> <stop offset="99%" stop-color="#BF0905"> </stop> <stop offset="100%" stop-color="#BF0905"> </stop> </lineargradient> <lineargradient id=":R3ht5qcmqn9:h" x1="27.624%" x2="50.745%" y1="21.135%" y2="79.056%"> <stop offset="0%" stop-color="#FFF"> </stop> <stop offset="0%" stop-color="#FFF"> </stop> <stop offset="31%" stop-color="#DE4024"> </stop> <stop offset="99%" stop-color="#BF190B"> </stop> <stop offset="100%" stop-color="#BF190B"> </stop> </lineargradient> <lineargradient id=":R3ht5qcmqn9:i" x1="-20.667%" x2="104.242%" y1="122.282%" y2="-6.342%"> <stop offset="0%" stop-color="#BD0012"> </stop> <stop offset="0%" stop-color="#BD0012"> </stop> <stop offset="7%" stop-color="#FFF"> </stop> <stop offset="17%" stop-color="#FFF"> </stop> <stop offset="27%" stop-color="#C82F1C"> </stop> <stop offset="33%" stop-color="#820C01"> </stop> <stop offset="46%" stop-color="#A31601"> </stop> <stop offset="72%" stop-color="#B31301"> </stop> <stop offset="99%" stop-color="#E82609"> </stop> <stop offset="100%" stop-color="#E82609"> </stop> </lineargradient> <lineargradient id=":R3ht5qcmqn9:j" x1="58.792%" x2="11.964%" y1="65.205%" y2="50.128%"> <stop offset="0%" stop-color="#8C0C01"> </stop> <stop offset="0%" stop-color="#8C0C01"> </stop> <stop offset="54%" stop-color="#990C00"> </stop> <stop offset="99%" stop-color="#A80D0E"> </stop> <stop offset="100%" stop-color="#A80D0E"> </stop> </lineargradient> <lineargradient id=":R3ht5qcmqn9:k" x1="79.319%" x2="23.088%" y1="62.754%" y2="17.888%"> <stop offset="0%" stop-color="#7E110B"> </stop> <stop offset="0%" stop-color="#7E110B"> </stop> <stop offset="99%" stop-color="#9E0C00"> </stop> <stop offset="100%" stop-color="#9E0C00"> </stop> </lineargradient> <lineargradient id=":R3ht5qcmqn9:l" x1="92.88%" x2="59.841%" y1="74.122%" y2="39.704%"> <stop offset="0%" stop-color="#79130D"> </stop> <stop offset="0%" stop-color="#79130D"> </stop> <stop offset="99%" stop-color="#9E120B"> </stop> <stop offset="100%" stop-color="#9E120B"> </stop> </lineargradient> <lineargradient id=":R3ht5qcmqn9:o" x1="56.57%" x2="3.105%" y1="101.717%" y2="11.993%"> <stop offset="0%" stop-color="#8B2114"> </stop> <stop offset="0%" stop-color="#8B2114"> </stop> <stop offset="43%" stop-color="#9E100A"> </stop> <stop offset="99%" stop-color="#B3100C"> </stop> <stop offset="100%" stop-color="#B3100C"> </stop> </lineargradient> <lineargradient id=":R3ht5qcmqn9:p" x1="30.87%" x2="92.471%" y1="35.599%" y2="100.694%"> <stop offset="0%" stop-color="#B31000"> </stop> <stop offset="0%" stop-color="#B31000"> </stop> <stop offset="44%" stop-color="#910F08"> </stop> <stop offset="99%" stop-color="#791C12"> </stop> <stop offset="100%" stop-color="#791C12"> </stop> </lineargradient> <radialgradient cx="32.001%" cy="40.21%" fx="32.001%" fy="40.21%" id=":R3ht5qcmqn9:m" r="69.573%"> <stop offset="0%" stop-color="#A80D00"> </stop> <stop offset="0%" stop-color="#A80D00"> </stop> <stop offset="99%" stop-color="#7E0E08"> </stop> <stop offset="100%" stop-color="#7E0E08"> </stop> </radialgradient> <radialgradient cx="13.549%" cy="40.86%" fx="13.549%" fy="40.86%" id=":R3ht5qcmqn9:n" r="88.386%"> <stop offset="0%" stop-color="#A30C00"> </stop> <stop offset="0%" stop-color="#A30C00"> </stop> <stop offset="99%" stop-color="#800E08"> </stop> <stop offset="100%" stop-color="#800E08"> </stop> </radialgradient> </defs> <path d="M197.467 167.764l-145.52 86.41 188.422-12.787L254.88 51.393l-57.414 116.37z" fill="url(#:R3ht5qcmqn9:a)"> </path> <path d="M240.677 241.257L224.482 129.48l-44.113 58.25 60.308 53.528z" fill="url(#:R3ht5qcmqn9:b)"> </path> <path d="M240.896 241.257l-118.646-9.313-69.674 21.986 188.32-12.673z" fill="url(#:R3ht5qcmqn9:c)"> </path> <path d="M52.744 253.955l29.64-97.1L17.16 170.8l35.583 83.154z" fill="url(#:R3ht5qcmqn9:d)"> </path> <path d="M180.358 188.05L153.085 81.226l-78.047 73.16 105.32 33.666z" fill="url(#:R3ht5qcmqn9:e)"> </path> <path d="M248.693 82.73l-73.777-60.256-20.544 66.418 94.321-6.162z" fill="url(#:R3ht5qcmqn9:f)"> </path> <path d="M214.191.99L170.8 24.97 143.424.669l70.767.322z" fill="url(#:R3ht5qcmqn9:g)"> </path> <path d="M0 203.372l18.177-33.151-14.704-39.494L0 203.372z" fill="url(#:R3ht5qcmqn9:h)"> </path> <path d="M2.496 129.48l14.794 41.963 64.283-14.422 73.39-68.207 20.712-65.787L143.063 0 87.618 20.75c-17.469 16.248-51.366 48.396-52.588 49-1.21.618-22.384 40.639-32.534 59.73z" fill="#FFF"> </path> <path d="M54.442 54.094c37.86-37.538 86.667-59.716 105.397-40.818 18.72 18.898-1.132 64.823-38.992 102.349-37.86 37.525-86.062 60.925-104.78 42.027-18.73-18.885.515-66.032 38.375-103.558z" fill="url(#:R3ht5qcmqn9:i)"> </path> <path d="M52.744 253.916l29.408-97.409 97.665 31.376c-35.312 33.113-74.587 61.106-127.073 66.033z" fill="url(#:R3ht5qcmqn9:j)"> </path> <path d="M155.092 88.622l25.073 99.313c29.498-31.016 55.972-64.36 68.938-105.603l-94.01 6.29z" fill="url(#:R3ht5qcmqn9:k)"> </path> <path d="M248.847 82.833c10.035-30.282 12.35-73.725-34.966-81.791l-38.825 21.445 73.791 60.346z" fill="url(#:R3ht5qcmqn9:l)"> </path> <path d="M0 202.935c1.39 49.979 37.448 50.724 52.808 51.162l-35.48-82.86L0 202.935z" fill="#9E1209"> </path> <path d="M155.232 88.777c22.667 13.932 68.35 41.912 69.276 42.426 1.44.81 19.695-30.784 23.838-48.64l-93.114 6.214z" fill="url(#:R3ht5qcmqn9:m)"> </path> <path d="M82.113 156.507l39.313 75.848c23.246-12.607 41.45-27.967 58.121-44.42l-97.434-31.428z" fill="url(#:R3ht5qcmqn9:n)"> </path> <path d="M17.174 171.34l-5.57 66.328c10.51 14.357 24.97 15.605 40.136 14.486-10.973-27.311-32.894-81.92-34.566-80.814z" fill="url(#:R3ht5qcmqn9:o)"> </path> <path d="M174.826 22.654l78.1 10.96c-4.169-17.662-16.969-29.06-38.787-32.623l-39.313 21.663z" fill="url(#:R3ht5qcmqn9:p)"> </path> </svg> <span> Mongoid </span> </a> <a class="leafygreen-ui-18cpm0b" href="https://www.mongodb.com/docs/drivers/rust/current/fundamentals/crud/compound-operations/#find-and-replace-a-document" target="_self"> <svg class="leafygreen-ui-x3zji3" height="24" viewbox="0 0 30 30" width="24" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_5454_14623)"> <path d="M15.2561 3.08398C8.56014 3.08398 3.11035 8.53634 3.11035 15.2297C3.11035 21.9231 8.56271 27.3755 15.2561 27.3755C21.9495 27.3755 27.4019 21.9231 27.4019 15.2297C27.4019 8.53634 21.9495 3.08398 15.2561 3.08398ZM15.2381 4.16315C15.4458 4.16853 15.6432 4.25509 15.7881 4.40437C15.9331 4.55365 16.0142 4.75384 16.0141 4.96225C16.0141 5.17418 15.9299 5.37744 15.7801 5.5273C15.6302 5.67715 15.4269 5.76134 15.215 5.76134C15.0031 5.76134 14.7998 5.67715 14.65 5.5273C14.5001 5.37744 14.4159 5.17418 14.4159 4.96225C14.4159 4.85533 14.4373 4.7495 14.4789 4.65101C14.5205 4.55252 14.5814 4.46338 14.6581 4.38887C14.7347 4.31435 14.8256 4.25598 14.9252 4.21721C15.0249 4.17844 15.1313 4.16006 15.2381 4.16315ZM17.0676 5.47871C18.4704 5.74146 19.7992 6.30644 20.9617 7.13439C22.1242 7.96235 23.0926 9.03345 23.7995 10.2733L22.8565 12.4008C22.6947 12.7682 22.8617 13.1999 23.2265 13.3643L25.0406 14.1686C25.0968 14.7356 25.1037 15.3065 25.0611 15.8747H24.0513C23.9511 15.8747 23.91 15.9415 23.91 16.0391V16.5016C23.91 17.5911 23.2959 17.83 22.7563 17.8891C22.2424 17.9482 21.6746 17.6733 21.6026 17.3598C21.2994 15.6563 20.7958 15.294 19.9993 14.6645C20.9885 14.0375 22.0163 13.11 22.0163 11.8715C22.0163 10.5328 21.099 9.69002 20.4747 9.27634C19.5959 8.69822 18.6247 8.5826 18.3626 8.5826H7.93063C9.37312 6.97114 11.3066 5.88021 13.4318 5.47871L14.6626 6.76857C14.9401 7.05891 15.4 7.07176 15.6903 6.79169L17.0676 5.47871ZM5.71063 11.3936C5.91853 11.3996 6.11589 11.4864 6.26079 11.6356C6.40568 11.7849 6.48669 11.9847 6.4866 12.1927C6.4866 12.4046 6.40241 12.6079 6.25255 12.7577C6.10269 12.9076 5.89944 12.9918 5.6875 12.9918C5.47557 12.9918 5.27232 12.9076 5.12246 12.7577C4.9726 12.6079 4.88841 12.4046 4.88841 12.1927C4.88836 12.0858 4.90977 11.9799 4.95137 11.8814C4.99297 11.7829 5.0539 11.6938 5.13057 11.6193C5.20724 11.5448 5.29809 11.4864 5.39772 11.4476C5.49736 11.4089 5.60376 11.3905 5.71063 11.3936ZM24.7631 11.4295C24.971 11.4356 25.1683 11.5224 25.3132 11.6716C25.4581 11.8208 25.5391 12.0206 25.539 12.2286C25.539 12.4406 25.4548 12.6438 25.305 12.7937C25.1551 12.9435 24.9519 13.0277 24.7399 13.0277C24.528 13.0277 24.3247 12.9435 24.1749 12.7937C24.025 12.6438 23.9408 12.4406 23.9408 12.2286C23.9408 12.1217 23.9622 12.0159 24.0038 11.9174C24.0454 11.8189 24.1063 11.7298 24.183 11.6553C24.2597 11.5807 24.3505 11.5224 24.4502 11.4836C24.5498 11.4448 24.6562 11.4264 24.7631 11.4295ZM7.21632 11.558H8.60896V17.8377H5.79799C5.45083 16.6186 5.34264 15.3439 5.47938 14.0838L7.20091 13.3181C7.56834 13.1536 7.73535 12.7245 7.57091 12.3571L7.21632 11.558ZM13.0284 11.6248H16.3456C16.5177 11.6248 17.5558 11.8227 17.5558 12.6012C17.5558 13.2461 16.7592 13.4774 16.104 13.4774H13.0258L13.0284 11.6248ZM13.0284 16.1368H15.5696C15.8008 16.1368 16.8106 16.2036 17.1318 17.4934C17.232 17.8891 17.4556 19.179 17.6072 19.5927C17.7588 20.0552 18.3729 20.9802 19.0281 20.9802H23.1751C22.8972 21.3524 22.5933 21.7044 22.2656 22.0336L20.5774 21.6713C20.1843 21.5866 19.7963 21.8384 19.7115 22.2315L19.3107 24.102C18.0217 24.6859 16.622 24.9848 15.2069 24.9781C13.7919 24.9714 12.395 24.6595 11.1116 24.0635L10.7108 22.1929C10.626 21.7998 10.2406 21.548 9.84743 21.6328L8.19528 21.9874C7.88869 21.6711 7.6037 21.3346 7.34223 20.9802H15.3769C15.4668 20.9802 15.5285 20.9647 15.5285 20.88V18.0381C15.5285 17.9559 15.4668 17.9379 15.3769 17.9379H13.0258L13.0284 16.1368ZM9.3207 22.6452C9.5286 22.6512 9.72596 22.738 9.87085 22.8872C10.0157 23.0364 10.0968 23.2363 10.0967 23.4443C10.0967 23.6562 10.0125 23.8594 9.86262 24.0093C9.71276 24.1592 9.50951 24.2434 9.29757 24.2434C9.08564 24.2434 8.88239 24.1592 8.73253 24.0093C8.58267 23.8594 8.49848 23.6562 8.49848 23.4443C8.49843 23.3373 8.51984 23.2315 8.56144 23.133C8.60303 23.0345 8.66397 22.9454 8.74064 22.8709C8.81731 22.7964 8.90815 22.738 9.00779 22.6992C9.10743 22.6605 9.21383 22.6421 9.3207 22.6452ZM21.153 22.6811C21.3609 22.6872 21.5583 22.774 21.7031 22.9232C21.848 23.0724 21.929 23.2722 21.929 23.4802C21.929 23.6922 21.8448 23.8954 21.6949 24.0453C21.5451 24.1951 21.3418 24.2793 21.1299 24.2793C20.9179 24.2793 20.7147 24.1951 20.5648 24.0453C20.415 23.8954 20.3308 23.6922 20.3308 23.4802C20.3307 23.3733 20.3521 23.2675 20.3937 23.169C20.4353 23.0705 20.4963 22.9814 20.5729 22.9068C20.6496 22.8323 20.7404 22.774 20.8401 22.7352C20.9397 22.6964 21.0461 22.678 21.153 22.6811Z" fill="black"> </path> <path clip-rule="evenodd" d="M26.7232 15.2304C26.7232 18.2717 25.515 21.1885 23.3645 23.3391C21.2139 25.4896 18.2971 26.6978 15.2558 26.6978C12.2144 26.6978 9.29761 25.4896 7.14705 23.3391C4.99649 21.1885 3.78832 18.2717 3.78832 15.2304C3.78832 12.189 4.99649 9.27222 7.14705 7.12166C9.29761 4.9711 12.2144 3.76293 15.2558 3.76293C18.2971 3.76293 21.2139 4.9711 23.3645 7.12166C25.515 9.27222 26.7232 12.189 26.7232 15.2304ZM26.5073 14.1229L28.2957 15.2304L26.5073 16.3378L28.0439 17.7741L26.0757 18.5115L27.3039 20.2202L25.2252 20.5594L26.0988 22.4762L23.9944 22.4017L24.4775 24.4521L22.4271 23.969L22.5016 26.0734L20.5848 25.1998L20.2456 27.2785L18.5369 26.0503L17.7995 28.0185L16.3632 26.482L15.2558 28.2703L14.1483 26.482L12.712 28.0185L11.9746 26.0503L10.2659 27.2785L9.92672 25.1998L8.00992 26.0734L8.08443 23.969L6.03401 24.4521L6.51707 22.4017L4.4127 22.4762L5.28631 20.5594L3.20763 20.2202L4.43582 18.5115L2.46763 17.7741L4.00415 16.3378L2.21582 15.2304L4.00415 14.1229L2.46763 12.6866L4.43582 11.9492L3.20763 10.2405L5.28631 9.90133L4.4127 7.98453L6.51707 8.05904L6.03401 6.00862L8.08443 6.49168L8.00992 4.3873L9.92672 5.26092L10.2659 3.18223L11.9746 4.41043L12.712 2.44224L14.1483 3.97876L15.2558 2.19043L16.3632 3.97876L17.7995 2.44224L18.5369 4.41043L20.2456 3.18223L20.5848 5.26092L22.5016 4.3873L22.4271 6.49168L24.4775 6.00862L23.9944 8.05904L26.0988 7.98453L25.2252 9.90133L27.3039 10.2405L26.0757 11.9492L28.0439 12.6866L26.5073 14.1229Z" fill="black" fill-rule="evenodd" stroke-linecap="round" stroke-linejoin="round"> </path> </g> <defs> <clippath id="clip0_5454_14623"> <rect fill="black" height="30" width="30"> </rect> </clippath> </defs> </svg> <span> Rust </span> </a> <a class="leafygreen-ui-18cpm0b" href="https://mongodb.github.io/mongo-java-driver/5.2/apidocs/mongo-scala-driver/org/mongodb/scala/MongoCollection.html#findOneAndReplace(clientSession:org.mongodb.scala.ClientSession,filter:org.mongodb.scala.bson.conversions.Bson,replacement:TResult,options:org.mongodb.scala.model.FindOneAndReplaceOptions):org.mongodb.scala.SingleObservable[TResult]" target="_self"> <svg class="leafygreen-ui-x3zji3" height="24" viewbox="0 0 70 70" width="24" xmlns="http://www.w3.org/2000/svg"> <defs> <lineargradient id=":R3pt5qcmqn9:aaa" x1=".006%" x2="96.837%" y1="49.998%" y2="49.998%"> <stop offset="0%" stop-color="#CD413F"> </stop> <stop offset="75.091%" stop-color="#CD4543"> </stop> <stop offset="100%" stop-color="#D04543"> </stop> </lineargradient> </defs> <g fill="none" fill-rule="nonzero"> <path d="M13 39v5c0 .843 17.73 2.255 29.28 5 5.582-1.327 9.72-2.966 9.72-5v-5c0-2.034-4.138-3.673-9.72-5C30.73 36.745 13 38.157 13 39M13 20v5c0 .843 17.73 2.255 29.28 5 5.582-1.327 9.72-2.966 9.72-5v-5c0-2.034-4.138-3.673-9.72-5C30.73 17.745 13 19.157 13 20" fill="#731818"> </path> <g fill="url(#:R3pt5qcmqn9:aaa)" transform="translate(13)"> <path d="M0 29.53v14.766c0-1.232 39-3.692 39-9.844V19.686c0 6.152-39 8.612-39 9.844M0 9.843V24.61c0-1.231 39-3.691 39-9.843V0C39 6.152 0 8.612 0 9.843M0 49.216v14.766c0-1.231 39-3.691 39-9.843V39.373c0 6.151-39 8.612-39 9.843"> </path> </g> </g> </svg> <span> Scala </span> </a> </div> <button class="leafygreen-ui-ki2t97"> Show all <svg aria-label="Chevron Down Icon" class="" fill="none" height="16" role="img" viewbox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M1.636 5.364a1 1 0 0 0 0 1.414l4.95 4.95.707.707a1 1 0 0 0 1.414 0l.707-.707 4.95-4.95a1 1 0 0 0 0-1.414l-.707-.707a1 1 0 0 0-1.414 0L8 8.899 3.757 4.657a1 1 0 0 0-1.414 0l-.707.707Z" fill="currentColor" fill-rule="evenodd"> </path> </svg> </button> </div> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Definition <a class="headerlink leafygreen-ui-1kepx47" href="#definition" 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="definition"> </div> </a> </h2> <dl class="method"> <dt> <code class="leafygreen-ui-1l06pbn"> db.collection.findOneAndReplace( filter, replacement, options ) </code> <a class="headerlink leafygreen-ui-1kepx47" href="#mongodb-method-db.collection.findOneAndReplace" title="Permalink to this definition"> <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="mongodb-method-db.collection.findOneAndReplace"> </div> </a> </dt> <dd> <p class="leafygreen-ui-1kp3ins"> Replaces a single document based on the specified <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-findOneAndReplace-filter" target="_self"> <span> filter <!-- --> . </span> </a> </p> </dd> </dl> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Syntax <a class="headerlink leafygreen-ui-1kepx47" href="#syntax" 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="syntax"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> The <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-method-db.collection.findOneAndReplace" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> findOneAndReplace() </code> </span> </a> method has the following form: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.collection.findOneAndReplace(\n &lt;filter&gt;,\n &lt;replacement&gt;,\n {\n writeConcern: &lt;document&gt;,\n projection: &lt;document&gt;,\n sort: &lt;document&gt;,\n maxTimeMS: &lt;number&gt;,\n upsert: &lt;boolean&gt;,\n returnDocument: &lt;string&gt;,\n returnNewDocument: &lt;boolean&gt;,\n collation: &lt;document&gt;\n }\n)","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">findOneAndReplace</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> &lt;<!-- -->filter<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->&lt;<!-- -->replacement<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">writeConcern</span>: &lt;<span class="lg-highlight-variable lg-highlight-language">document</span>&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">projection</span>: &lt;<span class="lg-highlight-variable lg-highlight-language">document</span>&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">sort</span>: &lt;<span class="lg-highlight-variable lg-highlight-language">document</span>&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">maxTimeMS</span>: &lt;<!-- -->number<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">upsert</span>: &lt;<!-- -->boolean<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">returnDocument</span>: &lt;<!-- -->string<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">returnNewDocument</span>: &lt;<!-- -->boolean<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">collation</span>: &lt;<span class="lg-highlight-variable lg-highlight-language">document</span>&gt;</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->}</td></tr><tr class=""><td class="leafygreen-ui-7razhx">)</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> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Fields and Options <a class="headerlink leafygreen-ui-1kepx47" href="#fields-and-options" 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="fields-and-options"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> The <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-method-db.collection.findOneAndReplace" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> findOneAndReplace() </code> </span> </a> method takes the following fields and options: </p> <div class="leafygreen-ui-skkc39" tabindex="0"> <table class="leafygreen-ui-hr8lsv"> <colgroup> <col style="width:20%"/> <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> Field </div> </div> </th> <th class="leafygreen-ui-13uteka" role="columnheader" scope="col"> <div class="leafygreen-ui-ui0te9"> <div> Type </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="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-findOneAndReplace-filter" target="_self"> <span> filter </span> </a> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> document </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <span class="leafygreen-ui-1qnjd6d" id="std-label-findOneAndReplace-filter"> </span> <p class="leafygreen-ui-1kp3ins"> The selection criteria for the update. The same <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/query/#std-label-query-selectors"> query selectors </a> as in the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/db.collection.find/#mongodb-method-db.collection.find"> <code class="leafygreen-ui-1l06pbn"> find() </code> </a> method are available. </p> <p class="leafygreen-ui-1kp3ins"> To replace the first document returned in the collection, specify an empty document <code class="leafygreen-ui-1l06pbn"> { } </code> . </p> <p class="leafygreen-ui-1kp3ins"> If unspecified, defaults to an empty document. </p> <p class="leafygreen-ui-1kp3ins"> If the query argument is not a document, the operation returns an error. </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="#std-label-findOneAndReplace-replacement" target="_self"> <span> replacement </span> </a> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> document </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <span class="leafygreen-ui-1qnjd6d" id="std-label-findOneAndReplace-replacement"> </span> <p class="leafygreen-ui-1kp3ins"> The replacement document. </p> <p class="leafygreen-ui-1kp3ins"> Cannot contain <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/update/#std-label-update-operators-top-level"> update operators <!-- --> . </a> </p> <p class="leafygreen-ui-1kp3ins"> The <code class="leafygreen-ui-1l06pbn"> &lt;replacement&gt; </code> document cannot specify an <code class="leafygreen-ui-1l06pbn"> _id </code> value that differs from the replaced document. </p> </div> </div> </td> </tr> <tr class="leafygreen-ui-15dvrnp"> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> writeConcern </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> document </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <p class="leafygreen-ui-1kp3ins"> Optional. A document expressing the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/write-concern/#std-label-write-concern"> write concern </a> . Omit to use the default write concern. </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ w: &lt;value&gt;, j: &lt;boolean&gt;, wtimeout: &lt;number&gt; }","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-1q4bxgx" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-attr">w</span>: &lt;<!-- -->value<!-- -->&gt;<!-- -->,<!-- --> <span class="lg-highlight-attr">j</span>: &lt;<!-- -->boolean<!-- -->&gt;<!-- -->,<!-- --> <span class="lg-highlight-attr">wtimeout</span>: &lt;<!-- -->number<!-- -->&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"> Do not explicitly set the write concern for the operation if run in a transaction. To use write concern with transactions, see <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/transactions/#std-label-transactions-write-concern"> Transactions and Write Concern <!-- --> . </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="#std-label-findOneAndReplace-projection" target="_self"> <span> projection </span> </a> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> document </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <span class="leafygreen-ui-1qnjd6d" id="std-label-findOneAndReplace-projection"> </span> <p class="leafygreen-ui-1kp3ins"> Optional. A subset of fields to return. </p> <p class="leafygreen-ui-1kp3ins"> To return all fields in the matching document, omit this field. </p> <p class="leafygreen-ui-1kp3ins"> If the projection argument is not a document, the operation errors. </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="#std-label-findOneAndReplace-sort" target="_self"> <span> sort </span> </a> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> document </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <span class="leafygreen-ui-1qnjd6d" id="std-label-findOneAndReplace-sort"> </span> <p class="leafygreen-ui-1kp3ins"> Optional. Specifies a sorting order for the documents matched by the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-findOneAndReplace-filter" target="_self"> <span> filter <!-- --> . </span> </a> </p> <p class="leafygreen-ui-1kp3ins"> If the sort argument is not a document, the operation errors. </p> <p class="leafygreen-ui-1kp3ins"> See <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/cursor.sort/#mongodb-method-cursor.sort"> <code class="leafygreen-ui-1l06pbn"> cursor.sort() </code> . </a> </p> </div> </div> </td> </tr> <tr class="leafygreen-ui-15dvrnp"> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> maxTimeMS </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> number </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Optional. Specifies a time limit in milliseconds within which the operation must complete. Returns an error if the limit is exceeded. </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="#std-label-findOneAndReplace-upsert" target="_self"> <span> upsert </span> </a> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> boolean </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <span class="leafygreen-ui-1qnjd6d" id="std-label-findOneAndReplace-upsert"> </span> <p class="leafygreen-ui-1kp3ins"> Optional. When <code class="leafygreen-ui-1l06pbn"> true </code> , <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-method-db.collection.findOneAndReplace" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> findOneAndReplace() </code> </span> </a> either: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Inserts the document from the <code class="leafygreen-ui-1l06pbn"> replacement </code> parameter if no document matches the <code class="leafygreen-ui-1l06pbn"> filter </code> . Returns <code class="leafygreen-ui-1l06pbn"> null </code> after inserting the new document, unless <code class="leafygreen-ui-1l06pbn"> returnNewDocument </code> is <code class="leafygreen-ui-1l06pbn"> true </code> . </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Replaces the document that matches the <code class="leafygreen-ui-1l06pbn"> filter </code> with the <code class="leafygreen-ui-1l06pbn"> replacement </code> document. </p> </li> </ul> <p class="leafygreen-ui-1kp3ins"> MongoDB will add the <code class="leafygreen-ui-1l06pbn"> _id </code> field to the replacement document if it is not specified in either the <code class="leafygreen-ui-1l06pbn"> filter </code> or <code class="leafygreen-ui-1l06pbn"> replacement </code> documents. If <code class="leafygreen-ui-1l06pbn"> _id </code> is present in both, the values must be equal. </p> <p class="leafygreen-ui-1kp3ins"> To avoid multiple upserts, ensure that the <code class="leafygreen-ui-1l06pbn"> query </code> fields are <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/index-unique/#std-label-index-type-unique"> uniquely indexed <!-- --> . </a> </p> <p class="leafygreen-ui-1kp3ins"> Defaults to <code class="leafygreen-ui-1l06pbn"> false </code> . </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="#std-label-findOneAndReplace-returnDocument" target="_self"> <span> returnDocument </span> </a> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> string </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <span class="leafygreen-ui-1qnjd6d" id="std-label-findOneAndReplace-returnDocument"> </span> <p class="leafygreen-ui-1kp3ins"> Optional. Starting in <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/mongodb-shell/#mongodb-binary-bin.mongosh" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongosh </code> </span> </a> 0.13.2, <code class="leafygreen-ui-1l06pbn"> returnDocument </code> is an alternative for <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-findOneAndReplace-returnNewDocument" target="_self"> <span> returnNewDocument </span> </a> . If both options are set, <code class="leafygreen-ui-1l06pbn"> returnDocument </code> takes precedence. </p> <p class="leafygreen-ui-1kp3ins"> <code class="leafygreen-ui-1l06pbn"> returnDocument: "before" </code> returns the original document. <code class="leafygreen-ui-1l06pbn"> returnDocument: "after" </code> returns the updated document. </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="#std-label-findOneAndReplace-returnNewDocument" target="_self"> <span> returnNewDocument </span> </a> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> boolean </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <span class="leafygreen-ui-1qnjd6d" id="std-label-findOneAndReplace-returnNewDocument"> </span> <p class="leafygreen-ui-1kp3ins"> Optional. When <code class="leafygreen-ui-1l06pbn"> true </code> , returns the replacement document instead of the original document. </p> <p class="leafygreen-ui-1kp3ins"> Defaults to <code class="leafygreen-ui-1l06pbn"> false </code> . </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="#std-label-findOneAndReplace-collation" target="_self"> <span> collation </span> </a> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> document </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <span class="leafygreen-ui-1qnjd6d" id="std-label-findOneAndReplace-collation"> </span> <p class="leafygreen-ui-1kp3ins"> Optional. </p> <p class="leafygreen-ui-1kp3ins"> Specifies the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/collation/#std-label-collation"> collation </a> to use for the operation. </p> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/collation/#std-label-collation"> Collation </a> allows users to specify language-specific rules for string comparison, such as rules for lettercase and accent marks. </p> <p class="leafygreen-ui-1kp3ins"> The collation option has the following syntax: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"collation: {\n locale: &lt;string&gt;,\n caseLevel: &lt;boolean&gt;,\n caseFirst: &lt;string&gt;,\n strength: &lt;int&gt;,\n numericOrdering: &lt;boolean&gt;,\n alternate: &lt;string&gt;,\n maxVariable: &lt;string&gt;,\n backwards: &lt;boolean&gt;\n}"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" tabindex="-1"><code class="lg-highlight-hljs-light none leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">collation: {</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> locale: &lt;string&gt;,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> caseLevel: &lt;boolean&gt;,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> caseFirst: &lt;string&gt;,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> strength: &lt;int&gt;,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> numericOrdering: &lt;boolean&gt;,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> alternate: &lt;string&gt;,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> maxVariable: &lt;string&gt;,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> backwards: &lt;boolean&gt;</td></tr><tr class=""><td class="leafygreen-ui-7razhx">}</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"> When specifying collation, the <code class="leafygreen-ui-1l06pbn"> locale </code> field is mandatory; all other collation fields are optional. For descriptions of the fields, see <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/collation/#std-label-collation-document-fields"> Collation Document <!-- --> . </a> </p> <p class="leafygreen-ui-1kp3ins"> If the collation is unspecified but the collection has a default collation (see <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/db.createCollection/#mongodb-method-db.createCollection"> <code class="leafygreen-ui-1l06pbn"> db.createCollection() </code> </a> ), the operation uses the collation specified for the collection. </p> <p class="leafygreen-ui-1kp3ins"> If no collation is specified for the collection or for the operations, MongoDB uses the simple binary comparison used in prior versions for string comparisons. </p> <p class="leafygreen-ui-1kp3ins"> You cannot specify multiple collations for an operation. For example, you cannot specify different collations per field, or if performing a find with a sort, you cannot use one collation for the find and another for the sort. </p> </div> </div> </td> </tr> </tbody> </table> </div> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Returns <a class="headerlink leafygreen-ui-1kepx47" href="#returns" 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="returns"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> Returns the original document by default. Returns the updated document if <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-findOneAndReplace-returnDocument" target="_self"> <span> returnDocument </span> </a> is set to <code class="leafygreen-ui-1l06pbn"> after </code> or <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-findOneAndReplace-returnNewDocument" target="_self"> <span> returnNewDocument </span> </a> is set to <code class="leafygreen-ui-1l06pbn"> true </code> . </p> </section> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Behavior <a class="headerlink leafygreen-ui-1kepx47" href="#behavior" 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="behavior"> </div> </a> </h2> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Document Match <a class="headerlink leafygreen-ui-1kepx47" href="#document-match" 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="document-match"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-method-db.collection.findOneAndReplace" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> db.collection.findOneAndReplace() </code> </span> </a> replaces the first matching document in the collection that matches the <code class="leafygreen-ui-1l06pbn"> filter </code> . The <code class="leafygreen-ui-1l06pbn"> sort </code> field can be used to influence which document is modified. </p> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Projection <a class="headerlink leafygreen-ui-1kepx47" href="#projection" 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="projection"> </div> </a> </h3> <div class="leafygreen-ui-85da11" role="note"> <h2 class="leafygreen-ui-1ac4g5h"> Important </h2> <h3 class="leafygreen-ui-144d5kf"> <strong> Language Consistency </strong> </h3> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> As part of making <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/db.collection.find/#mongodb-method-db.collection.find"> <code class="leafygreen-ui-1l06pbn"> find() </code> </a> and <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/db.collection.findAndModify/#mongodb-method-db.collection.findAndModify"> <code class="leafygreen-ui-1l06pbn"> findAndModify() </code> </a> projection consistent with aggregation's <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, </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> The <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/db.collection.find/#mongodb-method-db.collection.find"> <code class="leafygreen-ui-1l06pbn"> find() </code> </a> and <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/db.collection.findAndModify/#mongodb-method-db.collection.findAndModify"> <code class="leafygreen-ui-1l06pbn"> findAndModify() </code> </a> projection can accept <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/#std-label-aggregation-expressions"> aggregation expressions and syntax <!-- --> . </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> MongoDB enforces additional restrictions with regards to projections. See <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/limits/#mongodb-limit-Projection-Restrictions"> Projection Restrictions </a> for details. </p> </li> </ul> </div> </div> <p class="leafygreen-ui-1kp3ins"> The <code class="leafygreen-ui-1l06pbn"> projection </code> field takes a document in the following form: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ field1: &lt;value&gt;, field2: &lt;value&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">{ <span class="lg-highlight-attr">field1</span>: &lt;<!-- -->value<!-- -->&gt;<!-- -->,<!-- --> <span class="lg-highlight-attr">field2</span>: &lt;<!-- -->value<!-- -->&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:40%"/> <col style="width:60%"/> </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> Projection </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> <code class="leafygreen-ui-1l06pbn"> &lt;field&gt;: &lt;1 or true&gt; </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Specifies the inclusion of a field. If you specify a non-zero integer for the projection value, the operation treats the value as <code class="leafygreen-ui-1l06pbn"> true </code> . </div> </div> </td> </tr> <tr class="leafygreen-ui-15dvrnp"> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> &lt;field&gt;: &lt;0 or false&gt; </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Specifies the exclusion of a field. </div> </div> </td> </tr> <tr class="leafygreen-ui-15dvrnp"> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> "&lt;field&gt;.$": &lt;1 or true&gt; </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <p class="leafygreen-ui-1kp3ins"> Uses the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/projection/positional/#mongodb-projection-proj.-"> <code class="leafygreen-ui-1l06pbn"> $ </code> </a> array projection operator to return the first element that matches the query condition on the array field. If you specify a non-zero integer for the projection value, the operation treats the value as <code class="leafygreen-ui-1l06pbn"> true </code> . </p> <p class="leafygreen-ui-1kp3ins"> Not available for <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/views/#std-label-views-landing-page"> views <!-- --> . </a> </p> </div> </div> </td> </tr> <tr class="leafygreen-ui-15dvrnp"> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> &lt;field&gt;: &lt;array projection&gt; </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <p class="leafygreen-ui-1kp3ins"> Uses the array projection operators ( <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/projection/elemMatch/#mongodb-projection-proj.-elemMatch"> <code class="leafygreen-ui-1l06pbn"> $elemMatch </code> </a> , <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/projection/slice/#mongodb-projection-proj.-slice"> <code class="leafygreen-ui-1l06pbn"> $slice </code> </a> ) to specify the array elements to include. </p> <p class="leafygreen-ui-1kp3ins"> Not available for <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/views/#std-label-views-landing-page"> views <!-- --> . </a> </p> </div> </div> </td> </tr> <tr class="leafygreen-ui-15dvrnp"> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> &lt;field&gt;: &lt;aggregation expression&gt; </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <p class="leafygreen-ui-1kp3ins"> Specifies the value of the projected field. </p> <p class="leafygreen-ui-1kp3ins"> With the use of <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/#std-label-aggregation-expressions"> aggregation expressions and syntax </a> , including the use of literals and aggregation variables, you can project new fields or project existing fields with new values. </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> If you specify a non-numeric, non-boolean literal (such as a literal string or an array or an operator expression) for the projection value, the field is projected with the new value, for example: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <code class="leafygreen-ui-1l06pbn"> { field: [ 1, 2, 3, "$someExistingField" ] } </code> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <code class="leafygreen-ui-1l06pbn"> { field: "New String Value" } </code> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <code class="leafygreen-ui-1l06pbn"> { field: { status: "Active", total: { $sum: "$existingArray" } } } </code> </p> </li> </ul> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> To project a literal value for a field, use the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/literal/#mongodb-expression-exp.-literal"> <code class="leafygreen-ui-1l06pbn"> $literal </code> </a> aggregation expression, for example: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <code class="leafygreen-ui-1l06pbn"> { field: { $literal: 5 } } </code> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <code class="leafygreen-ui-1l06pbn"> { field: { $literal: true } } </code> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <code class="leafygreen-ui-1l06pbn"> { field: { $literal: { fieldWithValue0: 0, fieldWithValue1: 1 } } } </code> </p> </li> </ul> </li> </ul> </div> </div> </td> </tr> </tbody> </table> </div> <section> <h4 class="contains-headerlink leafygreen-ui-1vzlt5f"> Embedded Field Specification <a class="headerlink leafygreen-ui-1kepx47" href="#embedded-field-specification" 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="embedded-field-specification"> </div> </a> </h4> <p class="leafygreen-ui-1kp3ins"> For fields in an embedded documents, you can specify the field using either: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/document/#std-label-document-dot-notation-embedded-fields"> dot notation </a> , for example <code class="leafygreen-ui-1l06pbn"> "field.nestedfield": &lt;value&gt; </code> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> nested form, for example <code class="leafygreen-ui-1l06pbn"> { field: { nestedfield: &lt;value&gt; } } </code> </p> </li> </ul> </section> <section> <h4 class="contains-headerlink leafygreen-ui-1vzlt5f"> <code class="leafygreen-ui-1l06pbn"> _id </code> Field Projection <a class="headerlink leafygreen-ui-1kepx47" href="#_id-field-projection" 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="_id-field-projection"> </div> </a> </h4> <p class="leafygreen-ui-1kp3ins"> The <code class="leafygreen-ui-1l06pbn"> _id </code> field is included in the returned documents by default unless you explicitly specify <code class="leafygreen-ui-1l06pbn"> _id: 0 </code> in the projection to suppress the field. </p> </section> <section> <h4 class="contains-headerlink leafygreen-ui-1vzlt5f"> Inclusion or Exclusion <a class="headerlink leafygreen-ui-1kepx47" href="#inclusion-or-exclusion" 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="inclusion-or-exclusion"> </div> </a> </h4> <p class="leafygreen-ui-1kp3ins"> A <code class="leafygreen-ui-1l06pbn"> projection </code> <em> cannot </em> contain <em> both </em> include and exclude specifications, with the exception of the <code class="leafygreen-ui-1l06pbn"> _id </code> field: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> In projections that <em> explicitly include </em> fields, the <code class="leafygreen-ui-1l06pbn"> _id </code> field is the only field that you can <em> explicitly exclude </em> . </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> In projections that <em> explicitly excludes </em> fields, the <code class="leafygreen-ui-1l06pbn"> _id </code> field is the only field that you can <em> explicitly include </em> ; however, the <code class="leafygreen-ui-1l06pbn"> _id </code> field is included by default. </p> </li> </ul> <p class="leafygreen-ui-1kp3ins"> For more information on projection, see also: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/tutorial/project-fields-from-query-results/#std-label-read-operations-projection"> Project Fields to Return from Query </a> </p> </li> </ul> </section> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Sharded Collections <a class="headerlink leafygreen-ui-1kepx47" href="#sharded-collections" 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="sharded-collections"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> To use <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-method-db.collection.findOneAndReplace" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> db.collection.findOneAndReplace() </code> </span> </a> on a sharded collection, the query filter <strong class="css-4dei7l"> must </strong> include an equality condition on the shard key. </p> <p class="leafygreen-ui-1kp3ins"> Documents in a sharded collection can be <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/sharding-shard-key/#std-label-shard-key-missing"> missing the shard key fields </a> . To target a document that is missing the shard key, you can use the <code class="leafygreen-ui-1l06pbn"> null </code> equality match <strong class="css-4dei7l"> in conjunction with </strong> another filter condition (such as on the <code class="leafygreen-ui-1l06pbn"> _id </code> field). For example: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ _id: &lt;value&gt;, &lt;shardkeyfield&gt;: null } // _id of the document missing shard key","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-1q4bxgx" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-attr">_id</span>: &lt;<!-- -->value<!-- -->&gt;<!-- -->,<!-- --> <!-- -->&lt;<!-- -->shardkeyfield<!-- -->&gt;<!-- -->: <span class="lg-highlight-literal">null</span> } <span class="lg-highlight-comment">// _id of</span><span class="lg-highlight-comment"> the document missing </span><span class="lg-highlight-comment">shard key</span></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> <span class="leafygreen-ui-1qnjd6d" id="std-label-findOneAndReplace-shard-key-modification"> </span> <section> <h4 class="contains-headerlink leafygreen-ui-1vzlt5f"> Shard Key Modification <a class="headerlink leafygreen-ui-1kepx47" href="#shard-key-modification" 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="shard-key-modification"> </div> </a> </h4> <p class="leafygreen-ui-1kp3ins"> You can update a document's shard key value unless the shard key field is the immutable <code class="leafygreen-ui-1l06pbn"> _id </code> field. </p> <div class="leafygreen-ui-1sjx7ru" role="note"> <h2 class="leafygreen-ui-29m78u"> Warning </h2> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> Documents in sharded collections can be missing the shard key fields. Take precaution to avoid accidentally removing the shard key when changing a document's shard key value. </p> </div> </div> <p class="leafygreen-ui-1kp3ins"> To modify the <strong> existing </strong> shard key value with <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-method-db.collection.findOneAndReplace" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> db.collection.findOneAndReplace() </code> : </span> </a> </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> You <strong class="css-4dei7l"> must </strong> run on a <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongos/#mongodb-binary-bin.mongos"> <code class="leafygreen-ui-1l06pbn"> mongos </code> </a> . Do <strong class="css-4dei7l"> not </strong> issue the operation directly on the shard. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> You <strong class="css-4dei7l"> must </strong> run either in a <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/transactions/"> transaction </a> or as a <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/retryable-writes/"> retryable write <!-- --> . </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> You <strong class="css-4dei7l"> must </strong> include an equality filter on the full shard key. </p> </li> </ul> <span class="leafygreen-ui-1qnjd6d" id="std-label-findOneAndReplace-missing-shard-key"> </span> </section> <section> <h4 class="contains-headerlink leafygreen-ui-1vzlt5f"> Missing Shard Key <a class="headerlink leafygreen-ui-1kepx47" href="#missing-shard-key" 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="missing-shard-key"> </div> </a> </h4> <p class="leafygreen-ui-1kp3ins"> Documents in a sharded collection can be <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/sharding-shard-key/#std-label-shard-key-missing"> missing the shard key fields </a> . To use <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-method-db.collection.findOneAndReplace" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> db.collection.findOneAndReplace() </code> </span> </a> to set the document's <strong> missing </strong> shard key, </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> You <strong class="css-4dei7l"> must </strong> run on a <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongos/#mongodb-binary-bin.mongos"> <code class="leafygreen-ui-1l06pbn"> mongos </code> </a> . Do <strong class="css-4dei7l"> not </strong> issue the operation directly on the shard. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> You <strong class="css-4dei7l"> must </strong> run either in a <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/transactions/"> transaction </a> or as a <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/retryable-writes/"> retryable write </a> if the new shard key value is not <code class="leafygreen-ui-1l06pbn"> null </code> . </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> You <strong class="css-4dei7l"> must </strong> include an equality filter on the full shard key. </p> </li> </ul> <div class="leafygreen-ui-13vw3ie" role="note"> <h2 class="leafygreen-ui-1fn4p2b"> Tip </h2> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> Since a missing key value is returned as part of a null equality match, to avoid updating a null-valued key, include additional query conditions (such as on the <code class="leafygreen-ui-1l06pbn"> _id </code> field) as appropriate. </p> </div> </div> <p class="leafygreen-ui-1kp3ins"> See also: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/sharding-shard-key/#std-label-shard-key-missing"> Missing Shard Key Fields </a> </p> </li> </ul> </section> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Transactions <a class="headerlink leafygreen-ui-1kepx47" href="#transactions" 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="transactions"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-method-db.collection.findOneAndReplace" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> db.collection.findOneAndReplace() </code> </span> </a> can be used inside <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/transactions/#std-label-transactions"> distributed transactions <!-- --> . </a> </p> <div class="leafygreen-ui-85da11" role="note"> <h2 class="leafygreen-ui-1ac4g5h"> Important </h2> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> In most cases, a distributed transaction incurs a greater performance cost over single document writes, and the availability of distributed transactions should not be a replacement for effective schema design. For many scenarios, the <a class="leafygreen-ui-tqgtui" href="/docs/manual/data-modeling/concepts/embedding-vs-references/#std-label-data-modeling-embedding"> denormalized data model (embedded documents and arrays) </a> will continue to be optimal for your data and use cases. That is, for many scenarios, modeling your data appropriately will minimize the need for distributed transactions. </p> <p class="leafygreen-ui-1kp3ins"> For additional transactions usage considerations (such as runtime limit and oplog size limit), see also <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/transactions-production-consideration/#std-label-production-considerations"> Production Considerations <!-- --> . </a> </p> </div> </div> <section> <h4 class="contains-headerlink leafygreen-ui-1vzlt5f"> Upsert within Transactions <a class="headerlink leafygreen-ui-1kepx47" href="#upsert-within-transactions" 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="upsert-within-transactions"> </div> </a> </h4> <p class="leafygreen-ui-1kp3ins"> You can create collections and indexes inside a <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/transactions/#std-label-transactions-create-collections-indexes"> distributed transaction </a> if the transaction is <strong class="css-4dei7l"> not </strong> a cross-shard write transaction. </p> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-method-db.collection.findOneAndReplace" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> db.collection.findOneAndReplace() </code> </span> </a> with <code class="leafygreen-ui-1l06pbn"> upsert: true </code> can be run on an existing collection or a non-existing collection. If run on a non-existing collection, the operation creates the collection. </p> <div class="leafygreen-ui-13vw3ie" role="note"> <h2 class="leafygreen-ui-1fn4p2b"> Tip </h2> <h3 class="leafygreen-ui-144d5kf"> <strong> See also: </strong> </h3> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/transactions/#std-label-transactions-create-collections-indexes"> Create Collections and Indexes in a Transaction </a> </p> </div> </div> </section> <section> <h4 class="contains-headerlink leafygreen-ui-1vzlt5f"> Write Concerns and Transactions <a class="headerlink leafygreen-ui-1kepx47" href="#write-concerns-and-transactions" 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="write-concerns-and-transactions"> </div> </a> </h4> <p class="leafygreen-ui-1kp3ins"> Do not explicitly set the write concern for the operation if run in a transaction. To use write concern with transactions, see <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/transactions/#std-label-transactions-write-concern"> Transactions and Write Concern <!-- --> . </a> </p> </section> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Oplog Entries <a class="headerlink leafygreen-ui-1kepx47" href="#oplog-entries" 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="oplog-entries"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> If a <code class="leafygreen-ui-1l06pbn"> db.collection.findOneAndReplace() </code> operation successfully replaces a document, the operation adds an entry on the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-oplog"> oplog </a> (operations log). If the operation fails or does not find a document to replace, the operation does not add an entry on the oplog. </p> <span class="leafygreen-ui-1qnjd6d" id="std-label-findOneAndReplace-examples"> </span> </section> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Examples <a class="headerlink leafygreen-ui-1kepx47" href="#examples" 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="examples"> </div> </a> </h2> <span class="leafygreen-ui-1qnjd6d" id="std-label-findOneAndReplace-example-replace-document"> </span> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Replace A Document <a class="headerlink leafygreen-ui-1kepx47" href="#replace-a-document" 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="replace-a-document"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> Create a sample <code class="leafygreen-ui-1l06pbn"> scores </code> collection with the following documents: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.scores.insertMany([\n { \"_id\" : 1, \"team\" : \"Fearful Mallards\", \"score\" : 25000 },\n { \"_id\" : 2, \"team\" : \"Tactful Mooses\", \"score\" : 23500 },\n { \"_id\" : 3, \"team\" : \"Aquatic Ponies\", \"score\" : 19250 },\n { \"_id\" : 4, \"team\" : \"Cuddly Zebras\", \"score\" : 15235 },\n { \"_id\" : 5, \"team\" : \"Garrulous Bears\", \"score\" : 18000 }\n]);","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><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">scores</span>.<span class="lg-highlight-title lg-highlight-function">insertMany</span>(<!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">1</span>, <span class="lg-highlight-string">"team"</span> <!-- -->: <span class="lg-highlight-string">"Fearful Mallards"</span>, <span class="lg-highlight-string">"score"</span> <!-- -->: <span class="lg-highlight-number">25000</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">2</span>, <span class="lg-highlight-string">"team"</span> <!-- -->: <span class="lg-highlight-string">"Tactful Mooses"</span>, <span class="lg-highlight-string">"score"</span> <!-- -->: <span class="lg-highlight-number">23500</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">3</span>, <span class="lg-highlight-string">"team"</span> <!-- -->: <span class="lg-highlight-string">"Aquatic Ponies"</span>, <span class="lg-highlight-string">"score"</span> <!-- -->: <span class="lg-highlight-number">19250</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">4</span>, <span class="lg-highlight-string">"team"</span> <!-- -->: <span class="lg-highlight-string">"Cuddly Zebras"</span>, <span class="lg-highlight-string">"score"</span> <!-- -->: <span class="lg-highlight-number">15235</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">5</span>, <span class="lg-highlight-string">"team"</span> <!-- -->: <span class="lg-highlight-string">"Garrulous Bears"</span>, <span class="lg-highlight-string">"score"</span> <!-- -->: <span class="lg-highlight-number">18000</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">])<!-- -->;</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 operation finds a document with <code class="leafygreen-ui-1l06pbn"> score </code> less than <code class="leafygreen-ui-1l06pbn"> 20000 </code> and replaces it: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.scores.findOneAndReplace(\n { \"score\" : { $lt : 20000 } },\n { \"team\" : \"Observant Badgers\", \"score\" : 20000 }\n)","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">scores</span>.<span class="lg-highlight-title lg-highlight-function">findOneAndReplace</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"score"</span> <!-- -->: <!-- -->{ <!-- -->$lt<!-- --> <!-- -->: <span class="lg-highlight-number">20000</span> } }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"team"</span> <!-- -->: <span class="lg-highlight-string">"Observant Badgers"</span>, <span class="lg-highlight-string">"score"</span> <!-- -->: <span class="lg-highlight-number">20000</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">)</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 operation returns the <em> original </em> document that has been replaced: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ \"_id\" : 3, \"team\" : \"Aquatic Ponies\", \"score\" : 19250 }","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">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">3</span>, <span class="lg-highlight-string">"team"</span> <!-- -->: <span class="lg-highlight-string">"Aquatic Ponies"</span>, <span class="lg-highlight-string">"score"</span> <!-- -->: <span class="lg-highlight-number">19250</span> }</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"> If <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-findOneAndReplace-returnNewDocument" target="_self"> <span> returnNewDocument </span> </a> was true, the operation would return the replacement document instead. </p> <p class="leafygreen-ui-1kp3ins"> Although multiple documents meet the filter criteria, <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-method-db.collection.findOneAndReplace" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> db.collection.findOneAndReplace() </code> </span> </a> replaces only one document. </p> <span class="leafygreen-ui-1qnjd6d" id="std-label-findOneAndReplace-example-sort-and-replace-document"> </span> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Sort and Replace A Document <a class="headerlink leafygreen-ui-1kepx47" href="#sort-and-replace-a-document" 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="sort-and-replace-a-document"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> Create a sample <code class="leafygreen-ui-1l06pbn"> scores </code> collection with the following documents: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.scores.insertMany([\n { \"_id\" : 1, \"team\" : \"Fearful Mallards\", \"score\" : 25000 },\n { \"_id\" : 2, \"team\" : \"Tactful Mooses\", \"score\" : 23500 },\n { \"_id\" : 3, \"team\" : \"Aquatic Ponies\", \"score\" : 19250 },\n { \"_id\" : 4, \"team\" : \"Cuddly Zebras\", \"score\" : 15235 },\n { \"_id\" : 5, \"team\" : \"Garrulous Bears\", \"score\" : 18000 }\n]);","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><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">scores</span>.<span class="lg-highlight-title lg-highlight-function">insertMany</span>(<!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">1</span>, <span class="lg-highlight-string">"team"</span> <!-- -->: <span class="lg-highlight-string">"Fearful Mallards"</span>, <span class="lg-highlight-string">"score"</span> <!-- -->: <span class="lg-highlight-number">25000</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">2</span>, <span class="lg-highlight-string">"team"</span> <!-- -->: <span class="lg-highlight-string">"Tactful Mooses"</span>, <span class="lg-highlight-string">"score"</span> <!-- -->: <span class="lg-highlight-number">23500</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">3</span>, <span class="lg-highlight-string">"team"</span> <!-- -->: <span class="lg-highlight-string">"Aquatic Ponies"</span>, <span class="lg-highlight-string">"score"</span> <!-- -->: <span class="lg-highlight-number">19250</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">4</span>, <span class="lg-highlight-string">"team"</span> <!-- -->: <span class="lg-highlight-string">"Cuddly Zebras"</span>, <span class="lg-highlight-string">"score"</span> <!-- -->: <span class="lg-highlight-number">15235</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">5</span>, <span class="lg-highlight-string">"team"</span> <!-- -->: <span class="lg-highlight-string">"Garrulous Bears"</span>, <span class="lg-highlight-string">"score"</span> <!-- -->: <span class="lg-highlight-number">18000</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">])<!-- -->;</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"> By including an ascending <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-findOneAndReplace-sort" target="_self"> <span> sort </span> </a> on the <code class="leafygreen-ui-1l06pbn"> score </code> field, the following example replaces the document with the lowest score among those documents that match the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-findOneAndReplace-filter" target="_self"> <span> filter <!-- --> : </span> </a> </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.scores.findOneAndReplace(\n { \"score\" : { $lt : 20000 } },\n { \"team\" : \"Observant Badgers\", \"score\" : 20000 },\n { sort: { \"score\" : 1 } }\n)","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">scores</span>.<span class="lg-highlight-title lg-highlight-function">findOneAndReplace</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"score"</span> <!-- -->: <!-- -->{ <!-- -->$lt<!-- --> <!-- -->: <span class="lg-highlight-number">20000</span> } }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"team"</span> <!-- -->: <span class="lg-highlight-string">"Observant Badgers"</span>, <span class="lg-highlight-string">"score"</span> <!-- -->: <span class="lg-highlight-number">20000</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">sort</span>: <!-- -->{ <span class="lg-highlight-string">"score"</span> <!-- -->: <span class="lg-highlight-number">1</span> } }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">)</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 operation returns the <em> original </em> document that has been replaced: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ \"_id\" : 4, \"team\" : \"Cuddly Zebras\", \"score\" : 15235 }","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">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">4</span>, <span class="lg-highlight-string">"team"</span> <!-- -->: <span class="lg-highlight-string">"Cuddly Zebras"</span>, <span class="lg-highlight-string">"score"</span> <!-- -->: <span class="lg-highlight-number">15235</span> }</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"> See <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-findOneAndReplace-example-replace-document" target="_self"> <span> Replace A Document </span> </a> for the non-sorted result of this command. </p> <span class="leafygreen-ui-1qnjd6d" id="std-label-findOneAndReplace-example-project-returned-document"> </span> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Project Specific Fields in Return Document <a class="headerlink leafygreen-ui-1kepx47" href="#project-specific-fields-in-return-document" 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="project-specific-fields-in-return-document"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> Create a sample <code class="leafygreen-ui-1l06pbn"> scores </code> collection with the following documents: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.scores.insertMany([\n { \"_id\" : 1, \"team\" : \"Fearful Mallards\", \"score\" : 25000 },\n { \"_id\" : 2, \"team\" : \"Tactful Mooses\", \"score\" : 23500 },\n { \"_id\" : 3, \"team\" : \"Aquatic Ponies\", \"score\" : 19250 },\n { \"_id\" : 4, \"team\" : \"Cuddly Zebras\", \"score\" : 15235 },\n { \"_id\" : 5, \"team\" : \"Garrulous Bears\", \"score\" : 18000 }\n])","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><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">scores</span>.<span class="lg-highlight-title lg-highlight-function">insertMany</span>(<!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">1</span>, <span class="lg-highlight-string">"team"</span> <!-- -->: <span class="lg-highlight-string">"Fearful Mallards"</span>, <span class="lg-highlight-string">"score"</span> <!-- -->: <span class="lg-highlight-number">25000</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">2</span>, <span class="lg-highlight-string">"team"</span> <!-- -->: <span class="lg-highlight-string">"Tactful Mooses"</span>, <span class="lg-highlight-string">"score"</span> <!-- -->: <span class="lg-highlight-number">23500</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">3</span>, <span class="lg-highlight-string">"team"</span> <!-- -->: <span class="lg-highlight-string">"Aquatic Ponies"</span>, <span class="lg-highlight-string">"score"</span> <!-- -->: <span class="lg-highlight-number">19250</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">4</span>, <span class="lg-highlight-string">"team"</span> <!-- -->: <span class="lg-highlight-string">"Cuddly Zebras"</span>, <span class="lg-highlight-string">"score"</span> <!-- -->: <span class="lg-highlight-number">15235</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">5</span>, <span class="lg-highlight-string">"team"</span> <!-- -->: <span class="lg-highlight-string">"Garrulous Bears"</span>, <span class="lg-highlight-string">"score"</span> <!-- -->: <span class="lg-highlight-number">18000</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">])</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 operation uses <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-findOneAndReplace-projection" target="_self"> <span> projection </span> </a> to only display the <code class="leafygreen-ui-1l06pbn"> team </code> field in the returned document: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.scores.findOneAndReplace(\n { \"score\" : { $lt : 22250 } },\n { \"team\" : \"Therapeutic Hamsters\", \"score\" : 22250 },\n { sort : { \"score\" : 1 }, projection: { \"_id\" : 0, \"team\" : 1 } }\n)","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><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">scores</span>.<span class="lg-highlight-title lg-highlight-function">findOneAndReplace</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"score"</span> <!-- -->: <!-- -->{ <!-- -->$lt<!-- --> <!-- -->: <span class="lg-highlight-number">22250</span> } }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"team"</span> <!-- -->: <span class="lg-highlight-string">"Therapeutic Hamsters"</span>, <span class="lg-highlight-string">"score"</span> <!-- -->: <span class="lg-highlight-number">22250</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <!-- -->sort <!-- -->: <!-- -->{ <span class="lg-highlight-string">"score"</span> <!-- -->: <span class="lg-highlight-number">1</span> }<!-- -->, <span class="lg-highlight-attr">projection</span>: <!-- -->{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">0</span>, <span class="lg-highlight-string">"team"</span> <!-- -->: <span class="lg-highlight-number">1</span> } }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">)</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 operation returns the <em> original </em> document with only the <code class="leafygreen-ui-1l06pbn"> team </code> field: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ \"team\" : \"Cuddly Zebras\" }","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">{ <span class="lg-highlight-string">"team"</span> <!-- -->: <span class="lg-highlight-string">"Cuddly Zebras"</span> }</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> <span class="leafygreen-ui-1qnjd6d" id="std-label-findOneAndReplace-example-replace-with-time-limit"> </span> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Replace Document with Time Limit <a class="headerlink leafygreen-ui-1kepx47" href="#replace-document-with-time-limit" 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="replace-document-with-time-limit"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> The following operation sets a 5ms time limit to complete: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"try {\n db.scores.findOneAndReplace(\n { \"score\" : { $gt : 25000 } },\n { \"team\" : \"Emphatic Rhinos\", \"score\" : 25010 },\n { maxTimeMS: 5 }\n );\n} catch(e){\n print(e);\n}","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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"><span class="lg-highlight-keyword">try</span> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->db.<span class="lg-highlight-property">scores</span>.<span class="lg-highlight-title lg-highlight-function">findOneAndReplace</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"score"</span> <!-- -->: <!-- -->{ <!-- -->$gt<!-- --> <!-- -->: <span class="lg-highlight-number">25000</span> } }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"team"</span> <!-- -->: <span class="lg-highlight-string">"Emphatic Rhinos"</span>, <span class="lg-highlight-string">"score"</span> <!-- -->: <span class="lg-highlight-number">25010</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">maxTimeMS</span>: <span class="lg-highlight-number">5</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> )<!-- -->;</td></tr><tr class=""><td class="leafygreen-ui-7razhx">} <span class="lg-highlight-keyword">catch</span>(<!-- -->e)<!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-title lg-highlight-function">print</span>(<!-- -->e)<!-- -->;</td></tr><tr class=""><td class="leafygreen-ui-7razhx">}</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"> If the operation exceeds the time limit, it returns: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"Error: findAndModifyFailed failed: { \"ok\" : 0, \"errmsg\" : \"operation exceeded time limit\", \"code\" : 50 }","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-1q4bxgx" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-title lg-highlight-class">Error</span>: <!-- -->findAndModifyFailed <span class="lg-highlight-attr">failed</span>: <!-- -->{ <span class="lg-highlight-string">"ok"</span> <!-- -->: <span class="lg-highlight-number">0</span>, <span class="lg-highlight-string">"errmsg"</span> <!-- -->: <span class="lg-highlight-string">"operation exceeded time limit"</span>, <span class="lg-highlight-string">"code"</span> <!-- -->: <span class="lg-highlight-number">50</span> }</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> <span class="leafygreen-ui-1qnjd6d" id="std-label-findOneAndReplace-example-replace-with-upsert"> </span> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Replace Document with Upsert <a class="headerlink leafygreen-ui-1kepx47" href="#replace-document-with-upsert" 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="replace-document-with-upsert"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> The following operation uses the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-findOneAndReplace-upsert" target="_self"> <span> upsert </span> </a> field to insert the replacement document if no document matches the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-findOneAndReplace-filter" target="_self"> <span> filter <!-- --> : </span> </a> </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"try {\n db.scores.findOneAndReplace(\n { \"team\" : \"Fortified Lobsters\" },\n { \"_id\" : 6019, \"team\" : \"Fortified Lobsters\" , \"score\" : 32000},\n { upsert : true, returnDocument: \"after\" }\n );\n} catch (e){\n print(e);\n}","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-keyword">try</span> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->db.<span class="lg-highlight-property">scores</span>.<span class="lg-highlight-title lg-highlight-function">findOneAndReplace</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"team"</span> <!-- -->: <span class="lg-highlight-string">"Fortified Lobsters"</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">6019</span>, <span class="lg-highlight-string">"team"</span> <!-- -->: <span class="lg-highlight-string">"Fortified Lobsters"</span> <!-- -->, <span class="lg-highlight-string">"score"</span> <!-- -->: <span class="lg-highlight-number">32000</span>}<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <!-- -->upsert <!-- -->: <span class="lg-highlight-literal">true</span>, <span class="lg-highlight-attr">returnDocument</span>: <span class="lg-highlight-string">"after"</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> )<!-- -->;</td></tr><tr class=""><td class="leafygreen-ui-7razhx">} <span class="lg-highlight-keyword">catch</span> <!-- -->(<!-- -->e)<!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-title lg-highlight-function">print</span>(<!-- -->e)<!-- -->;</td></tr><tr class=""><td class="leafygreen-ui-7razhx">}</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 operation returns the following: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{\n \"_id\" : 6019,\n \"team\" : \"Fortified Lobsters\",\n \"score\" : 32000\n}","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">6019</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"team"</span> <!-- -->: <span class="lg-highlight-string">"Fortified Lobsters"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"score"</span> <!-- -->: <span class="lg-highlight-number">32000</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx">}</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"> If <code class="leafygreen-ui-1l06pbn"> returnDocument: "before" </code> was set, the operation would return <code class="leafygreen-ui-1l06pbn"> null </code> because there is no original document to return. </p> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Specify Collation <a class="headerlink leafygreen-ui-1kepx47" href="#specify-collation" 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="specify-collation"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/collation/#std-label-collation"> Collation </a> allows users to specify language-specific rules for string comparison, such as rules for lettercase and accent marks. </p> <p class="leafygreen-ui-1kp3ins"> Create a sample <code class="leafygreen-ui-1l06pbn"> myColl </code> collection with the following documents: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.myColl.insertMany([\n { _id: 1, category: \"café\", status: \"A\" },\n { _id: 2, category: \"cafe\", status: \"a\" },\n { _id: 3, category: \"cafE\", status: \"a\" }\n]);","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">myColl</span>.<span class="lg-highlight-title lg-highlight-function">insertMany</span>(<!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">1</span>, <span class="lg-highlight-attr">category</span>: <span class="lg-highlight-string">"café"</span>, <span class="lg-highlight-attr">status</span>: <span class="lg-highlight-string">"A"</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">2</span>, <span class="lg-highlight-attr">category</span>: <span class="lg-highlight-string">"cafe"</span>, <span class="lg-highlight-attr">status</span>: <span class="lg-highlight-string">"a"</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">3</span>, <span class="lg-highlight-attr">category</span>: <span class="lg-highlight-string">"cafE"</span>, <span class="lg-highlight-attr">status</span>: <span class="lg-highlight-string">"a"</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">])<!-- -->;</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 operation includes the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-findOneAndReplace-collation" target="_self"> <span> collation </span> </a> option: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.myColl.findOneAndReplace(\n { category: \"cafe\", status: \"a\" },\n { category: \"cafÉ\", status: \"Replaced\" },\n { collation: { locale: \"fr\", strength: 1 } }\n);","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">myColl</span>.<span class="lg-highlight-title lg-highlight-function">findOneAndReplace</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">category</span>: <span class="lg-highlight-string">"cafe"</span>, <span class="lg-highlight-attr">status</span>: <span class="lg-highlight-string">"a"</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">category</span>: <span class="lg-highlight-string">"cafÉ"</span>, <span class="lg-highlight-attr">status</span>: <span class="lg-highlight-string">"Replaced"</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">collation</span>: <!-- -->{ <span class="lg-highlight-attr">locale</span>: <span class="lg-highlight-string">"fr"</span>, <span class="lg-highlight-attr">strength</span>: <span class="lg-highlight-number">1</span> } }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">)<!-- -->;</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 operation returns the following document: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ \"_id\" : 1, \"category\" : \"café\", \"status\" : \"A\" }","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">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">1</span>, <span class="lg-highlight-string">"category"</span> <!-- -->: <span class="lg-highlight-string">"café"</span>, <span class="lg-highlight-string">"status"</span> <!-- -->: <span class="lg-highlight-string">"A"</span> }</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> </section> </section> </section>
https://www.mongodb.com/docs/manual/tutorial/install-mongodb-on-amazon/
<section> <h1 class="contains-headerlink leafygreen-ui-41fr9s" weight="medium"> Install MongoDB Community Edition on Amazon Linux <a class="headerlink leafygreen-ui-1kepx47" href="#install-mongodb-community-edition-on-amazon-linux" 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="install-mongodb-community-edition-on-amazon-linux"> </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="#overview" target="_self"> <span> Overview </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#considerations" target="_self"> <span> Considerations </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#install-mongodb-community-edition" target="_self"> <span> Install MongoDB Community Edition </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#run-mongodb-community-edition" target="_self"> <span> Run MongoDB Community Edition </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#uninstall-mongodb-community-edition" target="_self"> <span> Uninstall MongoDB Community Edition </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#additional-information" target="_self"> <span> Additional Information </span> </a> </li> </ul> </div> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Overview <a class="headerlink leafygreen-ui-1kepx47" href="#overview" 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="overview"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> Use this tutorial to install MongoDB 8.0 <!-- --> Community <!-- --> Edition on Amazon Linux using the <code class="leafygreen-ui-1l06pbn"> yum </code> package manager. </p> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Verify Linux Distribution <a class="headerlink leafygreen-ui-1kepx47" href="#verify-linux-distribution" 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="verify-linux-distribution"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> You can verify which Linux distribution you are running by running the following command on the command-line: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"grep ^NAME /etc/*release"} </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 none leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">grep ^NAME /etc/*release</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 result should be <strong> Amazon Linux </strong> or <strong> Amazon Linux AMI </strong> . If using a different Linux distribution, please see the <a class="leafygreen-ui-tqgtui" href="/docs/manual/administration/install-on-linux/#std-label-install-mdb-community-edition-linux"> install instructions for your platform <!-- --> . </a> </p> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> MongoDB Version <a class="headerlink leafygreen-ui-1kepx47" href="#mongodb-version" 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="mongodb-version"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> This tutorial installs MongoDB 8.0 <!-- --> Community <!-- --> Edition. To install a different version of MongoDB <!-- --> Community <!-- --> , use the version drop-down menu in the upper-left corner of this page to select the documentation for that version. </p> </section> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Considerations <a class="headerlink leafygreen-ui-1kepx47" href="#considerations" 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="considerations"> </div> </a> </h2> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Platform Support <a class="headerlink leafygreen-ui-1kepx47" href="#platform-support" 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="platform-support"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> MongoDB 8.0 Community Edition supports the following <strong class="css-4dei7l"> 64-bit </strong> Amazon Linux release on <a class="leafygreen-ui-tqgtui" href="/docs/manual/administration/production-notes/#std-label-prod-notes-supported-platforms-x86_64"> x86_64 </a> architecture: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Amazon Linux 2023 </p> </li> </ul> <p class="leafygreen-ui-1kp3ins"> MongoDB only supports the 64-bit versions of this platform. </p> <p class="leafygreen-ui-1kp3ins"> MongoDB 8.0 Community Edition on Amazon Linux also supports the <a class="leafygreen-ui-tqgtui" href="/docs/manual/administration/production-notes/#std-label-prod-notes-supported-platforms-ARM64"> ARM64 </a> architecture on select platforms. </p> <p class="leafygreen-ui-1kp3ins"> See <a class="leafygreen-ui-tqgtui" href="/docs/manual/administration/production-notes/#std-label-prod-notes-supported-platforms"> Platform Support </a> for more information. </p> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Production Notes <a class="headerlink leafygreen-ui-1kepx47" href="#production-notes" 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="production-notes"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> Before deploying MongoDB in a production environment, consider the <a class="leafygreen-ui-tqgtui" href="/docs/manual/administration/production-notes/"> Production Notes for Self-Managed Deployments </a> document which offers performance considerations and configuration recommendations for production MongoDB deployments. </p> <span class="leafygreen-ui-1qnjd6d" id="std-label-install-community-amazon-pkg"> </span> </section> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Install MongoDB Community Edition <a class="headerlink leafygreen-ui-1kepx47" href="#install-mongodb-community-edition" 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="install-mongodb-community-edition"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> Follow these steps to install MongoDB <!-- --> Community <!-- --> Edition using the <code class="leafygreen-ui-1l06pbn"> yum </code> package manager. Select the tab for your version of Amazon Linux: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"HowTo","steps":[{"@type":"HowToStep","text":"Configure the package management system (yum).Create a /etc/yum.repos.d/mongodb-org-8.0.repo file so that\nyou can install MongoDB directly using yum:You can also download the .rpm files directly from the\nMongoDB repository.\nDownloads are organized by Amazon Linux 2023 version\n(e.g. 2023), then MongoDB version\n(e.g., 8.0), then architecture (e.g., x86_64).Prior to MongoDB 5.0, odd-numbered MongoDB release versions, such as\n4.3, were development releases. Beginning with MongoDB 5.1,\nMongoDB has quarterly rapid releases. For more information on the\ndifferences between rapid and long-term support releases, see\nMongoDB Versioning."},{"@type":"HowToStep","text":"To install the latest stable version of MongoDB, issue the\nfollowing command:Alternatively, to install a specific release of MongoDB, specify\neach component package individually and append the version\nnumber to the package name, as in the following example:yum automatically upgrades packages when newer versions\nbecome available. If you want to prevent MongoDB upgrades, pin\nthe package by adding the following exclude directive to\nyour /etc/yum.conf file:"}],"name":"Install MongoDB Community Edition","image":"https://webimages.mongodb.com/_com_assets/cms/kuyj2focmkbxv7gh3-stacked_default_slate_blue.svg?auto=format%252Ccompress"} </script> <div class="css-4nyere eccljxs0"> <div class="css-1nuklj8 e1ckbxcu1"> <div class="css-18fui5z e1ckbxcu0"> <div class="css-19lsqsq e1ckbxcu2"> 1 </div> </div> <div class="css-1ed38mk"> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Configure the package management system ( <code class="leafygreen-ui-1l06pbn"> yum </code> ). <a class="headerlink leafygreen-ui-1kepx47" href="#configure-the-package-management-system-yum" 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="configure-the-package-management-system-yum"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> Create a <code class="leafygreen-ui-1l06pbn"> /etc/yum.repos.d/mongodb-org-8.0.repo </code> file so that you can install MongoDB directly using <code class="leafygreen-ui-1l06pbn"> yum </code> : </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"[mongodb-org-8.0]\nname=MongoDB Repository\nbaseurl=https://repo.mongodb.org/yum/amazon/2023/mongodb-org/8.0/x86_64/\ngpgcheck=1\nenabled=1\ngpgkey=https://pgp.mongodb.com/server-8.0.asc"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><code class="lg-highlight-hljs-light none leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">[mongodb-org-8.0]</td></tr><tr class=""><td class="leafygreen-ui-7razhx">name=MongoDB Repository</td></tr><tr class=""><td class="leafygreen-ui-7razhx">baseurl=https://repo.mongodb.org/yum/amazon/2023/mongodb-org/8.0/x86_64/</td></tr><tr class=""><td class="leafygreen-ui-7razhx">gpgcheck=1</td></tr><tr class=""><td class="leafygreen-ui-7razhx">enabled=1</td></tr><tr class=""><td class="leafygreen-ui-7razhx">gpgkey=https://pgp.mongodb.com/server-8.0.asc</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"> You can also download the <code class="leafygreen-ui-1l06pbn"> .rpm </code> files directly from the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://repo.mongodb.org/yum/amazon/" rel="noopener noreferrer"> <span> MongoDB repository </span> <svg alt="" aria-hidden="true" class="leafygreen-ui-1ie5kuq" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M13.823 2.4491C13.8201 2.30008 13.6999 2.17994 13.5509 2.17704L9.5062 2.09836C9.25654 2.09351 9.12821 2.39519 9.30482 2.5718L10.3856 3.65257L7.93433 6.10383C7.87964 6.15852 7.83047 6.21665 7.78683 6.27752L5.99909 8.06525C5.46457 8.59977 5.46457 9.4664 5.99909 10.0009C6.53361 10.5354 7.40023 10.5354 7.93475 10.0009L9.72249 8.21317C9.78336 8.16953 9.84148 8.12037 9.89618 8.06567L12.3474 5.61441L13.4282 6.69518C13.6048 6.87179 13.9065 6.74347 13.9016 6.4938L13.823 2.4491Z" fill="currentColor"> </path> <path d="M7.25 3.12893C7.66421 3.12893 8 3.46472 8 3.87893C8 4.29315 7.66421 4.62893 7.25 4.62893H4C3.72386 4.62893 3.5 4.85279 3.5 5.12893V11.9929C3.5 12.2691 3.72386 12.4929 4 12.4929H10.864C11.1401 12.4929 11.364 12.2691 11.364 11.9929V8.75C11.364 8.33579 11.6998 8 12.114 8C12.5282 8 12.864 8.33579 12.864 8.75V11.9929C12.864 13.0975 11.9686 13.9929 10.864 13.9929H4C2.89543 13.9929 2 13.0975 2 11.9929V5.12893C2 4.02436 2.89543 3.12893 4 3.12893H7.25Z" fill="currentColor"> </path> </svg> </a> . Downloads are organized by Amazon Linux 2023 version (e.g. <code class="leafygreen-ui-1l06pbn"> 2023 </code> ), then MongoDB <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/versioning/#std-label-release-version-numbers"> version </a> (e.g., <code class="leafygreen-ui-1l06pbn"> 8.0 </code> ), then architecture (e.g., <code class="leafygreen-ui-1l06pbn"> x86_64 </code> ). </p> <p class="leafygreen-ui-1kp3ins"> Prior to MongoDB 5.0, odd-numbered MongoDB release versions, such as <code class="leafygreen-ui-1l06pbn"> 4.3 </code> , were development releases. Beginning with MongoDB 5.1, MongoDB has quarterly rapid releases. For more information on the differences between rapid and long-term support releases, see <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/versioning/#std-label-release-version-numbers"> MongoDB Versioning <!-- --> . </a> </p> </section> </div> </div> <div class="css-1nuklj8 e1ckbxcu1"> <div class="css-18fui5z e1ckbxcu0"> <div class="css-19lsqsq e1ckbxcu2"> 2 </div> </div> <div class="css-1ed38mk"> <section> <p class="leafygreen-ui-1kp3ins"> To install the latest stable version of MongoDB, issue the following command: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"sudo yum install -y mongodb-org","programmingLanguage":"Shell"} </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 shell leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">sudo yum install -y mongodb-org</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"> Alternatively, to install a specific release of MongoDB, specify each component package individually and append the version number to the package name, as in the following example: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"sudo yum install -y mongodb-org-8.0.0 mongodb-org-database-8.0.0 mongodb-org-server-8.0.0 mongodb-mongosh mongodb-org-mongos-8.0.0 mongodb-org-tools-8.0.0\n","programmingLanguage":"Shell"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-1q4bxgx" tabindex="0"><code class="lg-highlight-hljs-light shell leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">sudo yum install -y mongodb-org-8.0.0 mongodb-org-database-8.0.0 mongodb-org-server-8.0.0 mongodb-mongosh mongodb-org-mongos-8.0.0 mongodb-org-tools-8.0.0</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-15mdk4" role="note"> <h2 class="leafygreen-ui-6n7b7d"> Note </h2> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> <code class="leafygreen-ui-1l06pbn"> yum </code> automatically upgrades packages when newer versions become available. If you want to prevent MongoDB upgrades, pin the package by adding the following <code class="leafygreen-ui-1l06pbn"> exclude </code> directive to your <code class="leafygreen-ui-1l06pbn"> /etc/yum.conf </code> file: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"exclude=mongodb-org,mongodb-org-database,mongodb-org-server,mongodb-mongosh,mongodb-org-mongos,mongodb-org-tools","programmingLanguage":"Ini"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-1q4bxgx" tabindex="0"><code class="lg-highlight-hljs-light ini leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-attr">exclude</span>=mongodb-org,mongodb-org-database,mongodb-org-server,mongodb-mongosh,mongodb-org-mongos,mongodb-org-tools</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> </div> </section> </div> </div> </div> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Run MongoDB Community Edition <a class="headerlink leafygreen-ui-1kepx47" href="#run-mongodb-community-edition" 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="run-mongodb-community-edition"> </div> </a> </h2> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> ulimit Considerations <a class="headerlink leafygreen-ui-1kepx47" href="#ulimit-considerations" 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="ulimit-considerations"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> Most Unix-like operating systems limit the system resources that a process may use. These limits may negatively impact MongoDB operation, and should be adjusted. See <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/ulimit/"> UNIX <code class="leafygreen-ui-1l06pbn"> ulimit </code> Settings for Self-Managed Deployments </a> for the recommended settings for your platform. </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"> If the <code class="leafygreen-ui-1l06pbn"> ulimit </code> value for number of open files is under <code class="leafygreen-ui-1l06pbn"> 64000 </code> , MongoDB generates a startup warning. </p> </div> </div> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Directories <a class="headerlink leafygreen-ui-1kepx47" href="#directories" 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="directories"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> By default, a MongoDB instance stores: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> its data files in <code class="leafygreen-ui-1l06pbn"> /var/lib/mongo </code> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> its log files in <code class="leafygreen-ui-1l06pbn"> /var/log/mongodb </code> </p> </li> </ul> <p class="leafygreen-ui-1kp3ins"> If you installed via the package manager, these default directories are created during the installation. </p> <p class="leafygreen-ui-1kp3ins"> If you installed manually by downloading the tarballs, you can create the directories using <code class="leafygreen-ui-1l06pbn"> mkdir -p &lt;directory&gt; </code> or <code class="leafygreen-ui-1l06pbn"> sudo mkdir -p &lt;directory&gt; </code> depending on the user that will run MongoDB. (See your linux man pages for information on <code class="leafygreen-ui-1l06pbn"> mkdir </code> and <code class="leafygreen-ui-1l06pbn"> sudo </code> .) </p> <p class="leafygreen-ui-1kp3ins"> By default, MongoDB runs using the <code class="leafygreen-ui-1l06pbn"> mongod </code> user account. If you change the user that runs the MongoDB process, you <strong> must </strong> also modify the permission to the <code class="leafygreen-ui-1l06pbn"> /var/lib/mongo </code> and <code class="leafygreen-ui-1l06pbn"> /var/log/mongodb </code> directories to give this user access to these directories. </p> <p class="leafygreen-ui-1kp3ins"> To specify a different log file directory and data file directory, edit the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/configuration-options/#mongodb-setting-systemLog.path"> <code class="leafygreen-ui-1l06pbn"> systemLog.path </code> </a> and <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/configuration-options/#mongodb-setting-storage.dbPath"> <code class="leafygreen-ui-1l06pbn"> storage.dbPath </code> </a> settings in the <code class="leafygreen-ui-1l06pbn"> /etc/mongod.conf </code> . Ensure that the user running MongoDB has access to these directories. </p> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Procedure <a class="headerlink leafygreen-ui-1kepx47" href="#procedure" 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="procedure"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> Follow these steps to run MongoDB <!-- --> Community <!-- --> Edition. These instructions assume that you are using the default settings. </p> <p class="leafygreen-ui-1kp3ins"> <strong> Init System </strong> </p> <p class="leafygreen-ui-1kp3ins"> To run and manage your <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> process, you will be using your operating system's built-in <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-init-system"> init system </a> . Recent versions of Linux tend to use <strong> systemd </strong> (which uses the <code class="leafygreen-ui-1l06pbn"> systemctl </code> command), while older versions of Linux tend to use <strong> System V init </strong> (which uses the <code class="leafygreen-ui-1l06pbn"> service </code> command). </p> <p class="leafygreen-ui-1kp3ins"> If you are unsure which init system your platform uses, run the following command: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"ps --no-headers -o comm 1","programmingLanguage":"Bash"} </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 bash leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">ps --no-headers -o <span class="lg-highlight-built_in">comm</span> 1</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"> Then select the appropriate tab below based on the result: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <code class="leafygreen-ui-1l06pbn"> systemd </code> - select the <strong> systemd (systemctl) </strong> tab below. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <code class="leafygreen-ui-1l06pbn"> init </code> - select the <strong> System V Init (service) </strong> tab below. </p> </li> </ul> <div class="line-block"> <div class="line"> <br/> </div> </div> <div aria-hidden="true"> </div> <div class="leafygreen-ui-1b75luy" data-lgid="lg-tabs"> <div class="leafygreen-ui-jp7pox" id="tabs-26"> <div aria-label="Tabs to describe usage of systemd-systemctl/systemvinit-service" aria-orientation="horizontal" class="leafygreen-ui-m8p1vb lg-ui-tab-list-0000" data-lgid="lg-tabs-tab_list" role="tablist"> <button aria-controls="_dix650kwy" aria-selected="true" class="leafygreen-ui-1l773z1" data-text="" id="_cz565ii26" name="" role="tab" tabindex="0"> <div class="leafygreen-ui-1nxuzmg"> systemd (systemctl) </div> </button> <button aria-controls="_p9j27vv01" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_se6wp1j1i" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> System V Init (service) </div> </button> </div> <div class="leafygreen-ui-ov1ktg"> <div class="leafygreen-ui-1sg2lsz"> </div> </div> </div> <div class="lg-ui-tab-panels-0000" data-lgid="lg-tabs-tab_panels"> <div> <div aria-labelledby="_xknyv6n4w" class="" id="_m7epivzol" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"HowTo","steps":[{"@type":"HowToStep","text":"Start MongoDB.You can start the mongod process by issuing the\nfollowing command:If you receive an error similar to the following when starting\nmongod:Failed to start mongod.service: Unit mongod.service not found.Run the following command first:Then run the start command above again."},{"@type":"HowToStep","text":"Verify that MongoDB has started successfully.You can verify that the mongod process has started\nsuccessfully by issuing the following command:You can optionally ensure that MongoDB will start following a\nsystem reboot by issuing the following command:"},{"@type":"HowToStep","text":"Stop MongoDB.As needed, you can stop the mongod process by issuing the\nfollowing command:"},{"@type":"HowToStep","text":"Restart MongoDB.You can restart the mongod process by issuing the following\ncommand:You can follow the state of the process for errors or important messages\nby watching the output in the /var/log/mongodb/mongod.log file."},{"@type":"HowToStep","text":"Begin using MongoDB.Start a mongosh session on the same host machine as the\nmongod. You can run mongosh\nwithout any command-line options to connect to a\nmongod that is running on your localhost with default\nport 27017.For more information on connecting using mongosh,\nsuch as to connect to a mongod instance running\non a different host and/or port, see the\nmongosh documentation.To help you start using MongoDB, MongoDB provides Getting\nStarted Guides in various driver editions. For the\ndriver documentation, see Start Developing with MongoDB."}],"name":"Procedure - systemd (systemctl)","image":"https://webimages.mongodb.com/_com_assets/cms/kuyj2focmkbxv7gh3-stacked_default_slate_blue.svg?auto=format%252Ccompress"} </script> <div class="css-4nyere eccljxs0"> <div class="css-1nuklj8 e1ckbxcu1"> <div class="css-18fui5z e1ckbxcu0"> <div class="css-19lsqsq e1ckbxcu2"> 1 </div> </div> <div class="css-1ed38mk"> <section> <h4 class="contains-headerlink leafygreen-ui-1vzlt5f"> Start MongoDB. <a class="headerlink leafygreen-ui-1kepx47" href="#start-mongodb" 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="start-mongodb"> </div> </a> </h4> <p class="leafygreen-ui-1kp3ins"> You can start the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> process by issuing the following command: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"sudo systemctl start mongod\n","programmingLanguage":"Shell"} </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 shell leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">sudo systemctl start mongod</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"> If you receive an error similar to the following when starting <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> : </a> </p> <p class="leafygreen-ui-1kp3ins"> <code class="leafygreen-ui-1l06pbn"> Failed to start mongod.service: Unit mongod.service not found. </code> </p> <p class="leafygreen-ui-1kp3ins"> Run the following command first: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"sudo systemctl daemon-reload\n","programmingLanguage":"Shell"} </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 shell leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">sudo systemctl daemon-reload</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"> Then run the start command above again. </p> </section> </div> </div> <div class="css-1nuklj8 e1ckbxcu1"> <div class="css-18fui5z e1ckbxcu0"> <div class="css-19lsqsq e1ckbxcu2"> 2 </div> </div> <div class="css-1ed38mk"> <section> <h4 class="contains-headerlink leafygreen-ui-1vzlt5f"> Verify that MongoDB has started successfully. <a class="headerlink leafygreen-ui-1kepx47" href="#verify-that-mongodb-has-started-successfully" 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="verify-that-mongodb-has-started-successfully"> </div> </a> </h4> <p class="leafygreen-ui-1kp3ins"> You can verify that the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> process has started successfully by issuing the following command: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"sudo systemctl status mongod\n","programmingLanguage":"Shell"} </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 shell leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">sudo systemctl status mongod</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"> You can optionally ensure that MongoDB will start following a system reboot by issuing the following command: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"sudo systemctl enable mongod\n","programmingLanguage":"Shell"} </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 shell leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">sudo systemctl enable mongod</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> </section> </div> </div> <div class="css-1nuklj8 e1ckbxcu1"> <div class="css-18fui5z e1ckbxcu0"> <div class="css-19lsqsq e1ckbxcu2"> 3 </div> </div> <div class="css-1ed38mk"> <section> <h4 class="contains-headerlink leafygreen-ui-1vzlt5f"> Stop MongoDB. <a class="headerlink leafygreen-ui-1kepx47" href="#stop-mongodb" 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="stop-mongodb"> </div> </a> </h4> <p class="leafygreen-ui-1kp3ins"> As needed, you can stop the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> process by issuing the following command: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"sudo systemctl stop mongod\n","programmingLanguage":"Shell"} </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 shell leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">sudo systemctl stop mongod</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> </section> </div> </div> <div class="css-1nuklj8 e1ckbxcu1"> <div class="css-18fui5z e1ckbxcu0"> <div class="css-19lsqsq e1ckbxcu2"> 4 </div> </div> <div class="css-1ed38mk"> <section> <h4 class="contains-headerlink leafygreen-ui-1vzlt5f"> Restart MongoDB. <a class="headerlink leafygreen-ui-1kepx47" href="#restart-mongodb" 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="restart-mongodb"> </div> </a> </h4> <p class="leafygreen-ui-1kp3ins"> You can restart the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> process by issuing the following command: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"sudo systemctl restart mongod\n","programmingLanguage":"Shell"} </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 shell leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">sudo systemctl restart mongod</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"> You can follow the state of the process for errors or important messages by watching the output in the <code class="leafygreen-ui-1l06pbn"> /var/log/mongodb/mongod.log </code> file. </p> </section> </div> </div> <div class="css-1nuklj8 e1ckbxcu1"> <div class="css-18fui5z e1ckbxcu0"> <div class="css-19lsqsq e1ckbxcu2"> 5 </div> </div> <div class="css-1ed38mk"> <section> <h4 class="contains-headerlink leafygreen-ui-1vzlt5f"> Begin using MongoDB. <a class="headerlink leafygreen-ui-1kepx47" href="#begin-using-mongodb" 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="begin-using-mongodb"> </div> </a> </h4> <p class="leafygreen-ui-1kp3ins"> Start a <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/mongodb-shell/#mongodb-binary-bin.mongosh" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongosh </code> </span> </a> session on the same host machine as the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> . You can run <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/mongodb-shell/#mongodb-binary-bin.mongosh" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongosh </code> </span> </a> without any command-line options to connect to a <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> that is running on your localhost with default port 27017. </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"\nmongosh\n","programmingLanguage":"Shell"} </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 shell leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">mongosh</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"> For more information on connecting using <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/mongodb-shell/#mongodb-binary-bin.mongosh" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongosh </code> </span> </a> , such as to connect to a <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> instance running on a different host and/or port, see the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/mongodb-shell/" target="_self"> <span> mongosh documentation <!-- --> . </span> </a> </p> <p class="leafygreen-ui-1kp3ins"> To help you start using MongoDB, MongoDB provides <a class="leafygreen-ui-tqgtui" href="/docs/manual/tutorial/getting-started/#std-label-getting-started"> Getting Started Guides </a> in various driver editions. For the driver documentation, see <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://api.mongodb.com/" target="_self"> <span> Start Developing with MongoDB <!-- --> . </span> </a> </p> </section> </div> </div> </div> </div> </div> </div> <div> <div aria-labelledby="_h0cvl3wv4" class="leafygreen-ui-38lglc" id="_8pqd2o6x6" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"HowTo","steps":[{"@type":"HowToStep","text":"Start MongoDB.You can start the mongod process by issuing the following\ncommand:"},{"@type":"HowToStep","text":"Verify that MongoDB has started successfullyYou can verify that the mongod process has started\nsuccessfully by checking the contents of the log file at\n/var/log/mongodb/mongod.log\nfor a line readingwhere <port> is the port configured in /etc/mongod.conf, 27017 by default.You can optionally ensure that MongoDB will start following a system\nreboot by issuing the following command:"},{"@type":"HowToStep","text":"Stop MongoDB.As needed, you can stop the mongod process by issuing the\nfollowing command:"},{"@type":"HowToStep","text":"Restart MongoDB.You can restart the mongod process by issuing the following\ncommand:You can follow the state of the process for errors or important messages\nby watching the output in the /var/log/mongodb/mongod.log file."},{"@type":"HowToStep","text":"Begin using MongoDB.Start a mongosh session on the same host machine as the\nmongod. You can run mongosh\nwithout any command-line options to connect to a\nmongod that is running on your localhost with default\nport 27017.For more information on connecting using mongosh,\nsuch as to connect to a mongod instance running\non a different host and/or port, see the\nmongosh documentation.To help you start using MongoDB, MongoDB provides Getting\nStarted Guides in various driver editions. For the\ndriver documentation, see Start Developing with MongoDB."}],"name":"Procedure - System V Init (service)","image":"https://webimages.mongodb.com/_com_assets/cms/kuyj2focmkbxv7gh3-stacked_default_slate_blue.svg?auto=format%252Ccompress"} </script> <div class="css-4nyere eccljxs0"> <div class="css-1nuklj8 e1ckbxcu1"> <div class="css-18fui5z e1ckbxcu0"> <div class="css-19lsqsq e1ckbxcu2"> 1 </div> </div> <div class="css-1ed38mk"> <section> <h4 class="contains-headerlink leafygreen-ui-1vzlt5f"> Start MongoDB. <a class="headerlink leafygreen-ui-1kepx47" href="#start-mongodb-1" 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="start-mongodb-1"> </div> </a> </h4> <p class="leafygreen-ui-1kp3ins"> You can start the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> process by issuing the following command: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"sudo service mongod start\n","programmingLanguage":"Shell"} </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 shell leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">sudo service mongod start</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> </section> </div> </div> <div class="css-1nuklj8 e1ckbxcu1"> <div class="css-18fui5z e1ckbxcu0"> <div class="css-19lsqsq e1ckbxcu2"> 2 </div> </div> <div class="css-1ed38mk"> <section> <h4 class="contains-headerlink leafygreen-ui-1vzlt5f"> Verify that MongoDB has started successfully <a class="headerlink leafygreen-ui-1kepx47" href="#verify-that-mongodb-has-started-successfully-1" 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="verify-that-mongodb-has-started-successfully-1"> </div> </a> </h4> <p class="leafygreen-ui-1kp3ins"> You can verify that the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> process has started successfully by checking the contents of the log file at <code class="leafygreen-ui-1l06pbn"> /var/log/mongodb/mongod.log </code> for a line reading </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"[initandlisten] waiting for connections on port &lt;port&gt;\n"} </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 none leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">[initandlisten] waiting for connections on port &lt;port&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"> where <code class="leafygreen-ui-1l06pbn"> &lt;port&gt; </code> is the port configured in <code class="leafygreen-ui-1l06pbn"> /etc/mongod.conf </code> , <code class="leafygreen-ui-1l06pbn"> 27017 </code> by default. </p> <p class="leafygreen-ui-1kp3ins"> You can optionally ensure that MongoDB will start following a system reboot by issuing the following command: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"sudo chkconfig mongod on\n","programmingLanguage":"Shell"} </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 shell leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">sudo chkconfig mongod on</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> </section> </div> </div> <div class="css-1nuklj8 e1ckbxcu1"> <div class="css-18fui5z e1ckbxcu0"> <div class="css-19lsqsq e1ckbxcu2"> 3 </div> </div> <div class="css-1ed38mk"> <section> <h4 class="contains-headerlink leafygreen-ui-1vzlt5f"> Stop MongoDB. <a class="headerlink leafygreen-ui-1kepx47" href="#stop-mongodb-1" 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="stop-mongodb-1"> </div> </a> </h4> <p class="leafygreen-ui-1kp3ins"> As needed, you can stop the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> process by issuing the following command: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"sudo service mongod stop\n","programmingLanguage":"Shell"} </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 shell leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">sudo service mongod stop</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> </section> </div> </div> <div class="css-1nuklj8 e1ckbxcu1"> <div class="css-18fui5z e1ckbxcu0"> <div class="css-19lsqsq e1ckbxcu2"> 4 </div> </div> <div class="css-1ed38mk"> <section> <h4 class="contains-headerlink leafygreen-ui-1vzlt5f"> Restart MongoDB. <a class="headerlink leafygreen-ui-1kepx47" href="#restart-mongodb-1" 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="restart-mongodb-1"> </div> </a> </h4> <p class="leafygreen-ui-1kp3ins"> You can restart the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> process by issuing the following command: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"sudo service mongod restart\n","programmingLanguage":"Shell"} </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 shell leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">sudo service mongod restart</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"> You can follow the state of the process for errors or important messages by watching the output in the <code class="leafygreen-ui-1l06pbn"> /var/log/mongodb/mongod.log </code> file. </p> </section> </div> </div> <div class="css-1nuklj8 e1ckbxcu1"> <div class="css-18fui5z e1ckbxcu0"> <div class="css-19lsqsq e1ckbxcu2"> 5 </div> </div> <div class="css-1ed38mk"> <section> <h4 class="contains-headerlink leafygreen-ui-1vzlt5f"> Begin using MongoDB. <a class="headerlink leafygreen-ui-1kepx47" href="#begin-using-mongodb-1" 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="begin-using-mongodb-1"> </div> </a> </h4> <p class="leafygreen-ui-1kp3ins"> Start a <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/mongodb-shell/#mongodb-binary-bin.mongosh" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongosh </code> </span> </a> session on the same host machine as the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> . You can run <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/mongodb-shell/#mongodb-binary-bin.mongosh" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongosh </code> </span> </a> without any command-line options to connect to a <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> that is running on your localhost with default port 27017. </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"\nmongosh\n","programmingLanguage":"Shell"} </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 shell leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">mongosh</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"> For more information on connecting using <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/mongodb-shell/#mongodb-binary-bin.mongosh" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongosh </code> </span> </a> , such as to connect to a <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> instance running on a different host and/or port, see the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/mongodb-shell/" target="_self"> <span> mongosh documentation <!-- --> . </span> </a> </p> <p class="leafygreen-ui-1kp3ins"> To help you start using MongoDB, MongoDB provides <a class="leafygreen-ui-tqgtui" href="/docs/manual/tutorial/getting-started/#std-label-getting-started"> Getting Started Guides </a> in various driver editions. For the driver documentation, see <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://api.mongodb.com/" target="_self"> <span> Start Developing with MongoDB <!-- --> . </span> </a> </p> </section> </div> </div> </div> </div> </div> </div> </div> </div> </section> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Uninstall MongoDB Community Edition <a class="headerlink leafygreen-ui-1kepx47" href="#uninstall-mongodb-community-edition" 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="uninstall-mongodb-community-edition"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> To completely remove MongoDB from a system, you must remove the MongoDB applications themselves, the configuration files, and any directories containing data and logs. The following section guides you through the necessary steps. </p> <div class="leafygreen-ui-1sjx7ru" role="note"> <h2 class="leafygreen-ui-29m78u"> Warning </h2> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> This process will <em> completely </em> remove MongoDB, its configuration, and <em> all </em> databases. This process is not reversible, so ensure that all of your configuration and data is backed up before proceeding. </p> </div> </div> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"HowTo","steps":[{"@type":"HowToStep","text":"Stop MongoDB.Stop the mongod process by issuing the following command:"},{"@type":"HowToStep","text":"Remove Packages.Remove any MongoDB packages that you had previously installed."},{"@type":"HowToStep","text":"Remove Data Directories.Remove MongoDB databases and log files."}],"name":"Uninstall MongoDB Community Edition","image":"https://webimages.mongodb.com/_com_assets/cms/kuyj2focmkbxv7gh3-stacked_default_slate_blue.svg?auto=format%252Ccompress"} </script> <div class="css-4nyere eccljxs0"> <div class="css-1nuklj8 e1ckbxcu1"> <div class="css-18fui5z e1ckbxcu0"> <div class="css-19lsqsq e1ckbxcu2"> 1 </div> </div> <div class="css-1ed38mk"> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Stop MongoDB. <a class="headerlink leafygreen-ui-1kepx47" href="#stop-mongodb-2" 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="stop-mongodb-2"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> Stop the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> process by issuing the following command: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"sudo service mongod stop\n","programmingLanguage":"Shell"} </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 shell leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">sudo service mongod stop</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> </section> </div> </div> <div class="css-1nuklj8 e1ckbxcu1"> <div class="css-18fui5z e1ckbxcu0"> <div class="css-19lsqsq e1ckbxcu2"> 2 </div> </div> <div class="css-1ed38mk"> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Remove Packages. <a class="headerlink leafygreen-ui-1kepx47" href="#remove-packages" 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="remove-packages"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> Remove any MongoDB packages that you had previously installed. </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"sudo yum erase $(sudo rpm -qa | grep mongodb-org)\n","programmingLanguage":"Shell"} </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 shell leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">sudo yum erase $(sudo rpm -qa | grep mongodb-org)</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> </section> </div> </div> <div class="css-1nuklj8 e1ckbxcu1"> <div class="css-18fui5z e1ckbxcu0"> <div class="css-19lsqsq e1ckbxcu2"> 3 </div> </div> <div class="css-1ed38mk"> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Remove Data Directories. <a class="headerlink leafygreen-ui-1kepx47" href="#remove-data-directories" 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="remove-data-directories"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> Remove MongoDB databases and log files. </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"sudo rm -r /var/log/mongodb\nsudo rm -r /var/lib/mongo\n","programmingLanguage":"Shell"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" tabindex="-1"><code class="lg-highlight-hljs-light shell leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">sudo rm -r /var/log/mongodb</td></tr><tr class=""><td class="leafygreen-ui-7razhx">sudo rm -r /var/lib/mongo</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> </section> </div> </div> </div> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Additional Information <a class="headerlink leafygreen-ui-1kepx47" href="#additional-information" 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="additional-information"> </div> </a> </h2> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Localhost Binding by Default <a class="headerlink leafygreen-ui-1kepx47" href="#localhost-binding-by-default" 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="localhost-binding-by-default"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> By default, MongoDB launches with <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/configuration-options/#mongodb-setting-net.bindIp"> <code class="leafygreen-ui-1l06pbn"> bindIp </code> </a> set to <code class="leafygreen-ui-1l06pbn"> 127.0.0.1 </code> , which binds to the localhost network interface. This means that the <code class="leafygreen-ui-1l06pbn"> mongod </code> can only accept connections from clients that are running on the same machine. Remote clients will not be able to connect to the <code class="leafygreen-ui-1l06pbn"> mongod </code> , and the <code class="leafygreen-ui-1l06pbn"> mongod </code> will not be able to initialize a <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-replica-set"> replica set </a> unless this value is set to a valid network interface. </p> <p class="leafygreen-ui-1kp3ins"> This value can be configured either: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> in the MongoDB configuration file with <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/configuration-options/#mongodb-setting-net.bindIp"> <code class="leafygreen-ui-1l06pbn"> bindIp </code> </a> , or </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> via the command-line argument <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#std-option-mongod.--bind_ip"> <code class="leafygreen-ui-1l06pbn"> --bind_ip </code> </a> </p> </li> </ul> <div class="leafygreen-ui-1sjx7ru" role="note"> <h2 class="leafygreen-ui-29m78u"> Warning </h2> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> Before you bind your instance to a publicly-accessible IP address, you must secure your cluster from unauthorized access. For a complete list of security recommendations, see <a class="leafygreen-ui-tqgtui" href="/docs/manual/administration/security-checklist/#std-label-security-checklist"> Security Checklist for Self-Managed Deployments </a> . At minimum, consider <a class="leafygreen-ui-tqgtui" href="/docs/manual/administration/security-checklist/#std-label-checklist-auth"> enabling authentication </a> and <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/security-hardening/#std-label-network-config-hardening"> hardening network infrastructure <!-- --> . </a> </p> </div> </div> <p class="leafygreen-ui-1kp3ins"> For more information on configuring <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/configuration-options/#mongodb-setting-net.bindIp"> <code class="leafygreen-ui-1l06pbn"> bindIp </code> </a> , see <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/security-mongodb-configuration/"> IP Binding in Self-Managed Deployments <!-- --> . </a> </p> <span class="leafygreen-ui-1qnjd6d" id="std-label-amazon-package-content"> </span> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> MongoDB Community Edition Packages <a class="headerlink leafygreen-ui-1kepx47" href="#mongodb-community-edition-packages" 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="mongodb-community-edition-packages"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> MongoDB Community Edition is available from its own dedicated repository, and contains the following officially-supported packages: </p> <div class="leafygreen-ui-skkc39" tabindex="0"> <table class="leafygreen-ui-hr8lsv"> <colgroup> <col style="width:25%"/> <col style="width:75%"/> </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> Package Name </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> <code class="leafygreen-ui-1l06pbn"> mongodb-org </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> A <code class="leafygreen-ui-1l06pbn"> metapackage </code> that automatically installs the component packages listed below. </div> </div> </td> </tr> <tr class=""> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> mongodb-org-database </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <p class="leafygreen-ui-1kp3ins"> A <code class="leafygreen-ui-1l06pbn"> metapackage </code> that automatically installs the component packages listed below. </p> <div class="leafygreen-ui-skkc39" tabindex="0"> <table class="leafygreen-ui-hr8lsv"> <colgroup> <col style="width:50%"/> <col style="width:50%"/> </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> Package Name </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> <code class="leafygreen-ui-1l06pbn"> mongodb-org-server </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Contains the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> daemon, associated init script, and a <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/configuration-options/#std-label-conf-file"> configuration file </a> ( <code class="leafygreen-ui-1l06pbn"> /etc/mongod.conf </code> ). You can use the initialization script to start <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> with the configuration file. For details, see the "Run MongoDB Community Edition" section, above. </div> </div> </td> </tr> <tr class=""> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> mongodb-org-mongos </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Contains the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongos/#mongodb-binary-bin.mongos"> <code class="leafygreen-ui-1l06pbn"> mongos </code> </a> daemon. </div> </div> </td> </tr> </tbody> </table> </div> </div> </div> </td> </tr> <tr class=""> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> mongodb-mongosh </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Contains the MongoDB Shell ( <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/mongodb-shell/#mongodb-binary-bin.mongosh" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongosh </code> </span> </a> ). </div> </div> </td> </tr> <tr class=""> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> mongodb-org-tools </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <p class="leafygreen-ui-1kp3ins"> A <code class="leafygreen-ui-1l06pbn"> metapackage </code> that automatically installs the component packages listed below: </p> <div class="leafygreen-ui-skkc39" tabindex="0"> <table class="leafygreen-ui-hr8lsv"> <colgroup> <col style="width:50%"/> <col style="width:50%"/> </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> Package Name </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> <code class="leafygreen-ui-1l06pbn"> mongodb-database-tools </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <p class="leafygreen-ui-1kp3ins"> Contains the following MongoDB database tools: </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/database-tools/mongodump/#mongodb-binary-bin.mongodump" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongodump </code> </span> </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/database-tools/mongorestore/#mongodb-binary-bin.mongorestore" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongorestore </code> </span> </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/database-tools/bsondump/#mongodb-binary-bin.bsondump" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> bsondump </code> </span> </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/database-tools/mongoimport/#mongodb-binary-bin.mongoimport" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongoimport </code> </span> </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/database-tools/mongoexport/#mongodb-binary-bin.mongoexport" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongoexport </code> </span> </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/database-tools/mongostat/#mongodb-binary-bin.mongostat" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongostat </code> </span> </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/database-tools/mongotop/#mongodb-binary-bin.mongotop" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongotop </code> </span> </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/database-tools/mongofiles/#mongodb-binary-bin.mongofiles" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongofiles </code> </span> </a> </p> </li> </ul> </div> </div> </td> </tr> <tr class=""> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> mongodb-org-database-tools-extra </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Contains the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/install_compass/#std-label-install-compass"> <code class="leafygreen-ui-1l06pbn"> install_compass </code> </a> script </div> </div> </td> </tr> </tbody> </table> </div> </div> </div> </td> </tr> </tbody> </table> </div> </section> </section> </section>
https://www.mongodb.com/docs/manual/administration/install-enterprise/
<section> <h1 class="contains-headerlink leafygreen-ui-41fr9s" weight="medium"> Install MongoDB Enterprise <a class="headerlink leafygreen-ui-1kepx47" href="#install-mongodb-enterprise" 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="install-mongodb-enterprise"> </div> </a> </h1> <div class="leafygreen-ui-15mdk4" role="note"> <h2 class="leafygreen-ui-6n7b7d"> Note </h2> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> Starting in MongoDB 8.0, LDAP authentication and authorization is deprecated. LDAP is available and will continue to operate without changes throughout the lifetime of MongoDB 8. LDAP will be removed in a future major release. </p> <p class="leafygreen-ui-1kp3ins"> For details, see <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/LDAP-deprecation/#std-label-ldap-deprecation"> LDAP Deprecation <!-- --> . </a> </p> </div> </div> <div class="leafygreen-ui-85da11" role="note"> <h2 class="leafygreen-ui-1ac4g5h"> Important </h2> <h3 class="leafygreen-ui-144d5kf"> <strong> MongoDB 8.0 Release Candidates </strong> </h3> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> MongoDB 8.0 binaries are currently available only as <strong> release candidates </strong> . Release candidates can be used for early testing of new features, but are not suitable for production deployments. </p> <p class="leafygreen-ui-1kp3ins"> This version of the manual is for an upcoming release and is currently a work in progress. </p> </div> </div> <p class="leafygreen-ui-1kp3ins"> These documents provide instructions to install MongoDB Enterprise. </p> <p class="leafygreen-ui-1kp3ins"> MongoDB Enterprise is available for MongoDB Enterprise subscribers and includes several additional features including LDAP authentication, Kerberos authentication, and System Event Auditing. </p> <dl> <dt> <a class="leafygreen-ui-tqgtui" href="/docs/manual/administration/install-enterprise-linux/#std-label-install-enterprise-linux"> Install on Linux </a> </dt> <dd class="css-1ufxuu7"> Install the official builds of MongoDB Enterprise on Linux-based systems. </dd> <dt> <a class="leafygreen-ui-tqgtui" href="/docs/manual/tutorial/install-mongodb-enterprise-on-os-x/#std-label-install-enterprise-macos"> Install on macOS </a> </dt> <dd class="css-1ufxuu7"> Install the official build of MongoDB Enterprise on macOS </dd> <dt> <a class="leafygreen-ui-tqgtui" href="/docs/manual/tutorial/install-mongodb-enterprise-on-windows/#std-label-install-enterprise-windows"> Install on Windows </a> </dt> <dd class="css-1ufxuu7"> Install MongoDB Enterprise on Windows using the <code class="leafygreen-ui-1l06pbn"> .msi </code> installer. </dd> <dt> <a class="leafygreen-ui-tqgtui" href="/docs/manual/tutorial/install-mongodb-enterprise-with-docker/#std-label-docker-mdb-enterprise-install"> Install with Docker </a> </dt> <dd class="css-1ufxuu7"> Install a MongoDB Enterprise Docker container. </dd> </dl> </section>
https://www.mongodb.com/docs/manual/reference/command/planCacheClear/
<section> <h1 class="contains-headerlink leafygreen-ui-41fr9s" weight="medium"> planCacheClear <a class="headerlink leafygreen-ui-1kepx47" href="#plancacheclear" 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="plancacheclear"> </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="#definition" target="_self"> <span> Definition </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#compatibility" target="_self"> <span> Compatibility </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#syntax" target="_self"> <span> Syntax </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#command-fields" target="_self"> <span> Command Fields </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#required-access" target="_self"> <span> Required Access </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#examples" target="_self"> <span> Examples </span> </a> </li> </ul> </div> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Definition <a class="headerlink leafygreen-ui-1kepx47" href="#definition" 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="definition"> </div> </a> </h2> <dl class="dbcommand"> <dt> <code class="leafygreen-ui-1l06pbn"> planCacheClear </code> <a class="headerlink leafygreen-ui-1kepx47" href="#mongodb-dbcommand-dbcmd.planCacheClear" title="Permalink to this definition"> <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="mongodb-dbcommand-dbcmd.planCacheClear"> </div> </a> </dt> <dd> <p class="leafygreen-ui-1kp3ins"> Removes cached query plans for a collection. Specify a <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-plan-cache-query-shape"> plan cache query shape </a> to remove cached query plans for that shape. Omit the plan cache query shape to clear all cached query plans. </p> <div class="leafygreen-ui-13vw3ie" role="note"> <h2 class="leafygreen-ui-1fn4p2b"> Tip </h2> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> In <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/mongodb-shell/#std-program-mongosh" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongosh </code> </span> </a> , this command can also be run through the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/PlanCache.clear/#mongodb-method-PlanCache.clear"> <code class="leafygreen-ui-1l06pbn"> PlanCache.clear() </code> </a> and <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/PlanCache.clearPlansByQuery/#mongodb-method-PlanCache.clearPlansByQuery"> <code class="leafygreen-ui-1l06pbn"> PlanCache.clearPlansByQuery() </code> </a> helper methods <!-- --> . </p> <p class="leafygreen-ui-1kp3ins"> Helper methods are convenient for <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/mongodb-shell/#std-program-mongosh" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongosh </code> </span> </a> users, but they may not return the same level of information as database commands. In cases where the convenience is not needed or the additional return fields are required, use the database command. </p> </div> </div> </dd> </dl> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Query Settings <a class="headerlink leafygreen-ui-1kepx47" href="#query-settings" 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="query-settings"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> Starting in MongoDB 8.0, use query settings instead of adding <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/query-plans/#std-label-index-filters"> index filters </a> . Index filters are deprecated starting in MongoDB 8.0. </p> <p class="leafygreen-ui-1kp3ins"> Query settings have more functionality than index filters. Also, index filters aren't persistent and you cannot easily create index filters for all cluster nodes. To add query settings and explore examples, see <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/command/setQuerySettings/#mongodb-dbcommand-dbcmd.setQuerySettings"> <code class="leafygreen-ui-1l06pbn"> setQuerySettings </code> . </a> </p> </section> </section> <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"> This command is available in 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> <div class="leafygreen-ui-85da11" role="note"> <h2 class="leafygreen-ui-1ac4g5h"> Important </h2> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> This command is not supported in M0, M2, and M5 clusters. For more information, see <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/atlas/unsupported-commands/" target="_self"> <span> Unsupported Commands <!-- --> . </span> </a> </p> </div> </div> <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"> Syntax <a class="headerlink leafygreen-ui-1kepx47" href="#syntax" 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="syntax"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> The command has the following syntax: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.runCommand(\n {\n planCacheClear: &lt;collection&gt;,\n query: &lt;query&gt;,\n sort: &lt;sort&gt;,\n projection: &lt;projection&gt;,\n comment: &lt;any&gt;\n }\n)","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">runCommand</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">planCacheClear</span>: &lt;<!-- -->collection<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">query</span>: &lt;<!-- -->query<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">sort</span>: &lt;<!-- -->sort<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">projection</span>: &lt;<!-- -->projection<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">comment</span>: &lt;<!-- -->any<!-- -->&gt;</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->}</td></tr><tr class=""><td class="leafygreen-ui-7razhx">)</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> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Command Fields <a class="headerlink leafygreen-ui-1kepx47" href="#command-fields" 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="command-fields"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> The command takes the following optional fields: </p> <div class="leafygreen-ui-skkc39" tabindex="0"> <table class="leafygreen-ui-hr8lsv"> <colgroup> <col style="width:20%"/> <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> Field </div> </div> </th> <th class="leafygreen-ui-13uteka" role="columnheader" scope="col"> <div class="leafygreen-ui-ui0te9"> <div> Type </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> <code class="leafygreen-ui-1l06pbn"> query </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> document </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Optional. The query predicate of the plan cache query shape. Only the structure of the predicate, including the field names, are significant to the shape; the values in the query predicate are insignificant. </div> </div> </td> </tr> <tr class=""> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> projection </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> document </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Optional. The projection associated with the plan cache query shape. </div> </div> </td> </tr> <tr class=""> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> sort </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> document </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Optional. The sort associated with the plan cache query shape. </div> </div> </td> </tr> <tr class=""> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> comment </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> any </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <p class="leafygreen-ui-1kp3ins"> Optional. A user-provided comment to attach to this command. Once set, this comment appears alongside records of this command in the following locations: </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/log-messages/#std-label-log-messages-ref"> mongod log messages </a> , in the <code class="leafygreen-ui-1l06pbn"> attr.command.cursor.comment </code> field. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/database-profiler/#std-label-profiler"> Database profiler </a> output, in the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/database-profiler/#mongodb-data-system.profile.command"> <code class="leafygreen-ui-1l06pbn"> command.comment </code> </a> field. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/command/currentOp/#mongodb-dbcommand-dbcmd.currentOp"> <code class="leafygreen-ui-1l06pbn"> currentOp </code> </a> output, in the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/command/currentOp/#mongodb-data-currentOp.command"> <code class="leafygreen-ui-1l06pbn"> command.comment </code> </a> field. </p> </li> </ul> <p class="leafygreen-ui-1kp3ins"> A comment can be any valid <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/bson-types/#std-label-bson-types"> BSON type </a> (string, integer, object, array, etc). </p> </div> </div> </td> </tr> </tbody> </table> </div> <p class="leafygreen-ui-1kp3ins"> To see the query shapes for which cached query plans exist, see <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/planCacheStats/#std-label-planCacheStats-examples"> Examples <!-- --> . </a> </p> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Required Access <a class="headerlink leafygreen-ui-1kepx47" href="#required-access" 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="required-access"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> On systems running with <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/configuration-options/#mongodb-setting-security.authorization"> <code class="leafygreen-ui-1l06pbn"> authorization </code> </a> , a user must have access that includes the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/privilege-actions/#mongodb-authaction-planCacheWrite"> <code class="leafygreen-ui-1l06pbn"> planCacheWrite </code> </a> action. </p> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Examples <a class="headerlink leafygreen-ui-1kepx47" href="#examples" 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="examples"> </div> </a> </h2> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Clear Cached Plans for a Plan Cache Query Shape <a class="headerlink leafygreen-ui-1kepx47" href="#clear-cached-plans-for-a-plan-cache-query-shape" 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="clear-cached-plans-for-a-plan-cache-query-shape"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> If a collection <code class="leafygreen-ui-1l06pbn"> orders </code> has the following plan cache query shape: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{\n \"query\" : { \"qty\" : { \"$gt\" : 10 } },\n \"sort\" : { \"ord_date\" : 1 },\n \"projection\" : { },\n \"planCacheShapeHash\" : \"9AAD95BE\"\n}","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"query"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-string">"qty"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-string">"$gt"</span> <!-- -->: <span class="lg-highlight-number">10</span> } }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"sort"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-string">"ord_date"</span> <!-- -->: <span class="lg-highlight-number">1</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"projection"</span> <!-- -->: <!-- -->{ <!-- -->}<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"planCacheShapeHash"</span> <!-- -->: <span class="lg-highlight-string">"9AAD95BE"</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx">}</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-1sjx7ru" role="note"> <h2 class="leafygreen-ui-29m78u"> Warning </h2> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> Starting in MongoDB 8.0, the pre-existing <code class="leafygreen-ui-1l06pbn"> queryHash </code> field is renamed to <code class="leafygreen-ui-1l06pbn"> planCacheShapeHash </code> . If you're using an earlier MongoDB version, you'll see <code class="leafygreen-ui-1l06pbn"> queryHash </code> instead of <code class="leafygreen-ui-1l06pbn"> planCacheShapeHash </code> . </p> </div> </div> <p class="leafygreen-ui-1kp3ins"> The following operation clears the query plan cached for the shape: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.runCommand(\n {\n planCacheClear: \"orders\",\n query: { \"qty\" : { \"$gt\" : 10 } },\n sort: { \"ord_date\" : 1 }\n }\n)","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">runCommand</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">planCacheClear</span>: <span class="lg-highlight-string">"orders"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">query</span>: <!-- -->{ <span class="lg-highlight-string">"qty"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-string">"$gt"</span> <!-- -->: <span class="lg-highlight-number">10</span> } }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">sort</span>: <!-- -->{ <span class="lg-highlight-string">"ord_date"</span> <!-- -->: <span class="lg-highlight-number">1</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">)</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> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Clear All Cached Plans for a Collection <a class="headerlink leafygreen-ui-1kepx47" href="#clear-all-cached-plans-for-a-collection" 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="clear-all-cached-plans-for-a-collection"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> The following example clears all the cached query plans for the <code class="leafygreen-ui-1l06pbn"> orders </code> collection: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.runCommand(\n {\n planCacheClear: \"orders\"\n }\n)","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">runCommand</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">planCacheClear</span>: <span class="lg-highlight-string">"orders"</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">)</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-13vw3ie" role="note"> <h2 class="leafygreen-ui-1fn4p2b"> Tip </h2> <h3 class="leafygreen-ui-144d5kf"> <strong> See also: </strong> </h3> <div class="leafygreen-ui-9mycqc"> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/PlanCache.clearPlansByQuery/#mongodb-method-PlanCache.clearPlansByQuery"> <code class="leafygreen-ui-1l06pbn"> PlanCache.clearPlansByQuery() </code> </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/PlanCache.clear/#mongodb-method-PlanCache.clear"> <code class="leafygreen-ui-1l06pbn"> PlanCache.clear() </code> </a> </p> </li> </ul> </div> </div> </section> </section> </section>
https://www.mongodb.com/docs/manual/reference/method/PlanCache.clearPlansByQuery/
<section> <h1 class="contains-headerlink leafygreen-ui-41fr9s" weight="medium"> PlanCache.clearPlansByQuery() <a class="headerlink leafygreen-ui-1kepx47" href="#plancache.clearplansbyquery--" 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="plancache.clearplansbyquery--"> </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="#definition" target="_self"> <span> Definition </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#required-access" target="_self"> <span> Required Access </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#example" target="_self"> <span> Example </span> </a> </li> </ul> </div> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Definition <a class="headerlink leafygreen-ui-1kepx47" href="#definition" 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="definition"> </div> </a> </h2> <dl class="method"> <dt> <code class="leafygreen-ui-1l06pbn"> PlanCache.clearPlansByQuery( &lt;query&gt;, &lt;projection&gt;, &lt;sort&gt; ) </code> <a class="headerlink leafygreen-ui-1kepx47" href="#mongodb-method-PlanCache.clearPlansByQuery" title="Permalink to this definition"> <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="mongodb-method-PlanCache.clearPlansByQuery"> </div> </a> </dt> <dd> <p class="leafygreen-ui-1kp3ins"> Clears the cached query plans for the specified <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-plan-cache-query-shape"> plan cache query shape <!-- --> . </a> </p> <div class="leafygreen-ui-85da11" role="note"> <h2 class="leafygreen-ui-1ac4g5h"> Important </h2> <h3 class="leafygreen-ui-144d5kf"> <strong> mongosh Method </strong> </h3> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> This page documents a <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/mongodb-shell/#mongodb-binary-bin.mongosh" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongosh </code> </span> </a> method. This is <em> not </em> the documentation for database commands or language-specific drivers, such as Node.js. </p> <p class="leafygreen-ui-1kp3ins"> For the database command, see the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/command/planCacheClear/#mongodb-dbcommand-dbcmd.planCacheClear"> <code class="leafygreen-ui-1l06pbn"> planCacheClear </code> </a> command <!-- --> . </p> <p class="leafygreen-ui-1kp3ins"> For MongoDB API drivers, refer to the language-specific <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/drivers/" target="_self"> <span> MongoDB driver documentation <!-- --> . </span> </a> </p> </div> </div> <p class="leafygreen-ui-1kp3ins"> The method is only available from the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/db.collection.getPlanCache/#mongodb-method-db.collection.getPlanCache"> <code class="leafygreen-ui-1l06pbn"> plan cache object </code> </a> of a specific collection; i.e. </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.collection.getPlanCache().clearPlansByQuery( &lt;query&gt;, &lt;projection&gt;, &lt;sort&gt; )","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-1q4bxgx" tabindex="0"><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">getPlanCache</span>(<!-- -->).<span class="lg-highlight-title lg-highlight-function">clearPlansByQuery</span>( &lt;<!-- -->query<!-- -->&gt;<!-- -->,<!-- --> <!-- -->&lt;<!-- -->projection<!-- -->&gt;<!-- -->,<!-- --> <!-- -->&lt;<!-- -->sort<!-- -->&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 <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-method-PlanCache.clearPlansByQuery" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> PlanCache.clearPlansByQuery() </code> </span> </a> method accepts the following parameters: </p> <div class="leafygreen-ui-skkc39" tabindex="0"> <table class="leafygreen-ui-hr8lsv"> <colgroup> <col style="width:20%"/> <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> Parameter </div> </div> </th> <th class="leafygreen-ui-13uteka" role="columnheader" scope="col"> <div class="leafygreen-ui-ui0te9"> <div> Type </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> <code class="leafygreen-ui-1l06pbn"> query </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> document </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> The query predicate of the plan cache query shape. Only the structure of the predicate, including the field names, are significant to the shape; the values in the query predicate are insignificant. </div> </div> </td> </tr> <tr class=""> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> projection </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> document </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Optional. The projection associated with the plan cache query shape. Required if specifying the <code class="leafygreen-ui-1l06pbn"> sort </code> parameter. </div> </div> </td> </tr> <tr class=""> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> sort </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> document </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Optional. The sort associated with the plan cache query shape. </div> </div> </td> </tr> </tbody> </table> </div> <p class="leafygreen-ui-1kp3ins"> To see the query shapes for which cached query plans exist, see <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/planCacheStats/#std-label-planCacheStats-examples"> Examples <!-- --> . </a> </p> </dd> </dl> <p class="leafygreen-ui-1kp3ins"> Starting in MongoDB 8.0, use query settings instead of adding <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/query-plans/#std-label-index-filters"> index filters </a> . Index filters are deprecated starting in MongoDB 8.0. </p> <p class="leafygreen-ui-1kp3ins"> Query settings have more functionality than index filters. Also, index filters aren't persistent and you cannot easily create index filters for all cluster nodes. To add query settings and explore examples, see <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/command/setQuerySettings/#mongodb-dbcommand-dbcmd.setQuerySettings"> <code class="leafygreen-ui-1l06pbn"> setQuerySettings </code> . </a> </p> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Required Access <a class="headerlink leafygreen-ui-1kepx47" href="#required-access" 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="required-access"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> On systems running with <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/configuration-options/#mongodb-setting-security.authorization"> <code class="leafygreen-ui-1l06pbn"> authorization </code> </a> , a user must have access that includes the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/privilege-actions/#mongodb-authaction-planCacheWrite"> <code class="leafygreen-ui-1l06pbn"> planCacheWrite </code> </a> action. </p> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Example <a class="headerlink leafygreen-ui-1kepx47" href="#example" 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="example"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> If a collection <code class="leafygreen-ui-1l06pbn"> orders </code> has the following plan cache query shape: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{\n \"query\" : { \"qty\" : { \"$gt\" : 10 } },\n \"sort\" : { \"ord_date\" : 1 },\n \"projection\" : { },\n \"planCacheShapeHash\" : \"9AAD95BE\"\n}","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"query"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-string">"qty"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-string">"$gt"</span> <!-- -->: <span class="lg-highlight-number">10</span> } }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"sort"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-string">"ord_date"</span> <!-- -->: <span class="lg-highlight-number">1</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"projection"</span> <!-- -->: <!-- -->{ <!-- -->}<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"planCacheShapeHash"</span> <!-- -->: <span class="lg-highlight-string">"9AAD95BE"</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx">}</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-1sjx7ru" role="note"> <h2 class="leafygreen-ui-29m78u"> Warning </h2> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> Starting in MongoDB 8.0, the pre-existing <code class="leafygreen-ui-1l06pbn"> queryHash </code> field is renamed to <code class="leafygreen-ui-1l06pbn"> planCacheShapeHash </code> . If you're using an earlier MongoDB version, you'll see <code class="leafygreen-ui-1l06pbn"> queryHash </code> instead of <code class="leafygreen-ui-1l06pbn"> planCacheShapeHash </code> . </p> </div> </div> <p class="leafygreen-ui-1kp3ins"> The following operation removes the query plan cached for the shape: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.orders.getPlanCache().clearPlansByQuery(\n { \"qty\" : { \"$gt\" : 10 } },\n { },\n { \"ord_date\" : 1 }\n)","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">orders</span>.<span class="lg-highlight-title lg-highlight-function">getPlanCache</span>(<!-- -->).<span class="lg-highlight-title lg-highlight-function">clearPlansByQuery</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"qty"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-string">"$gt"</span> <!-- -->: <span class="lg-highlight-number">10</span> } }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <!-- -->}<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"ord_date"</span> <!-- -->: <span class="lg-highlight-number">1</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">)</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-13vw3ie" role="note"> <h2 class="leafygreen-ui-1fn4p2b"> Tip </h2> <h3 class="leafygreen-ui-144d5kf"> <strong> See also: </strong> </h3> <div class="leafygreen-ui-9mycqc"> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/db.collection.getPlanCache/#mongodb-method-db.collection.getPlanCache"> <code class="leafygreen-ui-1l06pbn"> db.collection.getPlanCache() </code> </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <code class="leafygreen-ui-1l06pbn"> PlanCache.listQueryShapes() </code> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/PlanCache.clear/#mongodb-method-PlanCache.clear"> <code class="leafygreen-ui-1l06pbn"> PlanCache.clear() </code> </a> </p> </li> </ul> </div> </div> </section> </section>
https://www.mongodb.com/docs/manual/reference/command/getLog/
<section> <h1 class="contains-headerlink leafygreen-ui-41fr9s" weight="medium"> getLog <a class="headerlink leafygreen-ui-1kepx47" href="#getlog" 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="getlog"> </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="#definition" target="_self"> <span> Definition </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#compatibility" target="_self"> <span> Compatibility </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#syntax" target="_self"> <span> Syntax </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#command-fields" target="_self"> <span> Command Fields </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#output" target="_self"> <span> Output </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#behavior" target="_self"> <span> Behavior </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#filtering" target="_self"> <span> Filtering </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#examples" target="_self"> <span> Examples </span> </a> </li> </ul> </div> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Definition <a class="headerlink leafygreen-ui-1kepx47" href="#definition" 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="definition"> </div> </a> </h2> <dl class="dbcommand"> <dt> <code class="leafygreen-ui-1l06pbn"> getLog </code> <a class="headerlink leafygreen-ui-1kepx47" href="#mongodb-dbcommand-dbcmd.getLog" title="Permalink to this definition"> <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="mongodb-dbcommand-dbcmd.getLog"> </div> </a> </dt> <dd> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-dbcommand-dbcmd.getLog" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> getLog </code> </span> </a> is an administrative command that returns the most recent 1024 logged <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> events. <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-dbcommand-dbcmd.getLog" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> getLog </code> </span> </a> <em> does not </em> read log data from the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> log file. It instead reads data from a RAM cache of logged <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> events. To run <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-dbcommand-dbcmd.getLog" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> getLog </code> </span> </a> , use the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/db.adminCommand/#mongodb-method-db.adminCommand"> <code class="leafygreen-ui-1l06pbn"> db.adminCommand() </code> </a> method. </p> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-dbcommand-dbcmd.getLog" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> getLog </code> </span> </a> returns log data in escaped <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/mongodb-extended-json/#std-label-mongodb-extended-json-v2"> Relaxed Extended JSON v2.0 </a> format. Previously, log data was returned as plaintext. </p> </dd> </dl> </section> <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"> This command is available in 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> <div class="leafygreen-ui-15mdk4" role="note"> <h2 class="leafygreen-ui-6n7b7d"> Note </h2> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> This command is supported in all MongoDB Atlas clusters. For information on Atlas support for all commands, see <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/atlas/unsupported-commands/" target="_self"> <span> Unsupported Commands <!-- --> . </span> </a> </p> </div> </div> <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"> Syntax <a class="headerlink leafygreen-ui-1kepx47" href="#syntax" 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="syntax"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> The command has the following syntax: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.adminCommand(\n {\n getLog: &lt;value&gt;\n }\n)","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">adminCommand</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">getLog</span>: &lt;<!-- -->value<!-- -->&gt;</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->}</td></tr><tr class=""><td class="leafygreen-ui-7razhx">)</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> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Command Fields <a class="headerlink leafygreen-ui-1kepx47" href="#command-fields" 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="command-fields"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> The possible values for <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-dbcommand-dbcmd.getLog" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> getLog </code> </span> </a> are: </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> Value </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> <code class="leafygreen-ui-1l06pbn"> * </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Returns a list of the available values to the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-dbcommand-dbcmd.getLog" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> getLog </code> </span> </a> command. </div> </div> </td> </tr> <tr class=""> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> global </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Returns the combined output of all recent log entries. </div> </div> </td> </tr> <tr class=""> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> startupWarnings </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Returns log entries that <em> may </em> contain errors or warnings from MongoDB's log from when the current process started. If <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> started without warnings, this filter may return an empty array. </div> </div> </td> </tr> </tbody> </table> </div> <div class="leafygreen-ui-15mdk4" role="note"> <h2 class="leafygreen-ui-6n7b7d"> Note </h2> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> The <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-dbcommand-dbcmd.getLog" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> getLog </code> </span> </a> command no longer accepts the <code class="leafygreen-ui-1l06pbn"> rs </code> value, as this categorization of message type has been deprecated. Instead, log messages are now always identified by their <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/log-messages/#std-label-log-message-components"> component </a> - including <em> REPL </em> for replication messages. See <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/log-messages/#std-label-log-message-parsing-example-filter-component"> Filtering by Component </a> for log parsing examples that filter on the component field. </p> </div> </div> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Output <a class="headerlink leafygreen-ui-1kepx47" href="#output" 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="output"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> If specified <code class="leafygreen-ui-1l06pbn"> * </code> , then the command returns a document with the names of the other acceptable values. </p> <p class="leafygreen-ui-1kp3ins"> Otherwise, the command returns a document that includes the following fields: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <code class="leafygreen-ui-1l06pbn"> totalLinesWritten </code> field that contains the number of log events </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <code class="leafygreen-ui-1l06pbn"> log </code> field that contains an array of log events </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> A <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/db.adminCommand/#mongodb-method-db.adminCommand"> <code class="leafygreen-ui-1l06pbn"> db.adminCommand() </code> </a> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/db.adminCommand/#std-label-db-adminCommand-response"> response document </a> , containing status and timestamp information. </p> </li> </ul> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Behavior <a class="headerlink leafygreen-ui-1kepx47" href="#behavior" 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="behavior"> </div> </a> </h2> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Line Truncation <a class="headerlink leafygreen-ui-1kepx47" href="#line-truncation" 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="line-truncation"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-dbcommand-dbcmd.getLog" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> getLog </code> </span> </a> truncates any event that contains more than 1024 characters. </p> <span class="leafygreen-ui-1qnjd6d" id="std-label-getlog-character-escaping"> </span> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Character Escaping <a class="headerlink leafygreen-ui-1kepx47" href="#character-escaping" 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="character-escaping"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-dbcommand-dbcmd.getLog" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> getLog </code> </span> </a> returns log data in escaped <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/mongodb-extended-json/#std-label-mongodb-extended-json-v2"> Relaxed Extended JSON v2.0 </a> format, using the following escape sequences to render log output as valid JSON: </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> Character Represented </div> </div> </th> <th class="leafygreen-ui-13uteka" role="columnheader" scope="col"> <div class="leafygreen-ui-ui0te9"> <div> Escape Sequence </div> </div> </th> </tr> </thead> <tbody> <tr class="leafygreen-ui-15dvrnp"> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Quotation Mark ( <code class="leafygreen-ui-1l06pbn"> " </code> ) </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> \" </code> </div> </div> </td> </tr> <tr class="leafygreen-ui-15dvrnp"> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Backslash ( <code class="leafygreen-ui-1l06pbn"> \ </code> ) </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> \\ </code> </div> </div> </td> </tr> <tr class="leafygreen-ui-15dvrnp"> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Backspace ( <code class="leafygreen-ui-1l06pbn"> 0x08 </code> ) </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> \b </code> </div> </div> </td> </tr> <tr class="leafygreen-ui-15dvrnp"> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Formfeed ( <code class="leafygreen-ui-1l06pbn"> 0x0C </code> ) </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> \f </code> </div> </div> </td> </tr> <tr class="leafygreen-ui-15dvrnp"> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Newline ( <code class="leafygreen-ui-1l06pbn"> 0x0A </code> ) </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> \n </code> </div> </div> </td> </tr> <tr class="leafygreen-ui-15dvrnp"> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Carriage return ( <code class="leafygreen-ui-1l06pbn"> 0x0D </code> ) </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> \r </code> </div> </div> </td> </tr> <tr class="leafygreen-ui-15dvrnp"> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Horizontal tab ( <code class="leafygreen-ui-1l06pbn"> 0x09 </code> ) </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> \t </code> </div> </div> </td> </tr> </tbody> </table> </div> <p class="leafygreen-ui-1kp3ins"> Control characters not listed above are escaped with <code class="leafygreen-ui-1l06pbn"> \uXXXX </code> where "XXXX" is the unicode codepoint in hexadecimal. Bytes with invalid UTF-8 encoding are replaced with the unicode replacement character represented by <code class="leafygreen-ui-1l06pbn"> \ufffd </code> . </p> </section> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Filtering <a class="headerlink leafygreen-ui-1kepx47" href="#filtering" 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="filtering"> </div> </a> </h2> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Within <code class="leafygreen-ui-1l06pbn"> mongosh </code> <a class="headerlink leafygreen-ui-1kepx47" href="#within-mongosh" 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="within-mongosh"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-dbcommand-dbcmd.getLog" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> getLog </code> </span> </a> output can be filtered to make results more readable or to match on specific criteria. </p> <p class="leafygreen-ui-1kp3ins"> The following operation prints just the <code class="leafygreen-ui-1l06pbn"> log </code> field (which contains the array of all recent log events), and removes <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-getlog-character-escaping" target="_self"> <span> character escaping </span> </a> from each log message: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.adminCommand( { getLog:'global'} ).log.forEach(x =&gt; {print(x)})","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-1q4bxgx" tabindex="0"><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">adminCommand</span>( <!-- -->{ <span class="lg-highlight-attr">getLog</span>:<span class="lg-highlight-string">'global'</span>} ).<span class="lg-highlight-property">log</span>.<span class="lg-highlight-title lg-highlight-function">forEach</span>(<span class="lg-highlight-params lg-highlight-function">x</span><span class="lg-highlight-function"> =&gt;</span> <!-- -->{<span class="lg-highlight-title lg-highlight-function">print</span>(<!-- -->x)})</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"> This operation presents <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-dbcommand-dbcmd.getLog" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> getLog </code> </span> </a> output in the same format as the MongoDB <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#std-option-mongod.--logpath"> <code class="leafygreen-ui-1l06pbn"> log file </code> . </a> </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"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-dbcommand-dbcmd.getLog" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> getLog </code> </span> </a> only shows the most recent 1024 logged <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> events, and is not a replacement for the MongoDB <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#std-option-mongod.--logpath"> <code class="leafygreen-ui-1l06pbn"> log file </code> . </a> </p> </div> </div> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Outside <code class="leafygreen-ui-1l06pbn"> mongosh </code> with <code class="leafygreen-ui-1l06pbn"> jq </code> <a class="headerlink leafygreen-ui-1kepx47" href="#outside-mongosh-with-jq" 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="outside-mongosh-with-jq"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> When working with MongoDB structured logging, the third-party <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://stedolan.github.io/jq/" rel="noopener noreferrer"> <span> jq command-line utility </span> <svg alt="" aria-hidden="true" class="leafygreen-ui-1ie5kuq" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M13.823 2.4491C13.8201 2.30008 13.6999 2.17994 13.5509 2.17704L9.5062 2.09836C9.25654 2.09351 9.12821 2.39519 9.30482 2.5718L10.3856 3.65257L7.93433 6.10383C7.87964 6.15852 7.83047 6.21665 7.78683 6.27752L5.99909 8.06525C5.46457 8.59977 5.46457 9.4664 5.99909 10.0009C6.53361 10.5354 7.40023 10.5354 7.93475 10.0009L9.72249 8.21317C9.78336 8.16953 9.84148 8.12037 9.89618 8.06567L12.3474 5.61441L13.4282 6.69518C13.6048 6.87179 13.9065 6.74347 13.9016 6.4938L13.823 2.4491Z" fill="currentColor"> </path> <path d="M7.25 3.12893C7.66421 3.12893 8 3.46472 8 3.87893C8 4.29315 7.66421 4.62893 7.25 4.62893H4C3.72386 4.62893 3.5 4.85279 3.5 5.12893V11.9929C3.5 12.2691 3.72386 12.4929 4 12.4929H10.864C11.1401 12.4929 11.364 12.2691 11.364 11.9929V8.75C11.364 8.33579 11.6998 8 12.114 8C12.5282 8 12.864 8.33579 12.864 8.75V11.9929C12.864 13.0975 11.9686 13.9929 10.864 13.9929H4C2.89543 13.9929 2 13.0975 2 11.9929V5.12893C2 4.02436 2.89543 3.12893 4 3.12893H7.25Z" fill="currentColor"> </path> </svg> </a> is a useful tool that allows for easy pretty-printing of log entries, and powerful key-based matching and filtering. </p> <p class="leafygreen-ui-1kp3ins"> <code class="leafygreen-ui-1l06pbn"> jq </code> is an open-source JSON parser, and is available for Linux, Windows, and macOS. </p> <p class="leafygreen-ui-1kp3ins"> To use <code class="leafygreen-ui-1l06pbn"> jq </code> with <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-dbcommand-dbcmd.getLog" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> getLog </code> </span> </a> output, you must use the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/mongodb-shell/reference/options/#std-option-mongosh.--eval" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> --eval </code> </span> </a> option to <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/mongodb-shell/#mongodb-binary-bin.mongosh" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongosh </code> </span> </a> . The following operation uses <code class="leafygreen-ui-1l06pbn"> jq </code> to filter on the <strong> REPL </strong> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/log-messages/#std-label-log-message-components"> component </a> to present only those log messages associated with replication: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"mongosh --quiet --eval \"db.adminCommand( { getLog:'global'} ).log.forEach(x =&gt; {print(x)})\" | jq -c '. | select(.c==\"REPL\")'","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-1q4bxgx" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">mongosh <!-- -->-<!-- -->-<!-- -->quiet <!-- -->-<!-- -->-<span class="lg-highlight-built_in">eval</span> <span class="lg-highlight-string">"db.adminCommand( { getLog:'global'} ).log.forEach(x =&gt; {print(x)})"</span> <!-- -->| <!-- -->jq <!-- -->-<!-- -->c <span class="lg-highlight-string">'. | select(.c=="REPL")'</span></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"> Be sure to provide any necessary connection-specific parameters to <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/mongodb-shell/#mongodb-binary-bin.mongosh" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongosh </code> </span> </a> as needed, such as <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/mongodb-shell/reference/options/#std-option-mongosh.--host" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> --host </code> </span> </a> or <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/mongodb-shell/reference/options/#std-option-mongosh.--port" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> --port </code> . </span> </a> </p> <p class="leafygreen-ui-1kp3ins"> See <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/log-messages/#std-label-log-message-parsing"> Parsing Structured Log Messages </a> for more examples of filtering log output using <code class="leafygreen-ui-1l06pbn"> jq </code> . The <code class="leafygreen-ui-1l06pbn"> jq </code> syntax presented in each linked example can be used with the above <code class="leafygreen-ui-1l06pbn"> mongo --eval </code> operation with minor adjustment. For example, the following syntax adapts the linked "Counting Unique Messages" example for use with <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-dbcommand-dbcmd.getLog" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> getLog </code> : </span> </a> </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"mongosh --quiet --eval \"db.adminCommand( { getLog:'global'} ).log.forEach(x =&gt; {print(x)})\" | jq -r \".msg\" | sort | uniq -c | sort -rn | head -10","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-1q4bxgx" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">mongosh <!-- -->-<!-- -->-<!-- -->quiet <!-- -->-<!-- -->-<span class="lg-highlight-built_in">eval</span> <span class="lg-highlight-string">"db.adminCommand( { getLog:'global'} ).log.forEach(x =&gt; {print(x)})"</span> <!-- -->| <!-- -->jq <!-- -->-<!-- -->r <span class="lg-highlight-string">".msg"</span> <!-- -->| <!-- -->sort <!-- -->| <!-- -->uniq <!-- -->-<!-- -->c <!-- -->| <!-- -->sort <!-- -->-<!-- -->rn <!-- -->| <!-- -->head <!-- -->-<span class="lg-highlight-number">10</span></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> </section> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Examples <a class="headerlink leafygreen-ui-1kepx47" href="#examples" 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="examples"> </div> </a> </h2> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Retrieve Available Log Filters <a class="headerlink leafygreen-ui-1kepx47" href="#retrieve-available-log-filters" 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="retrieve-available-log-filters"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> The following operation, run from <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/mongodb-shell/#mongodb-binary-bin.mongosh" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongosh </code> </span> </a> , returns the available log filters for passing to <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-dbcommand-dbcmd.getLog" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> getLog </code> : </span> </a> </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.adminCommand( { getLog: \"*\" } )","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">adminCommand</span>( <!-- -->{ <span class="lg-highlight-attr">getLog</span>: <span class="lg-highlight-string">"*"</span> } )</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 operation returns the following document: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ \"names\" : [ \"global\", \"startupWarnings\" ], \"ok\" : 1 }","programmingLanguage":"JavaScript"} </script> <div class="css-1lju8ps"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1jheeh3"> <pre class="leafygreen-ui-1agdxuk" 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">{ <span class="lg-highlight-string">"names"</span> <!-- -->: <!-- -->[ <span class="lg-highlight-string">"global"</span>, <span class="lg-highlight-string">"startupWarnings"</span> ]<!-- -->, <span class="lg-highlight-string">"ok"</span> <!-- -->: <span class="lg-highlight-number">1</span> }</td></tr></tbody></table></code></pre> </div> </div> </div> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Retrieve Recent Events from Log <a class="headerlink leafygreen-ui-1kepx47" href="#retrieve-recent-events-from-log" 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="retrieve-recent-events-from-log"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> The following operation, run from <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/mongodb-shell/#mongodb-binary-bin.mongosh" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongosh </code> </span> </a> , retrieves the most recent <code class="leafygreen-ui-1l06pbn"> global </code> events for the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> : </a> </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.adminCommand( { getLog : \"global\" } )","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">adminCommand</span>( <!-- -->{ <!-- -->getLog <!-- -->: <span class="lg-highlight-string">"global"</span> } )</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 operation returns a document similar to the following: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{\n \"totalLinesWritten\" : &lt;num&gt;,\n \"log\" : [\n \"{\\\"t\\\":{\\\"$date\\\":\\\"2020-05-19T19:10:48.871+00:00\\\"},\\\"s\\\":\\\"I\\\", \\\"c\\\":\\\"STORAGE\\\", \\\"id\\\":4615611, \\\"ctx\\\":\\\"initandlisten\\\",\\\"msg\\\":\\\"MongoDB starting\\\",\\\"attr\\\":{\\\"pid\\\":12345,\\\"port\\\":27001,\\\"dbPath\\\":\\\"/var/lib/mongo\\\",\\\"architecture\\\":\\\"64-bit\\\",\\\"host\\\":\\\"server1.example.com\\\"}}\",\n \"{\\\"t\\\":{\\\"$date\\\":\\\"2020-05-19T19:10:48.871+00:00\\\"},\\\"s\\\":\\\"I\\\", \\\"c\\\":\\\"CONTROL\\\", \\\"id\\\":23403, \\\"ctx\\\":\\\"initandlisten\\\",\\\"msg\\\":\\\"Build Info\\\",\\\"attr\\\":{\\\"buildInfo\\\":{\\\"version\\\":\\\"4.4.0\\\",\\\"gitVersion\\\":\\\"328c35e4b883540675fb4b626c53a08f74e43cf0\\\",\\\"openSSLVersion\\\":\\\"OpenSSL 1.1.1c FIPS 28 May 2019\\\",\\\"modules\\\":[],\\\"allocator\\\":\\\"tcmalloc\\\",\\\"environment\\\":{\\\"distmod\\\":\\\"rhel80\\\",\\\"distarch\\\":\\\"x86_64\\\",\\\"target_arch\\\":\\\"x86_64\\\"}}}}\",\n \"{\\\"t\\\":{\\\"$date\\\":\\\"2020-05-19T19:10:48.871+00:00\\\"},\\\"s\\\":\\\"I\\\", \\\"c\\\":\\\"CONTROL\\\", \\\"id\\\":51765, \\\"ctx\\\":\\\"initandlisten\\\",\\\"msg\\\":\\\"Operating System\\\",\\\"attr\\\":{\\\"os\\\":{\\\"name\\\":\\\"CentOS Linux release 8.0.1905 (Core) \\\",\\\"version\\\":\\\"Kernel 4.18.0-80.11.2.el8_0.x86_64\\\"}}}\",\n \"{\\\"t\\\":{\\\"$date\\\":\\\"2020-05-19T19:10:48.871+00:00\\\"},\\\"s\\\":\\\"I\\\", \\\"c\\\":\\\"CONTROL\\\", \\\"id\\\":21951, \\\"ctx\\\":\\\"initandlisten\\\",\\\"msg\\\":\\\"Options set by command line\\\",\\\"attr\\\":{\\\"options\\\":{\\\"config\\\":\\\"/etc/mongod.conf\\\",\\\"net\\\":{\\\"bindIp\\\":\\\"127.0.0.1\\\",\\\"port\\\":27001},\\\"processManagement\\\":{\\\"fork\\\":true,\\\"timeZoneInfo\\\":\\\"/usr/share/zoneinfo\\\"},\\\"replication\\\":{\\\"replSetName\\\":\\\"repl-shard1\\\"},\\\"sharding\\\":{\\\"clusterRole\\\":\\\"shardsvr\\\"},\\\"storage\\\":{\\\"dbPath\\\":\\\"/var/lib/mongo\\\",\\\"journal\\\":{\\\"enabled\\\":true},\\\"wiredTiger\\\":{\\\"engineConfig\\\":{\\\"cacheSizeGB\\\":0.1}}},\\\"systemLog\\\":{\\\"destination\\\":\\\"file\\\",\\\"logAppend\\\":true,\\\"path\\\":\\\"/var/log/mongodb/mongod.log\\\"}}}}\",\n \"{\\\"t\\\":{\\\"$date\\\":\\\"2020-05-19T19:10:48.873+00:00\\\"},\\\"s\\\":\\\"I\\\", \\\"c\\\":\\\"STORAGE\\\", \\\"id\\\":22270, \\\"ctx\\\":\\\"initandlisten\\\",\\\"msg\\\":\\\"Storage engine to use detected by data files\\\",\\\"attr\\\":{\\\"dbpath\\\":\\\"/var/lib/mongo\\\",\\\"storageEngine\\\":\\\"wiredTiger\\\"}}\",\n \"{\\\"t\\\":{\\\"$date\\\":\\\"2020-05-19T19:10:48.873+00:00\\\"},\\\"s\\\":\\\"I\\\", \\\"c\\\":\\\"STORAGE\\\", \\\"id\\\":22315, \\\"ctx\\\":\\\"initandlisten\\\",\\\"msg\\\":\\\"wiredtiger_open config\\\",\\\"attr\\\":{\\\"config\\\":\\\"create,cache_size=102M,session_max=33000,eviction=(threads_min=4,threads_max=4),config_base=false,statistics=(fast),log=(enabled=true,archive=true,path=journal,compressor=snappy),file_manager=(close_idle_time=100000,close_scan_interval=10,close_handle_minimum=250),statistics_log=(wait=0),verbose=[recovery_progress,checkpoint_progress,compact_progress],\\\"}}\",\n \"{\\\"t\\\":{\\\"$date\\\":\\\"2020-05-19T19:10:58.877+00:00\\\"},\\\"s\\\":\\\"I\\\", \\\"c\\\":\\\"CONNPOOL\\\", \\\"id\\\":22576, \\\"ctx\\\":\\\"ReplicaSetMonitor-TaskExecutor\\\",\\\"msg\\\":\\\"Connecting\\\",\\\"attr\\\":{\\\"hostAndPort\\\":\\\"server1.example.com:27001\\\"}}\",\n \"{\\\"t\\\":{\\\"$date\\\":\\\"2020-05-19T19:10:58.877+00:00\\\"},\\\"s\\\":\\\"I\\\", \\\"c\\\":\\\"CONNPOOL\\\", \\\"id\\\":22576, \\\"ctx\\\":\\\"ReplicaSetMonitor-TaskExecutor\\\",\\\"msg\\\":\\\"Connecting\\\",\\\"attr\\\":{\\\"hostAndPort\\\":\\\"server2.example.com:27001\\\"}}\",\n \"{\\\"t\\\":{\\\"$date\\\":\\\"2020-05-19T19:10:58.877+00:00\\\"},\\\"s\\\":\\\"I\\\", \\\"c\\\":\\\"CONNPOOL\\\", \\\"id\\\":22576, \\\"ctx\\\":\\\"ReplicaSetMonitor-TaskExecutor\\\",\\\"msg\\\":\\\"Connecting\\\",\\\"attr\\\":{\\\"hostAndPort\\\":\\\"server3.example.com:27001\\\"}}\",\n \"{\\\"t\\\":{\\\"$date\\\":\\\"2020-05-19T19:10:58.877+00:00\\\"},\\\"s\\\":\\\"I\\\", \\\"c\\\":\\\"CONNPOOL\\\", \\\"id\\\":22576, \\\"ctx\\\":\\\"ReplicaSetMonitor-TaskExecutor\\\",\\\"msg\\\":\\\"Connecting\\\",\\\"attr\\\":{\\\"hostAndPort\\\":\\\"server4.example.com:27001\\\"}}\",\n \"{\\\"t\\\":{\\\"$date\\\":\\\"2020-05-19T19:10:58.877+00:00\\\"},\\\"s\\\":\\\"I\\\", \\\"c\\\":\\\"CONNPOOL\\\", \\\"id\\\":22576, \\\"ctx\\\":\\\"ReplicaSetMonitor-TaskExecutor\\\",\\\"msg\\\":\\\"Connecting\\\",\\\"attr\\\":{\\\"hostAndPort\\\":\\\"server5.example.com:27001\\\"}}\",\n \"{\\\"t\\\":{\\\"$date\\\":\\\"2020-05-19T19:10:58.877+00:00\\\"},\\\"s\\\":\\\"I\\\", \\\"c\\\":\\\"CONNPOOL\\\", \\\"id\\\":22576, \\\"ctx\\\":\\\"ReplicaSetMonitor-TaskExecutor\\\",\\\"msg\\\":\\\"Connecting\\\",\\\"attr\\\":{\\\"hostAndPort\\\":\\\"server6.example.com:27001\\\"}}\",\n \"{\\\"t\\\":{\\\"$date\\\":\\\"2020-05-19T19:10:58.877+00:00\\\"},\\\"s\\\":\\\"I\\\", \\\"c\\\":\\\"NETWORK\\\", \\\"id\\\":23015, \\\"ctx\\\":\\\"listener\\\",\\\"msg\\\":\\\"Listening on\\\",\\\"attr\\\":{\\\"address\\\":\\\"/tmp/mongodb-27001.sock\\\"}}\",\n \"{\\\"t\\\":{\\\"$date\\\":\\\"2020-05-19T19:10:58.877+00:00\\\"},\\\"s\\\":\\\"I\\\", \\\"c\\\":\\\"NETWORK\\\", \\\"id\\\":23015, \\\"ctx\\\":\\\"listener\\\",\\\"msg\\\":\\\"Listening on\\\",\\\"attr\\\":{\\\"address\\\":\\\"127.0.0.1\\\"}}\",\n \"{\\\"t\\\":{\\\"$date\\\":\\\"2020-05-19T19:10:58.877+00:00\\\"},\\\"s\\\":\\\"I\\\", \\\"c\\\":\\\"NETWORK\\\", \\\"id\\\":23016, \\\"ctx\\\":\\\"listener\\\",\\\"msg\\\":\\\"Waiting for connections\\\",\\\"attr\\\":{\\\"port\\\":27001,\\\"ssl\\\":\\\"off\\\"}}\",\n \"{\\\"t\\\":{\\\"$date\\\":\\\"2020-05-19T19:15:10.392+00:00\\\"},\\\"s\\\":\\\"I\\\", \\\"c\\\":\\\"NETWORK\\\", \\\"id\\\":22943, \\\"ctx\\\":\\\"listener\\\",\\\"msg\\\":\\\"connection accepted\\\",\\\"attr\\\":{\\\"remote\\\":\\\"127.0.0.1:35724\\\",\\\"sessionId\\\":67,\\\"connectionCount\\\":30}}\",\n \"{\\\"t\\\":{\\\"$date\\\":\\\"2020-05-19T19:15:10.393+00:00\\\"},\\\"s\\\":\\\"I\\\", \\\"c\\\":\\\"NETWORK\\\", \\\"id\\\":51800, \\\"ctx\\\":\\\"conn67\\\",\\\"msg\\\":\\\"client metadata\\\",\\\"attr\\\":{\\\"remote\\\":\\\"127.0.0.1:35724\\\",\\\"client\\\":\\\"conn67\\\",\\\"doc\\\":{\\\"application\\\":{\\\"name\\\":\\\"MongoDB Shell\\\"},\\\"driver\\\":{\\\"name\\\":\\\"MongoDB Internal Client\\\",\\\"version\\\":\\\"4.4.0\\\"},\\\"os\\\":{\\\"type\\\":\\\"Linux\\\",\\\"name\\\":\\\"CentOS Linux release 8.0.1905 (Core) \\\",\\\"architecture\\\":\\\"x86_64\\\",\\\"version\\\":\\\"Kernel 4.18.0-80.11.2.el8_0.x86_64\\\"}}}}\"\n ],\n \"ok\" : 1,\n \"$gleStats\" : {\n \"lastOpTime\" : Timestamp(&lt;ts&gt;),\n \"electionId\" : ObjectId(&lt;id&gt;)\n },\n \"lastCommittedOpTime\" : Timestamp(&lt;ts&gt;),\n \"$configServerState\" : {\n \"opTime\" : {\n \"ts\" : Timestamp(&lt;ts&gt;),\n \"t\" : NumberLong(8)\n }\n },\n \"$clusterTime\" : {\n \"clusterTime\" : Timestamp(&lt;ts&gt;),\n \"signature\" : {\n \"hash\" : BinData(&lt;bin&gt;),\n \"keyId\" : NumberLong(0)\n }\n },\n \"operationTime\" : Timestamp(&lt;ts&gt;)\n}","programmingLanguage":"JavaScript"} </script> <div class="css-1lju8ps"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-tyg50d"> <pre class="leafygreen-ui-1453az5" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"totalLinesWritten"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"log"</span> <!-- -->: <!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"{</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">t</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:{</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">$date</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">2020-05-19T19:10:48.871+00:00</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">},</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">s</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">I</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">, </span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">c</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">STORAGE</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">, </span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">id</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:4615611, </span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">ctx</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">initandlisten</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">,</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">msg</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">MongoDB starting</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">,</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">attr</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:{</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">pid</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:12345,</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">port</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:27001,</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">dbPath</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">/var/lib/mongo</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">,</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">architecture</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">64-bit</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">,</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">host</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">server1.example.com</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">}}"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"{</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">t</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:{</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">$date</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">2020-05-19T19:10:48.871+00:00</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">},</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">s</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">I</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">, </span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">c</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">CONTROL</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">, </span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">id</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:23403, </span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">ctx</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">initandlisten</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">,</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">msg</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">Build Info</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">,</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">attr</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:{</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">buildInfo</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:{</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">version</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">4.4.0</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">,</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">gitVersion</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">328c35e4b883540675fb4b626c53a08f74e43cf0</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">,</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">openSSLVersion</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">OpenSSL 1.1.1c FIPS 28 May 2019</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">,</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">modules</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:[],</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">allocator</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">tcmalloc</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">,</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">environment</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:{</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">distmod</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">rhel80</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">,</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">distarch</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">x86_64</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">,</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">target_arch</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">x86_64</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">}}}}"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"{</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">t</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:{</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">$date</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">2020-05-19T19:10:48.871+00:00</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">},</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">s</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">I</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">, </span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">c</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">CONTROL</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">, </span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">id</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:51765, </span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">ctx</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">initandlisten</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">,</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">msg</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">Operating System</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">,</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">attr</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:{</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">os</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:{</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">name</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">CentOS Linux release 8.0.1905 (Core) </span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">,</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">version</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">Kernel 4.18.0-80.11.2.el8_0.x86_64</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">}}}"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"{</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">t</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:{</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">$date</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">2020-05-19T19:10:48.871+00:00</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">},</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">s</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">I</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">, </span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">c</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">CONTROL</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">, </span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">id</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:21951, </span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">ctx</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">initandlisten</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">,</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">msg</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">Options set by command line</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">,</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">attr</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:{</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">options</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:{</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">config</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">/etc/mongod.conf</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">,</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">net</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:{</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">bindIp</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">127.0.0.1</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">,</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">port</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:27001},</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">processManagement</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:{</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">fork</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:true,</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">timeZoneInfo</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">/usr/share/zoneinfo</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">},</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">replication</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:{</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">replSetName</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">repl-shard1</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">},</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">sharding</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:{</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">clusterRole</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">shardsvr</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">},</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">storage</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:{</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">dbPath</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">/var/lib/mongo</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">,</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">journal</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:{</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">enabled</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:true},</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">wiredTiger</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:{</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">engineConfig</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:{</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">cacheSizeGB</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:0.1}}},</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">systemLog</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:{</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">destination</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">file</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">,</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">logAppend</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:true,</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">path</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">/var/log/mongodb/mongod.log</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">}}}}"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"{</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">t</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:{</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">$date</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">2020-05-19T19:10:48.873+00:00</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">},</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">s</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">I</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">, </span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">c</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">STORAGE</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">, </span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">id</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:22270, </span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">ctx</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">initandlisten</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">,</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">msg</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">Storage engine to use detected by data files</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">,</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">attr</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:{</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">dbpath</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">/var/lib/mongo</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">,</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">storageEngine</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">wiredTiger</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">}}"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"{</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">t</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:{</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">$date</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">2020-05-19T19:10:48.873+00:00</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">},</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">s</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">I</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">, </span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">c</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">STORAGE</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">, </span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">id</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:22315, </span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">ctx</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">initandlisten</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">,</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">msg</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">wiredtiger_open config</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">,</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">attr</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:{</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">config</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">create,cache_size=102M,session_max=33000,eviction=(threads_min=4,threads_max=4),config_base=false,statistics=(fast),log=(enabled=true,archive=true,path=journal,compressor=snappy),file_manager=(close_idle_time=100000,close_scan_interval=10,close_handle_minimum=250),statistics_log=(wait=0),verbose=[recovery_progress,checkpoint_progress,compact_progress],</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">}}"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"{</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">t</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:{</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">$date</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">2020-05-19T19:10:58.877+00:00</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">},</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">s</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">I</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">, </span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">c</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">CONNPOOL</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">, </span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">id</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:22576, </span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">ctx</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">ReplicaSetMonitor-TaskExecutor</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">,</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">msg</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">Connecting</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">,</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">attr</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:{</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">hostAndPort</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">server1.example.com:27001</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">}}"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"{</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">t</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:{</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">$date</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">2020-05-19T19:10:58.877+00:00</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">},</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">s</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">I</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">, </span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">c</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">CONNPOOL</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">, </span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">id</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:22576, </span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">ctx</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">ReplicaSetMonitor-TaskExecutor</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">,</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">msg</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">Connecting</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">,</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">attr</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:{</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">hostAndPort</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">server2.example.com:27001</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">}}"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"{</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">t</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:{</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">$date</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">2020-05-19T19:10:58.877+00:00</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">},</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">s</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">I</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">, </span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">c</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">CONNPOOL</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">, </span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">id</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:22576, </span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">ctx</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">ReplicaSetMonitor-TaskExecutor</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">,</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">msg</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">Connecting</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">,</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">attr</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:{</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">hostAndPort</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">server3.example.com:27001</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">}}"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"{</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">t</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:{</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">$date</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">2020-05-19T19:10:58.877+00:00</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">},</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">s</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">I</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">, </span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">c</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">CONNPOOL</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">, </span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">id</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:22576, </span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">ctx</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">ReplicaSetMonitor-TaskExecutor</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">,</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">msg</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">Connecting</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">,</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">attr</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:{</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">hostAndPort</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">server4.example.com:27001</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">}}"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"{</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">t</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:{</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">$date</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">2020-05-19T19:10:58.877+00:00</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">},</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">s</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">I</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">, </span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">c</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">CONNPOOL</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">, </span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">id</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:22576, </span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">ctx</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">ReplicaSetMonitor-TaskExecutor</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">,</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">msg</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">Connecting</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">,</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">attr</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:{</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">hostAndPort</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">server5.example.com:27001</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">}}"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"{</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">t</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:{</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">$date</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">2020-05-19T19:10:58.877+00:00</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">},</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">s</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">I</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">, </span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">c</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">CONNPOOL</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">, </span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">id</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:22576, </span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">ctx</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">ReplicaSetMonitor-TaskExecutor</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">,</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">msg</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">Connecting</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">,</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">attr</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:{</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">hostAndPort</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">server6.example.com:27001</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">}}"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"{</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">t</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:{</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">$date</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">2020-05-19T19:10:58.877+00:00</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">},</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">s</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">I</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">, </span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">c</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">NETWORK</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">, </span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">id</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:23015, </span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">ctx</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">listener</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">,</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">msg</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">Listening on</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">,</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">attr</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:{</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">address</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">/tmp/mongodb-27001.sock</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">}}"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"{</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">t</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:{</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">$date</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">2020-05-19T19:10:58.877+00:00</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">},</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">s</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">I</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">, </span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">c</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">NETWORK</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">, </span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">id</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:23015, </span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">ctx</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">listener</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">,</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">msg</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">Listening on</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">,</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">attr</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:{</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">address</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">127.0.0.1</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">}}"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"{</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">t</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:{</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">$date</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">2020-05-19T19:10:58.877+00:00</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">},</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">s</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">I</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">, </span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">c</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">NETWORK</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">, </span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">id</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:23016, </span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">ctx</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">listener</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">,</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">msg</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">Waiting for connections</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">,</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">attr</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:{</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">port</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:27001,</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">ssl</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">off</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">}}"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"{</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">t</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:{</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">$date</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">2020-05-19T19:15:10.392+00:00</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">},</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">s</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">I</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">, </span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">c</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">NETWORK</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">, </span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">id</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:22943, </span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">ctx</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">listener</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">,</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">msg</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">connection accepted</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">,</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">attr</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:{</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">remote</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">127.0.0.1:35724</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">,</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">sessionId</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:67,</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">connectionCount</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:30}}"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"{</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">t</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:{</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">$date</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">2020-05-19T19:15:10.393+00:00</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">},</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">s</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">I</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">, </span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">c</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">NETWORK</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">, </span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">id</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:51800, </span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">ctx</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">conn67</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">,</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">msg</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">client metadata</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">,</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">attr</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:{</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">remote</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">127.0.0.1:35724</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">,</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">client</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">conn67</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">,</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">doc</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:{</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">application</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:{</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">name</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">MongoDB Shell</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">},</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">driver</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:{</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">name</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">MongoDB Internal Client</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">,</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">version</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">4.4.0</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">},</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">os</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:{</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">type</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">Linux</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">,</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">name</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">CentOS Linux release 8.0.1905 (Core) </span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">,</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">architecture</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">x86_64</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">,</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">version</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">:</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">Kernel 4.18.0-80.11.2.el8_0.x86_64</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">}}}}"</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> ]<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"ok"</span> <!-- -->: <span class="lg-highlight-number">1</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"$gleStats"</span> <!-- -->: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"lastOpTime"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">Timestamp</span>(&lt;<!-- -->ts<!-- -->&gt;<!-- -->)<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"electionId"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">ObjectId</span>(&lt;<!-- -->id<!-- -->&gt;<!-- -->)</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"lastCommittedOpTime"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">Timestamp</span>(&lt;<!-- -->ts<!-- -->&gt;<!-- -->)<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"$configServerState"</span> <!-- -->: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"opTime"</span> <!-- -->: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"ts"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">Timestamp</span>(&lt;<!-- -->ts<!-- -->&gt;<!-- -->)<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"t"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">NumberLong</span>(<span class="lg-highlight-number">8</span>)</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"$clusterTime"</span> <!-- -->: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"clusterTime"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">Timestamp</span>(&lt;<!-- -->ts<!-- -->&gt;<!-- -->)<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"signature"</span> <!-- -->: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"hash"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">BinData</span>(&lt;<!-- -->bin<!-- -->&gt;<!-- -->)<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"keyId"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">NumberLong</span>(<span class="lg-highlight-number">0</span>)</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"operationTime"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">Timestamp</span>(&lt;<!-- -->ts<!-- -->&gt;<!-- -->)</td></tr><tr class=""><td class="leafygreen-ui-7razhx">}</td></tr></tbody></table></code></pre> </div> </div> </div> </section> </section> </section>
https://www.mongodb.com/docs/manual/tutorial/install-mongodb-on-os-x/
<section> <h1 class="contains-headerlink leafygreen-ui-41fr9s" weight="medium"> Install MongoDB Community Edition on macOS <a class="headerlink leafygreen-ui-1kepx47" href="#install-mongodb-community-edition-on-macos" 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="install-mongodb-community-edition-on-macos"> </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="#overview" target="_self"> <span> Overview </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#considerations" target="_self"> <span> Considerations </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#install-mongodb-community-edition" target="_self"> <span> Install MongoDB Community Edition </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#run-mongodb-community-edition" target="_self"> <span> Run MongoDB Community Edition </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#using-the-mongodb-database-tools" target="_self"> <span> Using the MongoDB Database Tools </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#additional-information" target="_self"> <span> Additional Information </span> </a> </li> </ul> </div> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Overview <a class="headerlink leafygreen-ui-1kepx47" href="#overview" 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="overview"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> Use this tutorial to install MongoDB 8.0 <!-- --> Community <!-- --> Edition on macOS using the third-party <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://brew.sh" rel="noopener noreferrer"> <span> Homebrew </span> <svg alt="" aria-hidden="true" class="leafygreen-ui-1ie5kuq" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M13.823 2.4491C13.8201 2.30008 13.6999 2.17994 13.5509 2.17704L9.5062 2.09836C9.25654 2.09351 9.12821 2.39519 9.30482 2.5718L10.3856 3.65257L7.93433 6.10383C7.87964 6.15852 7.83047 6.21665 7.78683 6.27752L5.99909 8.06525C5.46457 8.59977 5.46457 9.4664 5.99909 10.0009C6.53361 10.5354 7.40023 10.5354 7.93475 10.0009L9.72249 8.21317C9.78336 8.16953 9.84148 8.12037 9.89618 8.06567L12.3474 5.61441L13.4282 6.69518C13.6048 6.87179 13.9065 6.74347 13.9016 6.4938L13.823 2.4491Z" fill="currentColor"> </path> <path d="M7.25 3.12893C7.66421 3.12893 8 3.46472 8 3.87893C8 4.29315 7.66421 4.62893 7.25 4.62893H4C3.72386 4.62893 3.5 4.85279 3.5 5.12893V11.9929C3.5 12.2691 3.72386 12.4929 4 12.4929H10.864C11.1401 12.4929 11.364 12.2691 11.364 11.9929V8.75C11.364 8.33579 11.6998 8 12.114 8C12.5282 8 12.864 8.33579 12.864 8.75V11.9929C12.864 13.0975 11.9686 13.9929 10.864 13.9929H4C2.89543 13.9929 2 13.0975 2 11.9929V5.12893C2 4.02436 2.89543 3.12893 4 3.12893H7.25Z" fill="currentColor"> </path> </svg> </a> package manager. </p> <p class="leafygreen-ui-1kp3ins"> Starting with MongoDB 4.4.1, installing MongoDB through Homebrew also installs the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/database-tools/" target="_self"> <span> MongoDB Database Tools </span> </a> . See <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-brew-installs-dbtools" target="_self"> <span> Using the MongoDB Database Tools </span> </a> for more information. </p> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> MongoDB Version <a class="headerlink leafygreen-ui-1kepx47" href="#mongodb-version" 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="mongodb-version"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> This tutorial installs MongoDB 8.0 <!-- --> Community <!-- --> Edition. To install a different version of MongoDB <!-- --> Community <!-- --> , use the version drop-down menu in the upper-left corner of this page to select the documentation for that version. </p> </section> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Considerations <a class="headerlink leafygreen-ui-1kepx47" href="#considerations" 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="considerations"> </div> </a> </h2> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Platform Support <a class="headerlink leafygreen-ui-1kepx47" href="#platform-support" 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="platform-support"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> MongoDB 8.0 Community Edition supports macOS 11 or later. </p> <p class="leafygreen-ui-1kp3ins"> For more information, see <a class="leafygreen-ui-tqgtui" href="/docs/manual/administration/production-notes/#std-label-prod-notes-supported-platforms"> Platform Support <!-- --> . </a> </p> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Production Notes <a class="headerlink leafygreen-ui-1kepx47" href="#production-notes" 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="production-notes"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> Before deploying MongoDB in a production environment, consider the <a class="leafygreen-ui-tqgtui" href="/docs/manual/administration/production-notes/"> Production Notes for Self-Managed Deployments </a> document which offers performance considerations and configuration recommendations for production MongoDB deployments. </p> <span class="leafygreen-ui-1qnjd6d" id="std-label-install-with-homebrew"> </span> </section> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Install MongoDB Community Edition <a class="headerlink leafygreen-ui-1kepx47" href="#install-mongodb-community-edition" 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="install-mongodb-community-edition"> </div> </a> </h2> <span class="leafygreen-ui-1qnjd6d" id="std-label-osx-prereq"> </span> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Prerequisites <a class="headerlink leafygreen-ui-1kepx47" href="#prerequisites" 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="prerequisites"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> Ensure your system meets each of the following prerequisites. You only need to perform each prerequisite step once on your system. If you have already performed the prerequisite steps as part of an earlier MongoDB installation using Homebrew, you can skip to the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-install" target="_self"> <span> installation procedure <!-- --> . </span> </a> </p> <section> <h4 class="contains-headerlink leafygreen-ui-1vzlt5f"> Install Xcode Command-Line Tools <a class="headerlink leafygreen-ui-1kepx47" href="#install-xcode-command-line-tools" 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="install-xcode-command-line-tools"> </div> </a> </h4> <p class="leafygreen-ui-1kp3ins"> Homebrew requires the Xcode command-line tools from Apple's Xcode. </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Install the Xcode command-line tools by running the following command in your macOS Terminal: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"xcode-select --install","programmingLanguage":"Bash"} </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 bash leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">xcode-select --install</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> </li> </ul> </section> <section> <h4 class="contains-headerlink leafygreen-ui-1vzlt5f"> Install Homebrew <a class="headerlink leafygreen-ui-1kepx47" href="#install-homebrew" 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="install-homebrew"> </div> </a> </h4> <p class="leafygreen-ui-1kp3ins"> macOS does not include the Homebrew <code class="leafygreen-ui-1l06pbn"> brew </code> package by default. </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Install <code class="leafygreen-ui-1l06pbn"> brew </code> using the official <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://brew.sh/#install" rel="noopener noreferrer"> <span> Homebrew installation instructions </span> <svg alt="" aria-hidden="true" class="leafygreen-ui-1ie5kuq" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M13.823 2.4491C13.8201 2.30008 13.6999 2.17994 13.5509 2.17704L9.5062 2.09836C9.25654 2.09351 9.12821 2.39519 9.30482 2.5718L10.3856 3.65257L7.93433 6.10383C7.87964 6.15852 7.83047 6.21665 7.78683 6.27752L5.99909 8.06525C5.46457 8.59977 5.46457 9.4664 5.99909 10.0009C6.53361 10.5354 7.40023 10.5354 7.93475 10.0009L9.72249 8.21317C9.78336 8.16953 9.84148 8.12037 9.89618 8.06567L12.3474 5.61441L13.4282 6.69518C13.6048 6.87179 13.9065 6.74347 13.9016 6.4938L13.823 2.4491Z" fill="currentColor"> </path> <path d="M7.25 3.12893C7.66421 3.12893 8 3.46472 8 3.87893C8 4.29315 7.66421 4.62893 7.25 4.62893H4C3.72386 4.62893 3.5 4.85279 3.5 5.12893V11.9929C3.5 12.2691 3.72386 12.4929 4 12.4929H10.864C11.1401 12.4929 11.364 12.2691 11.364 11.9929V8.75C11.364 8.33579 11.6998 8 12.114 8C12.5282 8 12.864 8.33579 12.864 8.75V11.9929C12.864 13.0975 11.9686 13.9929 10.864 13.9929H4C2.89543 13.9929 2 13.0975 2 11.9929V5.12893C2 4.02436 2.89543 3.12893 4 3.12893H7.25Z" fill="currentColor"> </path> </svg> </a> . </p> </li> </ul> <span class="leafygreen-ui-1qnjd6d" id="std-label-install"> </span> </section> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Installing MongoDB 8.0 <!-- --> Community <!-- --> Edition <a class="headerlink leafygreen-ui-1kepx47" href="#installing-mongodb-8.0-edition-edition" 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="installing-mongodb-8.0-edition-edition"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> Follow these steps to install MongoDB <!-- --> Community <!-- --> Edition using Homebrew's <code class="leafygreen-ui-1l06pbn"> brew </code> package manager. Be sure that you have followed the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-osx-prereq" target="_self"> <span> installation prerequisites </span> </a> above before proceeding. </p> <ol class="leafygreen-ui-rioki0" type="1"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Tap the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://github.com/mongodb/homebrew-brew" rel="noopener noreferrer"> <span> MongoDB Homebrew Tap </span> <svg alt="" aria-hidden="true" class="leafygreen-ui-1ie5kuq" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M13.823 2.4491C13.8201 2.30008 13.6999 2.17994 13.5509 2.17704L9.5062 2.09836C9.25654 2.09351 9.12821 2.39519 9.30482 2.5718L10.3856 3.65257L7.93433 6.10383C7.87964 6.15852 7.83047 6.21665 7.78683 6.27752L5.99909 8.06525C5.46457 8.59977 5.46457 9.4664 5.99909 10.0009C6.53361 10.5354 7.40023 10.5354 7.93475 10.0009L9.72249 8.21317C9.78336 8.16953 9.84148 8.12037 9.89618 8.06567L12.3474 5.61441L13.4282 6.69518C13.6048 6.87179 13.9065 6.74347 13.9016 6.4938L13.823 2.4491Z" fill="currentColor"> </path> <path d="M7.25 3.12893C7.66421 3.12893 8 3.46472 8 3.87893C8 4.29315 7.66421 4.62893 7.25 4.62893H4C3.72386 4.62893 3.5 4.85279 3.5 5.12893V11.9929C3.5 12.2691 3.72386 12.4929 4 12.4929H10.864C11.1401 12.4929 11.364 12.2691 11.364 11.9929V8.75C11.364 8.33579 11.6998 8 12.114 8C12.5282 8 12.864 8.33579 12.864 8.75V11.9929C12.864 13.0975 11.9686 13.9929 10.864 13.9929H4C2.89543 13.9929 2 13.0975 2 11.9929V5.12893C2 4.02436 2.89543 3.12893 4 3.12893H7.25Z" fill="currentColor"> </path> </svg> </a> to download the official Homebrew formula for MongoDB and the Database Tools, by running the following command in your macOS Terminal: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"brew tap mongodb/brew","programmingLanguage":"Bash"} </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 bash leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">brew tap mongodb<!-- -->/brew</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"> If you have already done this for a previous installation of MongoDB, you can skip this step. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> To update Homebrew and all existing formulae: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"brew update","programmingLanguage":"Bash"} </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 bash leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">brew update</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> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> To install MongoDB, run the following command in your macOS Terminal application: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"brew install [email protected]","programmingLanguage":"Bash"} </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 bash leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">brew install [email protected]</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> </li> </ol> <div class="leafygreen-ui-13vw3ie" role="note"> <h2 class="leafygreen-ui-1fn4p2b"> Tip </h2> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> Alternatively, you can specify a previous version of MongoDB if desired. You can also maintain multiple versions of MongoDB side by side in this manner. </p> </div> </div> <div class="leafygreen-ui-13vw3ie" role="note"> <h2 class="leafygreen-ui-1fn4p2b"> Tip </h2> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> If you have previously installed an older version of the formula, you may encounter a ChecksumMismatchError. To resolve, see <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-troubleshooting-checksumerror" target="_self"> <span> Troubleshooting ChecksumMismatchError <!-- --> . </span> </a> </p> </div> </div> <p class="leafygreen-ui-1kp3ins"> The installation includes the following binaries: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> The <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> server </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> The <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongos/#mongodb-binary-bin.mongos"> <code class="leafygreen-ui-1l06pbn"> mongos </code> </a> sharded cluster query router </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> The MongoDB Shell, <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/mongodb-shell/#mongodb-binary-bin.mongosh" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongosh </code> </span> </a> </p> </li> </ul> <p class="leafygreen-ui-1kp3ins"> In addition, the installation creates the following files and directories at the location specified below, depending on your Apple hardware: </p> <div class="leafygreen-ui-skkc39" tabindex="0"> <table class="leafygreen-ui-hr8lsv"> <colgroup> <col style="width:20%"/> <col style="width:30%"/> <col style="width:30%"/> </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> </div> </div> </th> <th class="leafygreen-ui-13uteka" role="columnheader" scope="col"> <div class="leafygreen-ui-ui0te9"> <div> Intel Processor </div> </div> </th> <th class="leafygreen-ui-13uteka" role="columnheader" scope="col"> <div class="leafygreen-ui-ui0te9"> <div> Apple Silicon Processor </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/configuration-options/"> configuration file </a> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> /usr/local/etc/mongod.conf </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> /opt/homebrew/etc/mongod.conf </code> </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/configuration-options/#mongodb-setting-systemLog.path"> <code class="leafygreen-ui-1l06pbn"> log directory </code> </a> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> /usr/local/var/log/mongodb </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> /opt/homebrew/var/log/mongodb </code> </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/configuration-options/#mongodb-setting-storage.dbPath"> <code class="leafygreen-ui-1l06pbn"> data directory </code> </a> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> /usr/local/var/mongodb </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> /opt/homebrew/var/mongodb </code> </div> </div> </td> </tr> </tbody> </table> </div> <p class="leafygreen-ui-1kp3ins"> See <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://support.apple.com/en-us/HT211814" rel="noopener noreferrer"> <span> Apple's documentation </span> <svg alt="" aria-hidden="true" class="leafygreen-ui-1ie5kuq" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M13.823 2.4491C13.8201 2.30008 13.6999 2.17994 13.5509 2.17704L9.5062 2.09836C9.25654 2.09351 9.12821 2.39519 9.30482 2.5718L10.3856 3.65257L7.93433 6.10383C7.87964 6.15852 7.83047 6.21665 7.78683 6.27752L5.99909 8.06525C5.46457 8.59977 5.46457 9.4664 5.99909 10.0009C6.53361 10.5354 7.40023 10.5354 7.93475 10.0009L9.72249 8.21317C9.78336 8.16953 9.84148 8.12037 9.89618 8.06567L12.3474 5.61441L13.4282 6.69518C13.6048 6.87179 13.9065 6.74347 13.9016 6.4938L13.823 2.4491Z" fill="currentColor"> </path> <path d="M7.25 3.12893C7.66421 3.12893 8 3.46472 8 3.87893C8 4.29315 7.66421 4.62893 7.25 4.62893H4C3.72386 4.62893 3.5 4.85279 3.5 5.12893V11.9929C3.5 12.2691 3.72386 12.4929 4 12.4929H10.864C11.1401 12.4929 11.364 12.2691 11.364 11.9929V8.75C11.364 8.33579 11.6998 8 12.114 8C12.5282 8 12.864 8.33579 12.864 8.75V11.9929C12.864 13.0975 11.9686 13.9929 10.864 13.9929H4C2.89543 13.9929 2 13.0975 2 11.9929V5.12893C2 4.02436 2.89543 3.12893 4 3.12893H7.25Z" fill="currentColor"> </path> </svg> </a> for the current list of Apple hardware using the Apple Silicon processor. You can also run the following command to check where <code class="leafygreen-ui-1l06pbn"> brew </code> has installed these files and directories: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"brew --prefix","programmingLanguage":"Bash"} </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 bash leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">brew --prefix</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"> Starting with MongoDB 4.4.1, the installation also includes the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/database-tools/" target="_self"> <span> MongoDB Database Tools </span> </a> . See <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-brew-installs-dbtools" target="_self"> <span> Using the MongoDB Database Tools </span> </a> for more information. </p> <span class="leafygreen-ui-1qnjd6d" id="std-label-run-with-homebrew"> </span> </section> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Run MongoDB Community Edition <a class="headerlink leafygreen-ui-1kepx47" href="#run-mongodb-community-edition" 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="run-mongodb-community-edition"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> Follow these steps to run MongoDB <!-- --> Community <!-- --> Edition. These instructions assume that you are using the default settings. </p> <p class="leafygreen-ui-1kp3ins"> You can run MongoDB as a macOS service using <code class="leafygreen-ui-1l06pbn"> brew </code> , or you can run MongoDB manually as a background process. It is recommended to run MongoDB as a macOS service, as doing so sets the correct system <code class="leafygreen-ui-1l06pbn"> ulimit </code> values automatically (see <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/ulimit/#std-label-ulimit-settings"> ulimit settings </a> for more information). </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> To run MongoDB (i.e. the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> process) <strong> as a macOS service </strong> , run: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"brew services start [email protected]","programmingLanguage":"Bash"} </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 bash leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">brew services start [email protected]</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"> To stop a <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> running as a macOS service, use the following command as needed: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"brew services stop [email protected]","programmingLanguage":"Bash"} </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 bash leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">brew services stop [email protected]</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> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> To run <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> <strong> manually as a background process </strong> using a config file: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> If your deployment does not use <a class="leafygreen-ui-tqgtui" href="/docs/manual/tutorial/configure-ssl/#std-label-configure-mongod-mongos-for-tls-ssl"> TLS connections </a> , use the <code class="leafygreen-ui-1l06pbn"> --fork </code> option: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> For macOS running on Intel processors, run: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"mongod --config /usr/local/etc/mongod.conf --fork","programmingLanguage":"Bash"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-1q4bxgx" tabindex="0"><code class="lg-highlight-hljs-light bash leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">mongod --config <!-- -->/usr/local/etc/mongod.conf<!-- --> --fork</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> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> For macOS running on <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://support.apple.com/en-us/HT211814" rel="noopener noreferrer"> <span> Apple Silicon processors </span> <svg alt="" aria-hidden="true" class="leafygreen-ui-1ie5kuq" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M13.823 2.4491C13.8201 2.30008 13.6999 2.17994 13.5509 2.17704L9.5062 2.09836C9.25654 2.09351 9.12821 2.39519 9.30482 2.5718L10.3856 3.65257L7.93433 6.10383C7.87964 6.15852 7.83047 6.21665 7.78683 6.27752L5.99909 8.06525C5.46457 8.59977 5.46457 9.4664 5.99909 10.0009C6.53361 10.5354 7.40023 10.5354 7.93475 10.0009L9.72249 8.21317C9.78336 8.16953 9.84148 8.12037 9.89618 8.06567L12.3474 5.61441L13.4282 6.69518C13.6048 6.87179 13.9065 6.74347 13.9016 6.4938L13.823 2.4491Z" fill="currentColor"> </path> <path d="M7.25 3.12893C7.66421 3.12893 8 3.46472 8 3.87893C8 4.29315 7.66421 4.62893 7.25 4.62893H4C3.72386 4.62893 3.5 4.85279 3.5 5.12893V11.9929C3.5 12.2691 3.72386 12.4929 4 12.4929H10.864C11.1401 12.4929 11.364 12.2691 11.364 11.9929V8.75C11.364 8.33579 11.6998 8 12.114 8C12.5282 8 12.864 8.33579 12.864 8.75V11.9929C12.864 13.0975 11.9686 13.9929 10.864 13.9929H4C2.89543 13.9929 2 13.0975 2 11.9929V5.12893C2 4.02436 2.89543 3.12893 4 3.12893H7.25Z" fill="currentColor"> </path> </svg> </a> , run: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"mongod --config /opt/homebrew/etc/mongod.conf --fork","programmingLanguage":"Bash"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-1q4bxgx" tabindex="0"><code class="lg-highlight-hljs-light bash leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">mongod --config <!-- -->/opt/homebrew/etc/mongod.conf<!-- --> --fork</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> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> If your deployment uses <a class="leafygreen-ui-tqgtui" href="/docs/manual/tutorial/configure-ssl/#std-label-configure-mongod-mongos-for-tls-ssl"> TLS connections </a> , use <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.gnu.org/software/screen/" rel="noopener noreferrer"> <span> GNU Screen </span> <svg alt="" aria-hidden="true" class="leafygreen-ui-1ie5kuq" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M13.823 2.4491C13.8201 2.30008 13.6999 2.17994 13.5509 2.17704L9.5062 2.09836C9.25654 2.09351 9.12821 2.39519 9.30482 2.5718L10.3856 3.65257L7.93433 6.10383C7.87964 6.15852 7.83047 6.21665 7.78683 6.27752L5.99909 8.06525C5.46457 8.59977 5.46457 9.4664 5.99909 10.0009C6.53361 10.5354 7.40023 10.5354 7.93475 10.0009L9.72249 8.21317C9.78336 8.16953 9.84148 8.12037 9.89618 8.06567L12.3474 5.61441L13.4282 6.69518C13.6048 6.87179 13.9065 6.74347 13.9016 6.4938L13.823 2.4491Z" fill="currentColor"> </path> <path d="M7.25 3.12893C7.66421 3.12893 8 3.46472 8 3.87893C8 4.29315 7.66421 4.62893 7.25 4.62893H4C3.72386 4.62893 3.5 4.85279 3.5 5.12893V11.9929C3.5 12.2691 3.72386 12.4929 4 12.4929H10.864C11.1401 12.4929 11.364 12.2691 11.364 11.9929V8.75C11.364 8.33579 11.6998 8 12.114 8C12.5282 8 12.864 8.33579 12.864 8.75V11.9929C12.864 13.0975 11.9686 13.9929 10.864 13.9929H4C2.89543 13.9929 2 13.0975 2 11.9929V5.12893C2 4.02436 2.89543 3.12893 4 3.12893H7.25Z" fill="currentColor"> </path> </svg> </a> . </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> For macOS running on Intel processors: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"HowTo","steps":[{"@type":"HowToStep","text":"Start your screen."},{"@type":"HowToStep","text":"Start mongod."},{"@type":"HowToStep","text":"Detach from your screen by typing Ctrl+a, then\nclicking d.","name":"Detach from screen."},{"@type":"HowToStep","text":"View all active screens."}],"name":"Run MongoDB Community Edition","image":"https://webimages.mongodb.com/_com_assets/cms/kuyj2focmkbxv7gh3-stacked_default_slate_blue.svg?auto=format%252Ccompress"} </script> <div class="css-4nyere eccljxs0"> <div class="css-1nuklj8 e1ckbxcu1"> <div class="css-18fui5z e1ckbxcu0"> <div class="css-19lsqsq e1ckbxcu2"> 1 </div> </div> <div class="css-1ed38mk"> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Start your screen. <a class="headerlink leafygreen-ui-1kepx47" href="#start-your-screen." 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="start-your-screen."> </div> </a> </h3> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"screen -S &lt;name-of-screen&gt;","programmingLanguage":"Bash"} </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 bash leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">screen -S &lt;name-of-screen&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> </section> </div> </div> <div class="css-1nuklj8 e1ckbxcu1"> <div class="css-18fui5z e1ckbxcu0"> <div class="css-19lsqsq e1ckbxcu2"> 2 </div> </div> <div class="css-1ed38mk"> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Start <code class="leafygreen-ui-1l06pbn"> mongod </code> . <a class="headerlink leafygreen-ui-1kepx47" href="#start-mongod." 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="start-mongod."> </div> </a> </h3> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"mongod --config /usr/local/etc/mongod.conf","programmingLanguage":"Bash"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-1q4bxgx" tabindex="0"><code class="lg-highlight-hljs-light bash leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">mongod --config <!-- -->/usr/local/etc/mongod.conf</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> </section> </div> </div> <div class="css-1nuklj8 e1ckbxcu1"> <div class="css-18fui5z e1ckbxcu0"> <div class="css-19lsqsq e1ckbxcu2"> 3 </div> </div> <div class="css-1ed38mk"> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Detach from screen. <a class="headerlink leafygreen-ui-1kepx47" href="#detach-from-screen." 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="detach-from-screen."> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> Detach from your screen by typing <code class="leafygreen-ui-1l06pbn"> Ctrl+a </code> , then clicking <code class="leafygreen-ui-1l06pbn"> d </code> . </p> </section> </div> </div> <div class="css-1nuklj8 e1ckbxcu1"> <div class="css-18fui5z e1ckbxcu0"> <div class="css-19lsqsq e1ckbxcu2"> 4 </div> </div> <div class="css-1ed38mk"> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> View all active screens. <a class="headerlink leafygreen-ui-1kepx47" href="#view-all-active-screens." 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="view-all-active-screens."> </div> </a> </h3> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"screen -ls","programmingLanguage":"Bash"} </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 bash leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">screen -<span class="lg-highlight-built_in">ls</span></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> </section> </div> </div> </div> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> For macOS running on <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://support.apple.com/en-us/HT211814" rel="noopener noreferrer"> <span> Apple Silicon processors <!-- --> : </span> <svg alt="" aria-hidden="true" class="leafygreen-ui-1ie5kuq" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M13.823 2.4491C13.8201 2.30008 13.6999 2.17994 13.5509 2.17704L9.5062 2.09836C9.25654 2.09351 9.12821 2.39519 9.30482 2.5718L10.3856 3.65257L7.93433 6.10383C7.87964 6.15852 7.83047 6.21665 7.78683 6.27752L5.99909 8.06525C5.46457 8.59977 5.46457 9.4664 5.99909 10.0009C6.53361 10.5354 7.40023 10.5354 7.93475 10.0009L9.72249 8.21317C9.78336 8.16953 9.84148 8.12037 9.89618 8.06567L12.3474 5.61441L13.4282 6.69518C13.6048 6.87179 13.9065 6.74347 13.9016 6.4938L13.823 2.4491Z" fill="currentColor"> </path> <path d="M7.25 3.12893C7.66421 3.12893 8 3.46472 8 3.87893C8 4.29315 7.66421 4.62893 7.25 4.62893H4C3.72386 4.62893 3.5 4.85279 3.5 5.12893V11.9929C3.5 12.2691 3.72386 12.4929 4 12.4929H10.864C11.1401 12.4929 11.364 12.2691 11.364 11.9929V8.75C11.364 8.33579 11.6998 8 12.114 8C12.5282 8 12.864 8.33579 12.864 8.75V11.9929C12.864 13.0975 11.9686 13.9929 10.864 13.9929H4C2.89543 13.9929 2 13.0975 2 11.9929V5.12893C2 4.02436 2.89543 3.12893 4 3.12893H7.25Z" fill="currentColor"> </path> </svg> </a> </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"HowTo","steps":[{"@type":"HowToStep","text":"Start your screen."},{"@type":"HowToStep","text":"Start mongod."},{"@type":"HowToStep","text":"Detach from your screen by typing Ctrl+a, then\nclicking d.","name":"Detach from screen."},{"@type":"HowToStep","text":"View all active screens."}],"name":"Run MongoDB Community Edition","image":"https://webimages.mongodb.com/_com_assets/cms/kuyj2focmkbxv7gh3-stacked_default_slate_blue.svg?auto=format%252Ccompress"} </script> <div class="css-4nyere eccljxs0"> <div class="css-1nuklj8 e1ckbxcu1"> <div class="css-18fui5z e1ckbxcu0"> <div class="css-19lsqsq e1ckbxcu2"> 1 </div> </div> <div class="css-1ed38mk"> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Start your screen. <a class="headerlink leafygreen-ui-1kepx47" href="#start-your-screen.-1" 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="start-your-screen.-1"> </div> </a> </h3> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"screen -S &lt;name-of-screen&gt;","programmingLanguage":"Bash"} </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 bash leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">screen -S &lt;name-of-screen&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> </section> </div> </div> <div class="css-1nuklj8 e1ckbxcu1"> <div class="css-18fui5z e1ckbxcu0"> <div class="css-19lsqsq e1ckbxcu2"> 2 </div> </div> <div class="css-1ed38mk"> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Start <code class="leafygreen-ui-1l06pbn"> mongod </code> . <a class="headerlink leafygreen-ui-1kepx47" href="#start-mongod.-1" 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="start-mongod.-1"> </div> </a> </h3> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"mongod --config /opt/homebrew/etc/mongod.conf","programmingLanguage":"Bash"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-1q4bxgx" tabindex="0"><code class="lg-highlight-hljs-light bash leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">mongod --config <!-- -->/opt/homebrew/etc/mongod.conf</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> </section> </div> </div> <div class="css-1nuklj8 e1ckbxcu1"> <div class="css-18fui5z e1ckbxcu0"> <div class="css-19lsqsq e1ckbxcu2"> 3 </div> </div> <div class="css-1ed38mk"> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Detach from screen. <a class="headerlink leafygreen-ui-1kepx47" href="#detach-from-screen.-1" 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="detach-from-screen.-1"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> Detach from your screen by typing <code class="leafygreen-ui-1l06pbn"> Ctrl+a </code> , then clicking <code class="leafygreen-ui-1l06pbn"> d </code> . </p> </section> </div> </div> <div class="css-1nuklj8 e1ckbxcu1"> <div class="css-18fui5z e1ckbxcu0"> <div class="css-19lsqsq e1ckbxcu2"> 4 </div> </div> <div class="css-1ed38mk"> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> View all active screens. <a class="headerlink leafygreen-ui-1kepx47" href="#view-all-active-screens.-1" 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="view-all-active-screens.-1"> </div> </a> </h3> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"screen -ls","programmingLanguage":"Bash"} </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 bash leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">screen -<span class="lg-highlight-built_in">ls</span></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> </section> </div> </div> </div> </li> </ul> </li> </ul> </li> </ul> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> To run <code class="leafygreen-ui-1l06pbn"> mongod </code> <strong> manually as a background process </strong> specifying <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#std-option-mongod.--dbpath"> <code class="leafygreen-ui-1l06pbn"> --dbpath </code> </a> and <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#std-option-mongod.--logpath"> <code class="leafygreen-ui-1l06pbn"> --logpath </code> </a> on the command line, run: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"mongod --dbpath /path/to/dbdir --logpath /path/to/mongodb.log --fork","programmingLanguage":"Bash"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-1q4bxgx" tabindex="0"><code class="lg-highlight-hljs-light bash leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">mongod --dbpath <!-- -->/path/to/dbdir<!-- --> --logpath <!-- -->/path/to/mongodb.log<!-- --> --fork</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"> To stop a <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> running as a background process, connect to the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> using <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/mongodb-shell/" target="_self"> <span> mongosh </span> </a> , and issue the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/command/shutdown/#mongodb-dbcommand-dbcmd.shutdown"> <code class="leafygreen-ui-1l06pbn"> shutdown </code> </a> command as needed. </p> </li> </ul> <p class="leafygreen-ui-1kp3ins"> Both methods use the <code class="file docutils literal"> <span class="pre"> mongod.conf </span> </code> file created during the install. You can add your own MongoDB <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/configuration-options/"> configuration options </a> to this file as well. </p> <div class="leafygreen-ui-15mdk4" role="note"> <h2 class="leafygreen-ui-6n7b7d"> Note </h2> <h3 class="leafygreen-ui-144d5kf"> <strong> macOS Prevents mongod From Opening </strong> </h3> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> macOS may prevent <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> from running after installation. If you receive a security error when starting <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> indicating that the developer could not be identified or verified, do the following to grant <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> access to run: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Open <em> System Preferences </em> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Select the <em> Security and Privacy </em> pane. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Under the <em> General </em> tab, click the button to the right of the message about <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> , labelled either <span class="guilabel css-h15tq0"> Open Anyway </span> or <span class="guilabel css-h15tq0"> Allow Anyway </span> depending on your version of macOS. </p> </li> </ul> </div> </div> <p class="leafygreen-ui-1kp3ins"> To verify that MongoDB is running, perform one of the following: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> If you started MongoDB <strong> as a macOS service </strong> : </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"brew services list","programmingLanguage":"Bash"} </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 bash leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">brew services list</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"> You should see the service <code class="leafygreen-ui-1l06pbn"> mongodb-community </code> listed as <code class="leafygreen-ui-1l06pbn"> started </code> . </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> If you started MongoDB <strong> manually as a background process </strong> : </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"ps aux | grep -v grep | grep mongod","programmingLanguage":"Bash"} </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 bash leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">ps aux | grep -v grep | grep mongod</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"> You should see your <code class="leafygreen-ui-1l06pbn"> mongod </code> process in the output. </p> </li> </ul> <p class="leafygreen-ui-1kp3ins"> You can also view the log file to see the current status of your <code class="leafygreen-ui-1l06pbn"> mongod </code> process: <code class="leafygreen-ui-1l06pbn"> /usr/local/var/log/mongodb/mongo.log </code> . </p> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Connect and Use MongoDB <a class="headerlink leafygreen-ui-1kepx47" href="#connect-and-use-mongodb" 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="connect-and-use-mongodb"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> To begin using MongoDB, connect <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/mongodb-shell/#mongodb-binary-bin.mongosh" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongosh </code> </span> </a> to the running instance. From a new terminal, issue the following: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"mongosh","programmingLanguage":"Bash"} </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 bash leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">mongosh</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"> For information on CRUD (Create,Read,Update,Delete) operations, see: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/tutorial/insert-documents/"> Insert Documents </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/tutorial/query-documents/"> Query Documents </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/tutorial/update-documents/"> Update Documents </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/tutorial/remove-documents/"> Delete Documents </a> </p> </li> </ul> <span class="leafygreen-ui-1qnjd6d" id="std-label-brew-installs-dbtools"> </span> </section> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Using the MongoDB Database Tools <a class="headerlink leafygreen-ui-1kepx47" href="#using-the-mongodb-database-tools" 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="using-the-mongodb-database-tools"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> Starting in MongoDB 4.4.1, installing MongoDB through <code class="leafygreen-ui-1l06pbn"> brew </code> also installs the MongoDB Database Tools. </p> <p class="leafygreen-ui-1kp3ins"> The <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/database-tools/" target="_self"> <span> MongoDB Database Tools </span> </a> are a collection of command-line utilities for working with a MongoDB deployment, including data backup and import/export tools like <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/database-tools/mongoimport/#mongodb-binary-bin.mongoimport" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongoimport </code> </span> </a> and <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/database-tools/mongodump/#mongodb-binary-bin.mongodump" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongodump </code> </span> </a> as well as monitoring tools like <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/database-tools/mongotop/#mongodb-binary-bin.mongotop" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongotop </code> . </span> </a> </p> <p class="leafygreen-ui-1kp3ins"> Once you have installed the MongoDB Server in the steps above, the Database Tools are available directly from the command line in your macOS Terminal application. For example you could run <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/database-tools/mongotop/#mongodb-binary-bin.mongotop" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongotop </code> </span> </a> against your running MongoDB instance by invoking it in your macOS Terminal like so: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"mongotop","programmingLanguage":"Bash"} </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 bash leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">mongotop</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"> It should start up, connect to your running <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> , and start reporting usage statistics. </p> <p class="leafygreen-ui-1kp3ins"> See the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/database-tools/" target="_self"> <span> MongoDB Database Tools Documentation </span> </a> for usage information for each of the Database Tools. </p> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Additional Information <a class="headerlink leafygreen-ui-1kepx47" href="#additional-information" 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="additional-information"> </div> </a> </h2> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Localhost Binding by Default <a class="headerlink leafygreen-ui-1kepx47" href="#localhost-binding-by-default" 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="localhost-binding-by-default"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> By default, MongoDB launches with <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/configuration-options/#mongodb-setting-net.bindIp"> <code class="leafygreen-ui-1l06pbn"> bindIp </code> </a> set to <code class="leafygreen-ui-1l06pbn"> 127.0.0.1 </code> , which binds to the localhost network interface. This means that the <code class="leafygreen-ui-1l06pbn"> mongod </code> can only accept connections from clients that are running on the same machine. Remote clients will not be able to connect to the <code class="leafygreen-ui-1l06pbn"> mongod </code> , and the <code class="leafygreen-ui-1l06pbn"> mongod </code> will not be able to initialize a <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-replica-set"> replica set </a> unless this value is set to a valid network interface. </p> <p class="leafygreen-ui-1kp3ins"> This value can be configured either: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> in the MongoDB configuration file with <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/configuration-options/#mongodb-setting-net.bindIp"> <code class="leafygreen-ui-1l06pbn"> bindIp </code> </a> , or </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> via the command-line argument <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#std-option-mongod.--bind_ip"> <code class="leafygreen-ui-1l06pbn"> --bind_ip </code> </a> </p> </li> </ul> <div class="leafygreen-ui-1sjx7ru" role="note"> <h2 class="leafygreen-ui-29m78u"> Warning </h2> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> Before you bind your instance to a publicly-accessible IP address, you must secure your cluster from unauthorized access. For a complete list of security recommendations, see <a class="leafygreen-ui-tqgtui" href="/docs/manual/administration/security-checklist/#std-label-security-checklist"> Security Checklist for Self-Managed Deployments </a> . At minimum, consider <a class="leafygreen-ui-tqgtui" href="/docs/manual/administration/security-checklist/#std-label-checklist-auth"> enabling authentication </a> and <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/security-hardening/#std-label-network-config-hardening"> hardening network infrastructure <!-- --> . </a> </p> </div> </div> <p class="leafygreen-ui-1kp3ins"> For more information on configuring <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/configuration-options/#mongodb-setting-net.bindIp"> <code class="leafygreen-ui-1l06pbn"> bindIp </code> </a> , see <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/security-mongodb-configuration/"> IP Binding in Self-Managed Deployments <!-- --> . </a> </p> <span class="leafygreen-ui-1qnjd6d" id="std-label-troubleshooting-checksumerror"> </span> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Troubleshooting ChecksumMismatchError <a class="headerlink leafygreen-ui-1kepx47" href="#troubleshooting-checksummismatcherror" 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="troubleshooting-checksummismatcherror"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> If you have previously installed an older version of the formula, you may encounter a <code class="leafygreen-ui-1l06pbn"> ChecksumMismatchError </code> resembling the following: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"Error: An exception occurred within a child process:\n\n ChecksumMismatchError: SHA256 mismatch\n\nExpected: c7214ee7bda3cf9566e8776a8978706d9827c1b09017e17b66a5a4e0c0731e1f\n\n Actual: 6aa2e0c348e8abeec7931dced1f85d4bb161ef209c6af317fe530ea11bbac8f0\n\n Archive: /Users/kay/Library/Caches/Homebrew/downloads/a6696157a9852f392ec6323b4bb697b86312f0c345d390111bd51bb1cbd7e219--mongodb-macos-x86_64-4.2.0.tgz\n\nTo retry an incomplete download, remove the file above.","programmingLanguage":"Bash"} </script> <div class="css-1lju8ps"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-tyg50d"> <pre class="leafygreen-ui-1453az5" tabindex="0"><code class="lg-highlight-hljs-light bash leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">Error: An exception occurred within a child process:</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><div class="leafygreen-ui-ihxujy"></div></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> ChecksumMismatchError: SHA256 mismatch</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><div class="leafygreen-ui-ihxujy"></div></td></tr><tr class=""><td class="leafygreen-ui-7razhx">Expected: c7214ee7bda3cf9566e8776a8978706d9827c1b09017e17b66a5a4e0c0731e1f</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><div class="leafygreen-ui-ihxujy"></div></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> Actual: 6aa2e0c348e8abeec7931dced1f85d4bb161ef209c6af317fe530ea11bbac8f0</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><div class="leafygreen-ui-ihxujy"></div></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> Archive: /Users<!-- -->/kay<!-- -->/Library/Caches/Homebrew<!-- -->/downloads/a<!-- -->6696157a9852f392ec6323b4bb697b86312f0c345d390111bd51bb1cbd7e219--mongodb-macos-x86_64-4.2.0.tgz</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><div class="leafygreen-ui-ihxujy"></div></td></tr><tr class=""><td class="leafygreen-ui-7razhx">To retry an incomplete download, remove the file above.</td></tr></tbody></table></code></pre> </div> </div> </div> <p class="leafygreen-ui-1kp3ins"> To fix: </p> <ol class="leafygreen-ui-rioki0" type="1"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Remove the downloaded <code class="file docutils literal"> <span class="pre"> .tgz </span> </code> archive. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Retap the formula. </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"brew untap mongodb/brew &amp;&amp; brew tap mongodb/brew","programmingLanguage":"Bash"} </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 bash leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">brew untap mongodb<!-- -->/brew<!-- --> &amp;&amp; brew tap mongodb<!-- -->/brew</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> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Retry the install. </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"brew install [email protected]","programmingLanguage":"Bash"} </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 bash leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">brew install [email protected]</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> </li> </ol> </section> </section> </section>
https://www.mongodb.com/docs/manual/reference/method/cursor.maxAwaitTimeMS/
<section> <h1 class="contains-headerlink leafygreen-ui-41fr9s" weight="medium"> cursor.maxAwaitTimeMS() <a class="headerlink leafygreen-ui-1kepx47" href="#cursor.maxawaittimems--" 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="cursor.maxawaittimems--"> </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="#definition" target="_self"> <span> Definition </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#example" target="_self"> <span> Example </span> </a> </li> </ul> </div> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Definition <a class="headerlink leafygreen-ui-1kepx47" href="#definition" 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="definition"> </div> </a> </h2> <dl class="method"> <dt> <code class="leafygreen-ui-1l06pbn"> cursor.maxAwaitTimeMS(&lt;time limit&gt;) </code> <a class="headerlink leafygreen-ui-1kepx47" href="#mongodb-method-cursor.maxAwaitTimeMS" title="Permalink to this definition"> <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="mongodb-method-cursor.maxAwaitTimeMS"> </div> </a> </dt> <dd> <div class="leafygreen-ui-85da11" role="note"> <h2 class="leafygreen-ui-1ac4g5h"> Important </h2> <h3 class="leafygreen-ui-144d5kf"> <strong> mongosh Method </strong> </h3> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> This page documents a <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/mongodb-shell/#mongodb-binary-bin.mongosh" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongosh </code> </span> </a> method. This is <em> not </em> the documentation for a language-specific driver, such as Node.js. </p> <p class="leafygreen-ui-1kp3ins"> For MongoDB API drivers, refer to the language-specific <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/drivers/" target="_self"> <span> MongoDB driver documentation <!-- --> . </span> </a> </p> </div> </div> <p class="leafygreen-ui-1kp3ins"> Specifies the maximum time for the server to wait for new documents that match a <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/tailable-cursors/#std-label-tailable-cursors-landing-page"> tailable cursor </a> query on a <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/capped-collections/#std-label-manual-capped-collection"> capped collection </a> . For more information on iterating a cursor returned by a query, see: <a class="leafygreen-ui-tqgtui" href="/docs/manual/tutorial/iterate-a-cursor/#std-label-read-operations-cursors"> Iterate a Cursor in <code class="leafygreen-ui-1l06pbn"> mongosh </code> . </a> </p> <p class="leafygreen-ui-1kp3ins"> The <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-method-cursor.maxAwaitTimeMS" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> maxAwaitTimeMS() </code> </span> </a> method has the following prototype form: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.collection.find(\n { &lt;query&gt; },\n { &lt;projection&gt; }\n).tailable( { awaitData: true } ).maxAwaitTimeMS( &lt;milliseconds&gt; )","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><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">find</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ &lt;<!-- -->query<!-- -->&gt; <!-- -->}<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ &lt;<!-- -->projection<!-- -->&gt; <!-- -->}</td></tr><tr class=""><td class="leafygreen-ui-7razhx">).<span class="lg-highlight-title lg-highlight-function">tailable</span>( <!-- -->{ <span class="lg-highlight-attr">awaitData</span>: <span class="lg-highlight-literal">true</span> } ).<span class="lg-highlight-title lg-highlight-function">maxAwaitTimeMS</span>( &lt;<!-- -->milliseconds<!-- -->&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 <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-method-cursor.maxAwaitTimeMS" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> maxAwaitTimeMS() </code> </span> </a> method has the following parameter: </p> <div class="leafygreen-ui-skkc39" tabindex="0"> <table class="leafygreen-ui-hr8lsv"> <colgroup> <col style="width:20%"/> <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> Parameter </div> </div> </th> <th class="leafygreen-ui-13uteka" role="columnheader" scope="col"> <div class="leafygreen-ui-ui0te9"> <div> Type </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> <code class="leafygreen-ui-1l06pbn"> milliseconds </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> integer </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Specifies a maximum wait time for new documents. </div> </div> </td> </tr> </tbody> </table> </div> </dd> </dl> <div class="leafygreen-ui-85da11" role="note"> <h2 class="leafygreen-ui-1ac4g5h"> Important </h2> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> This method, <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-method-cursor.maxAwaitTimeMS" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> maxAwaitTimeMS() </code> </span> </a> , sets a limit on how long a <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/tailable-cursors/#std-label-tailable-cursors-landing-page"> tailable cursor </a> waits for the next response. <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/cursor.maxTimeMS/#mongodb-method-cursor.maxTimeMS"> <code class="leafygreen-ui-1l06pbn"> maxTimeMS() </code> </a> sets a limit on total processing time. </p> </div> </div> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Example <a class="headerlink leafygreen-ui-1kepx47" href="#example" 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="example"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> Query the <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/capped-collections/#std-label-manual-capped-collection"> capped </a> <code class="leafygreen-ui-1l06pbn"> sales </code> collection to find agent Mary Kay's weekly sales totals: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.sales.find(\n { agent: \"Mary Kay\" },\n { _id: 0, agent: 1, weeklyTotal: 1 }\n).tailable( { awaitData: true } ).maxAwaitTimeMS( 1000 )","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">sales</span>.<span class="lg-highlight-title lg-highlight-function">find</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">agent</span>: <span class="lg-highlight-string">"Mary Kay"</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">0</span>, <span class="lg-highlight-attr">agent</span>: <span class="lg-highlight-number">1</span>, <span class="lg-highlight-attr">weeklyTotal</span>: <span class="lg-highlight-number">1</span> }</td></tr><tr class="leafygreen-ui-1wr1lm6"><td class="leafygreen-ui-7razhx">).<span class="lg-highlight-title lg-highlight-function">tailable</span>( <!-- -->{ <span class="lg-highlight-attr">awaitData</span>: <span class="lg-highlight-literal">true</span> } ).<span class="lg-highlight-title lg-highlight-function">maxAwaitTimeMS</span>( <span class="lg-highlight-number">1000</span> )</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 highlighted line creates a <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/tailable-cursors/#std-label-tailable-cursors-landing-page"> tailable cursor </a> on the <code class="leafygreen-ui-1l06pbn"> sales </code> collection. The <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-method-cursor.maxAwaitTimeMS" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> maxAwaitTimeMS() </code> </span> </a> sets a one second maximum wait time for the next cursor update. </p> </section> </section>
https://www.mongodb.com/docs/manual/reference/command/setQuerySettings/
<section> <h1 class="contains-headerlink leafygreen-ui-41fr9s" weight="medium"> setQuerySettings <a class="headerlink leafygreen-ui-1kepx47" href="#setquerysettings" 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="setquerysettings"> </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="#definition" target="_self"> <span> Definition </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#syntax" target="_self"> <span> Syntax </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#command-fields" target="_self"> <span> Command Fields </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#examples" target="_self"> <span> Examples </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#learn-more" target="_self"> <span> Learn More </span> </a> </li> </ul> </div> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Definition <a class="headerlink leafygreen-ui-1kepx47" href="#definition" 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="definition"> </div> </a> </h2> <dl class="dbcommand"> <dt> <code class="leafygreen-ui-1l06pbn"> setQuerySettings </code> <a class="headerlink leafygreen-ui-1kepx47" href="#mongodb-dbcommand-dbcmd.setQuerySettings" title="Permalink to this definition"> <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="mongodb-dbcommand-dbcmd.setQuerySettings"> </div> </a> </dt> <dd> </dd> </dl> <div> <p> <em> New <!-- --> in version <!-- --> 8.0 </em> . </p> </div> <p class="leafygreen-ui-1kp3ins"> You can use query settings to add index hints, define <a class="leafygreen-ui-tqgtui" href="/docs/manual/tutorial/operation-rejection-filters/#std-label-operation-rejection-filters"> operation rejection filters </a> , and set other fields. The settings apply to the <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/query-shapes/#std-label-query-shapes"> query shape </a> on the entire cluster. The cluster retains the settings after shutdown. </p> <p class="leafygreen-ui-1kp3ins"> For example, query settings allow you to use an index for all executions of a query shape in a cluster. </p> <p class="leafygreen-ui-1kp3ins"> The <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-query-optimizer"> query optimizer </a> uses the query settings as an additional input during query planning, which affects the plan selected to run the query. </p> <p class="leafygreen-ui-1kp3ins"> <code class="leafygreen-ui-1l06pbn"> setQuerySettings </code> defines query settings used by the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/command/find/#mongodb-dbcommand-dbcmd.find"> <code class="leafygreen-ui-1l06pbn"> find </code> </a> , <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/command/distinct/#mongodb-dbcommand-dbcmd.distinct"> <code class="leafygreen-ui-1l06pbn"> distinct </code> </a> , and <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/command/aggregate/#mongodb-dbcommand-dbcmd.aggregate"> <code class="leafygreen-ui-1l06pbn"> aggregate </code> </a> commands. </p> <p class="leafygreen-ui-1kp3ins"> Starting in MongoDB 8.0, use query settings instead of <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/query-plans/#std-label-index-filters"> index filters </a> . Index filters are deprecated starting in MongoDB 8.0. </p> <p class="leafygreen-ui-1kp3ins"> Query settings have more functionality than index filters. Also, index filters aren't persistent and you cannot easily create index filters for all cluster nodes. </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"> To remove query settings, use <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/command/removeQuerySettings/#mongodb-dbcommand-dbcmd.removeQuerySettings"> <code class="leafygreen-ui-1l06pbn"> removeQuerySettings </code> </a> . To obtain the query settings, use a <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/querySettings/#mongodb-pipeline-pipe.-querySettings"> <code class="leafygreen-ui-1l06pbn"> $querySettings </code> </a> stage in an aggregation pipeline. </p> </div> </div> <span class="leafygreen-ui-1qnjd6d" id="std-label-setQuerySettings-syntax"> </span> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Syntax <a class="headerlink leafygreen-ui-1kepx47" href="#syntax" 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="syntax"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> You can add or update query settings using either of the two syntax specifications shown in this section. </p> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Set Query Settings by Passing in a Query <a class="headerlink leafygreen-ui-1kepx47" href="#set-query-settings-by-passing-in-a-query" 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="set-query-settings-by-passing-in-a-query"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> In the following syntax, you provide: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> The same fields as a <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/command/find/#mongodb-dbcommand-dbcmd.find"> <code class="leafygreen-ui-1l06pbn"> find </code> </a> , <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/command/distinct/#mongodb-dbcommand-dbcmd.distinct"> <code class="leafygreen-ui-1l06pbn"> distinct </code> </a> , or <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/command/aggregate/#mongodb-dbcommand-dbcmd.aggregate"> <code class="leafygreen-ui-1l06pbn"> aggregate </code> </a> command. See the syntax sections on the pages for those commands for the fields you can include in <code class="leafygreen-ui-1l06pbn"> setQuerySettings </code> . </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> A <code class="leafygreen-ui-1l06pbn"> $db </code> field to specify the database for the query settings. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> A <code class="leafygreen-ui-1l06pbn"> settings </code> document with <code class="leafygreen-ui-1l06pbn"> indexHints </code> and other fields. </p> </li> </ul> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.adminCommand( {\n setQuerySettings: {\n &lt;fields&gt;, // Provide fields for\n // find, distinct, or aggregate command\n $db: &lt;string&gt; // Provide a database name\n },\n // Provide a settings document with indexHints and other fields\n settings: {\n indexHints: [ {\n ns: { db: &lt;string&gt;, coll: &lt;string&gt; },\n allowedIndexes: &lt;array&gt;\n }, ... ],\n queryFramework: &lt;string&gt;,\n reject: &lt;boolean&gt;\n }\n} )","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><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">adminCommand</span>( <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">setQuerySettings</span>: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> &lt;<!-- -->fields<!-- -->&gt;<!-- -->,<!-- --> <span class="lg-highlight-comment">// Provide fields for</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-comment">// find, distinct, or aggregate command</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">$db</span>: &lt;<!-- -->string<!-- -->&gt; <span class="lg-highlight-comment">//</span><span class="lg-highlight-comment"> Provide a database </span><span class="lg-highlight-comment">name</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->}<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-comment">//</span><span class="lg-highlight-comment"> Provide a settings </span><span class="lg-highlight-comment">document with indexHints and other fields</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">settings</span>: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">indexHints</span>: <!-- -->[ <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">ns</span>: <!-- -->{ <span class="lg-highlight-attr">db</span>: &lt;<!-- -->string<!-- -->&gt;<!-- -->,<!-- --> <span class="lg-highlight-attr">coll</span>: &lt;<!-- -->string<!-- -->&gt; <!-- -->}<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">allowedIndexes</span>: &lt;<!-- -->array<!-- -->&gt;</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->}<!-- -->, <!-- -->...<!-- --> ]<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">queryFramework</span>: &lt;<!-- -->string<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">reject</span>: &lt;<!-- -->boolean<!-- -->&gt;</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->}</td></tr><tr class=""><td class="leafygreen-ui-7razhx">} )</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> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Set Query Settings by Passing in a Query Shape Hash <a class="headerlink leafygreen-ui-1kepx47" href="#set-query-settings-by-passing-in-a-query-shape-hash" 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="set-query-settings-by-passing-in-a-query-shape-hash"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> You can provide an existing query shape hash string in <code class="leafygreen-ui-1l06pbn"> setQuerySettings </code> and an updated <code class="leafygreen-ui-1l06pbn"> settings </code> document with <code class="leafygreen-ui-1l06pbn"> indexHints </code> and other fields: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.adminCommand( {\n setQuerySettings: &lt;string&gt;, // Provide an existing query shape hash string\n // Provide a settings document with indexHints and other fields\n settings: {\n indexHints: [ {\n ns: { db: &lt;string&gt;, coll: &lt;string&gt; },\n allowedIndexes: &lt;array&gt;\n }, ... ],\n queryFramework: &lt;string&gt;,\n reject: &lt;boolean&gt;\n }\n} )","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><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">adminCommand</span>( <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">setQuerySettings</span>: &lt;<!-- -->string<!-- -->&gt;<!-- -->,<!-- --> <span class="lg-highlight-comment">// Provide an</span><span class="lg-highlight-comment"> existing query shape </span><span class="lg-highlight-comment">hash string</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-comment">//</span><span class="lg-highlight-comment"> Provide a settings </span><span class="lg-highlight-comment">document with indexHints and other fields</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">settings</span>: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">indexHints</span>: <!-- -->[ <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">ns</span>: <!-- -->{ <span class="lg-highlight-attr">db</span>: &lt;<!-- -->string<!-- -->&gt;<!-- -->,<!-- --> <span class="lg-highlight-attr">coll</span>: &lt;<!-- -->string<!-- -->&gt; <!-- -->}<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">allowedIndexes</span>: &lt;<!-- -->array<!-- -->&gt;</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->}<!-- -->, <!-- -->...<!-- --> ]<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">queryFramework</span>: &lt;<!-- -->string<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">reject</span>: &lt;<!-- -->boolean<!-- -->&gt;</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->}</td></tr><tr class=""><td class="leafygreen-ui-7razhx">} )</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"> A query shape hash is a string that uniquely identifies the query shape. An example query shape hash is <code class="leafygreen-ui-1l06pbn"> "F42757F1AEB68B4C5A6DE6182B29B01947C829C926BCC01226BDA4DDE799766C" </code> . </p> <p class="leafygreen-ui-1kp3ins"> To obtain the query shape hash string, do any of these: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Use a <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/querySettings/#mongodb-pipeline-pipe.-querySettings"> <code class="leafygreen-ui-1l06pbn"> $querySettings </code> </a> stage in an <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/aggregation-pipeline/#std-label-aggregation-pipeline"> aggregation pipeline </a> and examine the <code class="leafygreen-ui-1l06pbn"> queryShapeHash </code> field. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Examine the <a class="leafygreen-ui-tqgtui" href="/docs/manual/tutorial/manage-the-database-profiler/#std-label-database-profiling"> database profiler </a> output. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> View the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/log-messages/#std-label-log-message-slow-ops"> slow query logs <!-- --> . </a> </p> </li> </ul> <p class="leafygreen-ui-1kp3ins"> If you set the query settings using a hash string, then you won't have the <code class="leafygreen-ui-1l06pbn"> representativeQuery </code> field in the <code class="leafygreen-ui-1l06pbn"> $querySettings </code> aggregation stage output. </p> <div class="leafygreen-ui-13vw3ie" role="note"> <h2 class="leafygreen-ui-1fn4p2b"> Tip </h2> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> In both syntax variations, you can provide an array of <code class="leafygreen-ui-1l06pbn"> indexHints </code> documents. You can omit the array brackets if you provide only one <code class="leafygreen-ui-1l06pbn"> indexHints </code> document. </p> </div> </div> </section> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Command Fields <a class="headerlink leafygreen-ui-1kepx47" href="#command-fields" 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="command-fields"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> The command takes these fields: </p> <div class="leafygreen-ui-skkc39" tabindex="0"> <table class="leafygreen-ui-hr8lsv"> <colgroup> <col style="width:5%"/> <col style="width:25%"/> <col style="width:10%"/> <col style="width:50%"/> </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> Field </div> </div> </th> <th class="leafygreen-ui-13uteka" role="columnheader" scope="col"> <div class="leafygreen-ui-ui0te9"> <div> Field Type (document, string, ...) </div> </div> </th> <th class="leafygreen-ui-13uteka" role="columnheader" scope="col"> <div class="leafygreen-ui-ui0te9"> <div> Necessity </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> <code class="leafygreen-ui-1l06pbn"> setQuerySettings </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> document or string‎ </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Required </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <p class="leafygreen-ui-1kp3ins"> You can provide either: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> The same fields as those in a <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/command/find/#mongodb-dbcommand-dbcmd.find"> <code class="leafygreen-ui-1l06pbn"> find </code> </a> , <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/command/distinct/#mongodb-dbcommand-dbcmd.distinct"> <code class="leafygreen-ui-1l06pbn"> distinct </code> </a> , or <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/command/aggregate/#mongodb-dbcommand-dbcmd.aggregate"> <code class="leafygreen-ui-1l06pbn"> aggregate </code> </a> command, and a <code class="leafygreen-ui-1l06pbn"> $db </code> field with the database associated with the original command. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> An existing query shape hash string that uniquely identifies the query shape. An example query shape hash is <code class="leafygreen-ui-1l06pbn"> "F42757F1AEB68B4C5A6DE6182B29B01947C829C926BCC01226BDA4DDE799766C"` </code> . </p> </li> </ul> </div> </div> </td> </tr> <tr class=""> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> indexHints.ns </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> document </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Optional </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <p class="leafygreen-ui-1kp3ins"> Namespace for index hints. Only required when optional index hints are specified. </p> <div class="leafygreen-ui-skkc39" tabindex="0"> <table class="leafygreen-ui-hr8lsv"> <thead class="leafygreen-ui-a9ho40"> </thead> <tbody> <tr class=""> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> db </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> string </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Required </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Name of the database for index hints. </div> </div> </td> </tr> <tr class=""> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> coll </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> string </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Required </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Name of the collection for index hints. </div> </div> </td> </tr> </tbody> </table> </div> </div> </div> </td> </tr> <tr class=""> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> indexHints.allowedIndexes </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> array </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Optional </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <p class="leafygreen-ui-1kp3ins"> Array of indexes for index hints. An index hint can be one of these: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Index name </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> index key pattern </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/meta/natural/#mongodb-operator-metaOp.-natural"> <code class="leafygreen-ui-1l06pbn"> $natural </code> </a> hint </p> </li> </ul> <p class="leafygreen-ui-1kp3ins"> For more details, see <a class="leafygreen-ui-tqgtui" href="/docs/manual/indexes/#std-label-indexes"> Indexes </a> and <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/cursor.hint/#mongodb-method-cursor.hint"> <code class="leafygreen-ui-1l06pbn"> hint() </code> . </a> </p> </div> </div> </td> </tr> <tr class=""> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> queryFramework </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> string </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Optional </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-query-framework"> Query framework </a> string can be set to: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <code class="leafygreen-ui-1l06pbn"> classic </code> to use the classic engine. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <code class="leafygreen-ui-1l06pbn"> sbe </code> to use slot-based query execution engine. For details, see <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/sbe/#std-label-sbe-landing"> Slot-Based Query Execution Engine <!-- --> . </a> </p> </li> </ul> </div> </div> </td> </tr> <tr class=""> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> reject </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> boolean </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Optional </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <p class="leafygreen-ui-1kp3ins"> If <code class="leafygreen-ui-1l06pbn"> true </code> : </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> New queries with the matching query shape are rejected and the query response states the query is rejected. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Any queries currently in progress aren't rejected. </p> </li> </ul> <p class="leafygreen-ui-1kp3ins"> Default is <code class="leafygreen-ui-1l06pbn"> false </code> . </p> <p class="leafygreen-ui-1kp3ins"> To enable a query shape, run <code class="leafygreen-ui-1l06pbn"> setQuerySettings </code> again for the query shape and set <code class="leafygreen-ui-1l06pbn"> reject </code> to <code class="leafygreen-ui-1l06pbn"> false </code> . If you set <code class="leafygreen-ui-1l06pbn"> reject </code> to <code class="leafygreen-ui-1l06pbn"> true </code> and then back to <code class="leafygreen-ui-1l06pbn"> false </code> using <code class="leafygreen-ui-1l06pbn"> setQuerySettings </code> then: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> If your <code class="leafygreen-ui-1l06pbn"> settings </code> document isn't empty, then <code class="leafygreen-ui-1l06pbn"> setQuerySettings </code> enables the query shape. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> If your <code class="leafygreen-ui-1l06pbn"> settings </code> document only contains <code class="leafygreen-ui-1l06pbn"> reject: false </code> , then <code class="leafygreen-ui-1l06pbn"> setQuerySettings </code> returns an error. Instead, use the <code class="leafygreen-ui-1l06pbn"> removeQuerySettings </code> command to remove the settings and then use <code class="leafygreen-ui-1l06pbn"> setQuerySettings </code> to add query settings. </p> </li> </ul> </div> </div> </td> </tr> </tbody> </table> </div> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Examples <a class="headerlink leafygreen-ui-1kepx47" href="#examples" 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="examples"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> The following examples create a collection and add query settings for different commands. The examples use one index for all executions of a query shape run in the cluster. </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"HowTo","steps":[{"@type":"HowToStep","text":"Run:The indexes have the default names orderDate_1 and\ntotalNumber_1.","name":"Create the example collection and indexes"},{"@type":"HowToStep","text":"The following example adds query settings for a find\ncommand. The example provides fields in setQuerySettings for\nthe find command, and includes the orderDate_1 index in\nallowedIndexes.","name":"Add query settings for a find command"},{"@type":"HowToStep","text":"Run this explain command:The following truncated output shows the query settings are set:","name":"(Optional) Verify the query settings"},{"@type":"HowToStep","text":"The following example runs the query:The query optimizer uses the query settings as an additional input\nduring query planning, which affects the plan selected to run the\nquery.Query output:","name":"(Optional) Run the query"},{"@type":"HowToStep","text":"The following example uses a $querySettings stage in\nan aggregation pipeline to obtain the query settings:Truncated output, which includes the queryShapeHash field:","name":"(Optional) Obtain the query settings"},{"@type":"HowToStep","text":"The following example adds query settings for a\ndistinct command:","name":"Add query settings for a distinct command"},{"@type":"HowToStep","text":"The following example adds query settings for an\naggregate command:","name":"Add query settings for an aggregate command"}],"name":"Examples","image":"https://webimages.mongodb.com/_com_assets/cms/kuyj2focmkbxv7gh3-stacked_default_slate_blue.svg?auto=format%252Ccompress"} </script> <div class="css-4nyere eccljxs0"> <div class="css-1nuklj8 e1ckbxcu1"> <div class="css-18fui5z e1ckbxcu0"> <div class="css-19lsqsq e1ckbxcu2"> 1 </div> </div> <div class="css-1ed38mk"> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Create the example collection and indexes <a class="headerlink leafygreen-ui-1kepx47" href="#create-the-example-collection-and-indexes" 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="create-the-example-collection-and-indexes"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> Run: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":" // Create pizzaOrders collection\n db.pizzaOrders.insertMany( [\n { _id: 0, type: \"pepperoni\", size: \"small\", price: 19,\n totalNumber: 10, orderDate: ISODate( \"2023-03-13T08:14:30Z\" ) },\n { _id: 1, type: \"pepperoni\", size: \"medium\", price: 20,\n totalNumber: 20, orderDate: ISODate( \"2023-03-13T09:13:24Z\" ) },\n { _id: 2, type: \"pepperoni\", size: \"large\", price: 21,\n totalNumber: 30, orderDate: ISODate( \"2023-03-17T09:22:12Z\" ) },\n { _id: 3, type: \"cheese\", size: \"small\", price: 12,\n totalNumber: 15, orderDate: ISODate( \"2023-03-13T11:21:39.736Z\" ) },\n { _id: 4, type: \"cheese\", size: \"medium\", price: 13,\n totalNumber: 50, orderDate: ISODate( \"2024-01-12T21:23:13.331Z\" ) },\n { _id: 5, type: \"cheese\", size: \"large\", price: 14,\n totalNumber: 10, orderDate: ISODate( \"2024-01-12T05:08:13Z\" ) },\n { _id: 6, type: \"vegan\", size: \"small\", price: 17,\n totalNumber: 10, orderDate: ISODate( \"2023-01-13T05:08:13Z\" ) },\n { _id: 7, type: \"vegan\", size: \"medium\", price: 18,\n totalNumber: 10, orderDate: ISODate( \"2023-01-13T05:10:13Z\" ) }\n] )\n\n // Create ascending index on orderDate field\n db.pizzaOrders.createIndex( { orderDate: 1 } )\n\n // Create ascending index on totalNumber field\n db.pizzaOrders.createIndex( { totalNumber: 1 } )","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-comment">// Create pizzaOrders collection</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> db.<span class="lg-highlight-property">pizzaOrders</span>.<span class="lg-highlight-title lg-highlight-function">insertMany</span>( <!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">0</span>, <span class="lg-highlight-attr">type</span>: <span class="lg-highlight-string">"pepperoni"</span>, <span class="lg-highlight-attr">size</span>: <span class="lg-highlight-string">"small"</span>, <span class="lg-highlight-attr">price</span>: <span class="lg-highlight-number">19</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">totalNumber</span>: <span class="lg-highlight-number">10</span>, <span class="lg-highlight-attr">orderDate</span>: <span class="lg-highlight-title lg-highlight-class">ISODate</span>( <span class="lg-highlight-string">"2023-03-13T08:14:30Z"</span> ) }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">1</span>, <span class="lg-highlight-attr">type</span>: <span class="lg-highlight-string">"pepperoni"</span>, <span class="lg-highlight-attr">size</span>: <span class="lg-highlight-string">"medium"</span>, <span class="lg-highlight-attr">price</span>: <span class="lg-highlight-number">20</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">totalNumber</span>: <span class="lg-highlight-number">20</span>, <span class="lg-highlight-attr">orderDate</span>: <span class="lg-highlight-title lg-highlight-class">ISODate</span>( <span class="lg-highlight-string">"2023-03-13T09:13:24Z"</span> ) }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">2</span>, <span class="lg-highlight-attr">type</span>: <span class="lg-highlight-string">"pepperoni"</span>, <span class="lg-highlight-attr">size</span>: <span class="lg-highlight-string">"large"</span>, <span class="lg-highlight-attr">price</span>: <span class="lg-highlight-number">21</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">totalNumber</span>: <span class="lg-highlight-number">30</span>, <span class="lg-highlight-attr">orderDate</span>: <span class="lg-highlight-title lg-highlight-class">ISODate</span>( <span class="lg-highlight-string">"2023-03-17T09:22:12Z"</span> ) }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">3</span>, <span class="lg-highlight-attr">type</span>: <span class="lg-highlight-string">"cheese"</span>, <span class="lg-highlight-attr">size</span>: <span class="lg-highlight-string">"small"</span>, <span class="lg-highlight-attr">price</span>: <span class="lg-highlight-number">12</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">totalNumber</span>: <span class="lg-highlight-number">15</span>, <span class="lg-highlight-attr">orderDate</span>: <span class="lg-highlight-title lg-highlight-class">ISODate</span>( <span class="lg-highlight-string">"2023-03-13T11:21:39.736Z"</span> ) }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">4</span>, <span class="lg-highlight-attr">type</span>: <span class="lg-highlight-string">"cheese"</span>, <span class="lg-highlight-attr">size</span>: <span class="lg-highlight-string">"medium"</span>, <span class="lg-highlight-attr">price</span>: <span class="lg-highlight-number">13</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">totalNumber</span>: <span class="lg-highlight-number">50</span>, <span class="lg-highlight-attr">orderDate</span>: <span class="lg-highlight-title lg-highlight-class">ISODate</span>( <span class="lg-highlight-string">"2024-01-12T21:23:13.331Z"</span> ) }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">5</span>, <span class="lg-highlight-attr">type</span>: <span class="lg-highlight-string">"cheese"</span>, <span class="lg-highlight-attr">size</span>: <span class="lg-highlight-string">"large"</span>, <span class="lg-highlight-attr">price</span>: <span class="lg-highlight-number">14</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">totalNumber</span>: <span class="lg-highlight-number">10</span>, <span class="lg-highlight-attr">orderDate</span>: <span class="lg-highlight-title lg-highlight-class">ISODate</span>( <span class="lg-highlight-string">"2024-01-12T05:08:13Z"</span> ) }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">6</span>, <span class="lg-highlight-attr">type</span>: <span class="lg-highlight-string">"vegan"</span>, <span class="lg-highlight-attr">size</span>: <span class="lg-highlight-string">"small"</span>, <span class="lg-highlight-attr">price</span>: <span class="lg-highlight-number">17</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">totalNumber</span>: <span class="lg-highlight-number">10</span>, <span class="lg-highlight-attr">orderDate</span>: <span class="lg-highlight-title lg-highlight-class">ISODate</span>( <span class="lg-highlight-string">"2023-01-13T05:08:13Z"</span> ) }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">7</span>, <span class="lg-highlight-attr">type</span>: <span class="lg-highlight-string">"vegan"</span>, <span class="lg-highlight-attr">size</span>: <span class="lg-highlight-string">"medium"</span>, <span class="lg-highlight-attr">price</span>: <span class="lg-highlight-number">18</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">totalNumber</span>: <span class="lg-highlight-number">10</span>, <span class="lg-highlight-attr">orderDate</span>: <span class="lg-highlight-title lg-highlight-class">ISODate</span>( <span class="lg-highlight-string">"2023-01-13T05:10:13Z"</span> ) }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">] )</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><div class="leafygreen-ui-ihxujy"></div></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-comment">//</span><span class="lg-highlight-comment"> Create ascending index </span><span class="lg-highlight-comment">on orderDate field</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> db.<span class="lg-highlight-property">pizzaOrders</span>.<span class="lg-highlight-title lg-highlight-function">createIndex</span>( <!-- -->{ <span class="lg-highlight-attr">orderDate</span>: <span class="lg-highlight-number">1</span> } )</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><div class="leafygreen-ui-ihxujy"></div></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-comment">//</span><span class="lg-highlight-comment"> Create ascending index </span><span class="lg-highlight-comment">on totalNumber field</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> db.<span class="lg-highlight-property">pizzaOrders</span>.<span class="lg-highlight-title lg-highlight-function">createIndex</span>( <!-- -->{ <span class="lg-highlight-attr">totalNumber</span>: <span class="lg-highlight-number">1</span> } )</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 indexes have the default names <code class="leafygreen-ui-1l06pbn"> orderDate_1 </code> and <code class="leafygreen-ui-1l06pbn"> totalNumber_1 </code> . </p> </section> </div> </div> <div class="css-1nuklj8 e1ckbxcu1"> <div class="css-18fui5z e1ckbxcu0"> <div class="css-19lsqsq e1ckbxcu2"> 2 </div> </div> <div class="css-1ed38mk"> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Add query settings for a find command <a class="headerlink leafygreen-ui-1kepx47" href="#add-query-settings-for-a-find-command" 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="add-query-settings-for-a-find-command"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> The following example adds query settings for a <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/command/find/#mongodb-dbcommand-dbcmd.find"> <code class="leafygreen-ui-1l06pbn"> find </code> </a> command. The example provides fields in <code class="leafygreen-ui-1l06pbn"> setQuerySettings </code> for the <code class="leafygreen-ui-1l06pbn"> find </code> command, and includes the <code class="leafygreen-ui-1l06pbn"> orderDate_1 </code> index in <code class="leafygreen-ui-1l06pbn"> allowedIndexes </code> . </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.adminCommand( {\n setQuerySettings: {\n find: \"pizzaOrders\",\n filter: {\n orderDate: { $gt: ISODate( \"2023-01-20T00:00:00Z\" ) }\n },\n sort: {\n totalNumber: 1\n },\n $db: \"test\"\n },\n settings: {\n indexHints: {\n ns: { db: \"test\", coll: \"pizzaOrders\" },\n allowedIndexes: [ \"orderDate_1\" ]\n },\n queryFramework: \"classic\"\n }\n} )","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><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">adminCommand</span>( <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">setQuerySettings</span>: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">find</span>: <span class="lg-highlight-string">"pizzaOrders"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">filter</span>: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">orderDate</span>: <!-- -->{ <span class="lg-highlight-attr">$gt</span>: <span class="lg-highlight-title lg-highlight-class">ISODate</span>( <span class="lg-highlight-string">"2023-01-20T00:00:00Z"</span> ) }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">sort</span>: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">totalNumber</span>: <span class="lg-highlight-number">1</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">$db</span>: <span class="lg-highlight-string">"test"</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">settings</span>: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">indexHints</span>: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">ns</span>: <!-- -->{ <span class="lg-highlight-attr">db</span>: <span class="lg-highlight-string">"test"</span>, <span class="lg-highlight-attr">coll</span>: <span class="lg-highlight-string">"pizzaOrders"</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">allowedIndexes</span>: <!-- -->[ <span class="lg-highlight-string">"orderDate_1"</span> ]</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">queryFramework</span>: <span class="lg-highlight-string">"classic"</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">} )</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> </section> </div> </div> <div class="css-1nuklj8 e1ckbxcu1"> <div class="css-18fui5z e1ckbxcu0"> <div class="css-19lsqsq e1ckbxcu2"> 3 </div> </div> <div class="css-1ed38mk"> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> (Optional) Verify the query settings <a class="headerlink leafygreen-ui-1kepx47" href="#-optional--verify-the-query-settings" 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="-optional--verify-the-query-settings"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> Run this <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/command/explain/#mongodb-dbcommand-dbcmd.explain"> <code class="leafygreen-ui-1l06pbn"> explain </code> </a> command: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.pizzaOrders.explain().find( { orderDate: { $gt: ISODate(\n\"2023-01-20T00:00:00Z\" ) } } ).sort( { totalNumber: 1 } )","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><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">pizzaOrders</span>.<span class="lg-highlight-title lg-highlight-function">explain</span>(<!-- -->).<span class="lg-highlight-title lg-highlight-function">find</span>( <!-- -->{ <span class="lg-highlight-attr">orderDate</span>: <!-- -->{ <span class="lg-highlight-attr">$gt</span>: <span class="lg-highlight-title lg-highlight-class">ISODate</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-string">"2023-01-20T00:00:00Z"</span> ) } } ).<span class="lg-highlight-title lg-highlight-function">sort</span>( <!-- -->{ <span class="lg-highlight-attr">totalNumber</span>: <span class="lg-highlight-number">1</span> } )</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 truncated output shows the query settings are set: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"queryPlanner: {\n winningPlan: {\n stage: 'SINGLE_SHARD',\n shards: [\n {\n explainVersion: '1',\n ...\n namespace: 'test.pizzaOrders',\n indexFilterSet: false,\n parsedQuery: { orderDate: { '$gt': ISODate('2023-01-20T00:00:00.000Z') } },\n querySettings: {\n indexHints: {\n ns: { db: 'test', coll: 'pizzaOrders' },\n allowedIndexes: [ 'orderDate_1' ]\n },\n queryFramework: 'classic'\n },\n ...\n }\n ...\n ]\n }\n}","programmingLanguage":"JavaScript"} </script> <div class="css-1lju8ps"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-tyg50d"> <pre class="leafygreen-ui-1453az5" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-attr">queryPlanner</span>: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">winningPlan</span>: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">stage</span>: <span class="lg-highlight-string">'SINGLE_SHARD'</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">shards</span>: <!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">explainVersion</span>: <span class="lg-highlight-string">'1'</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->...</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">namespace</span>: <span class="lg-highlight-string">'test.pizzaOrders'</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">indexFilterSet</span>: <span class="lg-highlight-literal">false</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">parsedQuery</span>: <!-- -->{ <span class="lg-highlight-attr">orderDate</span>: <!-- -->{ <span class="lg-highlight-string">'$gt'</span>: <span class="lg-highlight-title lg-highlight-class">ISODate</span>(<span class="lg-highlight-string">'2023-01-20T00:00:00.000Z'</span>) } }<!-- -->,</td></tr><tr class="leafygreen-ui-1wr1lm6"><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">querySettings</span>: <!-- -->{</td></tr><tr class="leafygreen-ui-1wr1lm6"><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">indexHints</span>: <!-- -->{</td></tr><tr class="leafygreen-ui-1wr1lm6"><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">ns</span>: <!-- -->{ <span class="lg-highlight-attr">db</span>: <span class="lg-highlight-string">'test'</span>, <span class="lg-highlight-attr">coll</span>: <span class="lg-highlight-string">'pizzaOrders'</span> }<!-- -->,</td></tr><tr class="leafygreen-ui-1wr1lm6"><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">allowedIndexes</span>: <!-- -->[ <span class="lg-highlight-string">'orderDate_1'</span> ]</td></tr><tr class="leafygreen-ui-1wr1lm6"><td class="leafygreen-ui-7razhx"> }<!-- -->,</td></tr><tr class="leafygreen-ui-1wr1lm6"><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">queryFramework</span>: <span class="lg-highlight-string">'classic'</span></td></tr><tr class="leafygreen-ui-1wr1lm6"><td class="leafygreen-ui-7razhx"> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->...</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->...</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> ]</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">}</td></tr></tbody></table></code></pre> </div> </div> </div> </section> </div> </div> <div class="css-1nuklj8 e1ckbxcu1"> <div class="css-18fui5z e1ckbxcu0"> <div class="css-19lsqsq e1ckbxcu2"> 4 </div> </div> <div class="css-1ed38mk"> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> (Optional) Run the query <a class="headerlink leafygreen-ui-1kepx47" href="#-optional--run-the-query" 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="-optional--run-the-query"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> The following example runs the query: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.pizzaOrders.find(\n { orderDate: { $gt: ISODate( \"2023-01-20T00:00:00Z\" ) } } ).sort( { totalNumber: 1 }\n)","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><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">pizzaOrders</span>.<span class="lg-highlight-title lg-highlight-function">find</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">orderDate</span>: <!-- -->{ <span class="lg-highlight-attr">$gt</span>: <span class="lg-highlight-title lg-highlight-class">ISODate</span>( <span class="lg-highlight-string">"2023-01-20T00:00:00Z"</span> ) } } ).<span class="lg-highlight-title lg-highlight-function">sort</span>( <!-- -->{ <span class="lg-highlight-attr">totalNumber</span>: <span class="lg-highlight-number">1</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">)</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 query optimizer uses the query settings as an additional input during query planning, which affects the plan selected to run the query. </p> <p class="leafygreen-ui-1kp3ins"> Query output: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"[\n {\n _id: 0,\n type: 'pepperoni',\n size: 'small',\n price: 19,\n totalNumber: 10,\n orderDate: ISODate('2023-03-13T08:14:30.000Z')\n },\n {\n _id: 5,\n type: 'cheese',\n size: 'large',\n price: 14,\n totalNumber: 10,\n orderDate: ISODate('2024-01-12T05:08:13.000Z')\n },\n {\n _id: 3,\n type: 'cheese',\n size: 'small',\n price: 12,\n totalNumber: 15,\n orderDate: ISODate('2023-03-13T11:21:39.736Z')\n },\n {\n _id: 1,\n type: 'pepperoni',\n size: 'medium',\n price: 20,\n totalNumber: 20,\n orderDate: ISODate('2023-03-13T09:13:24.000Z')\n },\n {\n _id: 2,\n type: 'pepperoni',\n size: 'large',\n price: 21,\n totalNumber: 30,\n orderDate: ISODate('2023-03-17T09:22:12.000Z')\n },\n {\n _id: 4,\n type: 'cheese',\n size: 'medium',\n price: 13,\n totalNumber: 50,\n orderDate: ISODate('2024-01-12T21:23:13.331Z')\n }\n]","programmingLanguage":"JavaScript"} </script> <div class="css-1lju8ps"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1jheeh3"> <pre class="leafygreen-ui-1453az5" 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">[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">0</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">type</span>: <span class="lg-highlight-string">'pepperoni'</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">size</span>: <span class="lg-highlight-string">'small'</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">price</span>: <span class="lg-highlight-number">19</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">totalNumber</span>: <span class="lg-highlight-number">10</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">orderDate</span>: <span class="lg-highlight-title lg-highlight-class">ISODate</span>(<span class="lg-highlight-string">'2023-03-13T08:14:30.000Z'</span>)</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">5</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">type</span>: <span class="lg-highlight-string">'cheese'</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">size</span>: <span class="lg-highlight-string">'large'</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">price</span>: <span class="lg-highlight-number">14</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">totalNumber</span>: <span class="lg-highlight-number">10</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">orderDate</span>: <span class="lg-highlight-title lg-highlight-class">ISODate</span>(<span class="lg-highlight-string">'2024-01-12T05:08:13.000Z'</span>)</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">3</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">type</span>: <span class="lg-highlight-string">'cheese'</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">size</span>: <span class="lg-highlight-string">'small'</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">price</span>: <span class="lg-highlight-number">12</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">totalNumber</span>: <span class="lg-highlight-number">15</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">orderDate</span>: <span class="lg-highlight-title lg-highlight-class">ISODate</span>(<span class="lg-highlight-string">'2023-03-13T11:21:39.736Z'</span>)</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">1</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">type</span>: <span class="lg-highlight-string">'pepperoni'</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">size</span>: <span class="lg-highlight-string">'medium'</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">price</span>: <span class="lg-highlight-number">20</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">totalNumber</span>: <span class="lg-highlight-number">20</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">orderDate</span>: <span class="lg-highlight-title lg-highlight-class">ISODate</span>(<span class="lg-highlight-string">'2023-03-13T09:13:24.000Z'</span>)</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">2</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">type</span>: <span class="lg-highlight-string">'pepperoni'</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">size</span>: <span class="lg-highlight-string">'large'</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">price</span>: <span class="lg-highlight-number">21</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">totalNumber</span>: <span class="lg-highlight-number">30</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">orderDate</span>: <span class="lg-highlight-title lg-highlight-class">ISODate</span>(<span class="lg-highlight-string">'2023-03-17T09:22:12.000Z'</span>)</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">4</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">type</span>: <span class="lg-highlight-string">'cheese'</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">size</span>: <span class="lg-highlight-string">'medium'</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">price</span>: <span class="lg-highlight-number">13</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">totalNumber</span>: <span class="lg-highlight-number">50</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">orderDate</span>: <span class="lg-highlight-title lg-highlight-class">ISODate</span>(<span class="lg-highlight-string">'2024-01-12T21:23:13.331Z'</span>)</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">]</td></tr></tbody></table></code></pre> </div> </div> </div> </section> </div> </div> <div class="css-1nuklj8 e1ckbxcu1"> <div class="css-18fui5z e1ckbxcu0"> <div class="css-19lsqsq e1ckbxcu2"> 5 </div> </div> <div class="css-1ed38mk"> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> (Optional) Obtain the query settings <a class="headerlink leafygreen-ui-1kepx47" href="#-optional--obtain-the-query-settings" 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="-optional--obtain-the-query-settings"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> The following example uses a <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/querySettings/#mongodb-pipeline-pipe.-querySettings"> <code class="leafygreen-ui-1l06pbn"> $querySettings </code> </a> stage in an aggregation pipeline to obtain the query settings: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.aggregate( [\n { $querySettings: {} }\n] )","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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>( <!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">$querySettings</span>: <!-- -->{<!-- -->} }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">] )</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"> Truncated output, which includes the <code class="leafygreen-ui-1l06pbn"> queryShapeHash </code> field: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"[\n {\n queryShapeHash: 'AB8ECADEE8F0EB0F447A30744EB4813AE7E0BFEF523B0870CA10FCBC87F5D8F1',\n settings: {\n indexHints: [\n {\n ns: { db: 'test', coll: 'pizzaOrders' },\n allowedIndexes: [ 'orderDate_1' ]\n }\n ],\n queryFramework: 'classic'\n },\n representativeQuery: {\n find: 'pizzaOrders',\n filter: { orderDate: { '$gt': ISODate('2023-01-20T00:00:00.000Z') } },\n sort: { totalNumber: 1 },\n '$db': 'test'\n }\n }\n]","programmingLanguage":"JavaScript"} </script> <div class="css-1lju8ps"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-tyg50d"> <pre class="leafygreen-ui-1453az5" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class="leafygreen-ui-1wr1lm6"><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">queryShapeHash</span>: <span class="lg-highlight-string">'AB8ECADEE8F0EB0F447A30744EB4813AE7E0BFEF523B0870CA10FCBC87F5D8F1'</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">settings</span>: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">indexHints</span>: <!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">ns</span>: <!-- -->{ <span class="lg-highlight-attr">db</span>: <span class="lg-highlight-string">'test'</span>, <span class="lg-highlight-attr">coll</span>: <span class="lg-highlight-string">'pizzaOrders'</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">allowedIndexes</span>: <!-- -->[ <span class="lg-highlight-string">'orderDate_1'</span> ]</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> ]<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">queryFramework</span>: <span class="lg-highlight-string">'classic'</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">representativeQuery</span>: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">find</span>: <span class="lg-highlight-string">'pizzaOrders'</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">filter</span>: <!-- -->{ <span class="lg-highlight-attr">orderDate</span>: <!-- -->{ <span class="lg-highlight-string">'$gt'</span>: <span class="lg-highlight-title lg-highlight-class">ISODate</span>(<span class="lg-highlight-string">'2023-01-20T00:00:00.000Z'</span>) } }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">sort</span>: <!-- -->{ <span class="lg-highlight-attr">totalNumber</span>: <span class="lg-highlight-number">1</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">'$db'</span>: <span class="lg-highlight-string">'test'</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">]</td></tr></tbody></table></code></pre> </div> </div> </div> </section> </div> </div> <div class="css-1nuklj8 e1ckbxcu1"> <div class="css-18fui5z e1ckbxcu0"> <div class="css-19lsqsq e1ckbxcu2"> 6 </div> </div> <div class="css-1ed38mk"> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Add query settings for a distinct command <a class="headerlink leafygreen-ui-1kepx47" href="#add-query-settings-for-a-distinct-command" 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="add-query-settings-for-a-distinct-command"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> The following example adds query settings for a <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/command/distinct/#mongodb-dbcommand-dbcmd.distinct"> <code class="leafygreen-ui-1l06pbn"> distinct </code> </a> command: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.adminCommand( {\n setQuerySettings: {\n distinct: \"pizzaOrders\",\n key: \"totalNumber\",\n query: { type: \"pepperoni\"} ,\n $db: \"test\"\n },\n settings: {\n indexHints: {\n ns: { db: \"test\", coll: \"pizzaOrders\" },\n allowedIndexes: [ \"orderDate_1\" ]\n },\n queryFramework: \"classic\"\n }\n} )","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">adminCommand</span>( <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">setQuerySettings</span>: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">distinct</span>: <span class="lg-highlight-string">"pizzaOrders"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">key</span>: <span class="lg-highlight-string">"totalNumber"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">query</span>: <!-- -->{ <span class="lg-highlight-attr">type</span>: <span class="lg-highlight-string">"pepperoni"</span>} <!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">$db</span>: <span class="lg-highlight-string">"test"</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">settings</span>: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">indexHints</span>: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">ns</span>: <!-- -->{ <span class="lg-highlight-attr">db</span>: <span class="lg-highlight-string">"test"</span>, <span class="lg-highlight-attr">coll</span>: <span class="lg-highlight-string">"pizzaOrders"</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">allowedIndexes</span>: <!-- -->[ <span class="lg-highlight-string">"orderDate_1"</span> ]</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">queryFramework</span>: <span class="lg-highlight-string">"classic"</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">} )</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> </section> </div> </div> <div class="css-1nuklj8 e1ckbxcu1"> <div class="css-18fui5z e1ckbxcu0"> <div class="css-19lsqsq e1ckbxcu2"> 7 </div> </div> <div class="css-1ed38mk"> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Add query settings for an aggregate command <a class="headerlink leafygreen-ui-1kepx47" href="#add-query-settings-for-an-aggregate-command" 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="add-query-settings-for-an-aggregate-command"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> The following example adds query settings for an <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/command/aggregate/#mongodb-dbcommand-dbcmd.aggregate"> <code class="leafygreen-ui-1l06pbn"> aggregate </code> </a> command: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.adminCommand( {\n setQuerySettings: {\n aggregate: \"pizzaOrders\",\n pipeline: [\n { $match: { size: \"medium\" } },\n { $group: {\n _id: \"$type\",\n totalMediumPizzaOrdersGroupedByType: { $sum: \"$totalNumber\" }\n } }\n ],\n $db: \"test\"\n },\n settings: {\n indexHints: {\n ns: { db: \"test\", coll: \"pizzaOrders\" },\n allowedIndexes: [ \"totalNumber_1\" ]\n },\n queryFramework: \"classic\"\n }\n} )","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><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">adminCommand</span>( <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">setQuerySettings</span>: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">aggregate</span>: <span class="lg-highlight-string">"pizzaOrders"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">pipeline</span>: <!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">$match</span>: <!-- -->{ <span class="lg-highlight-attr">size</span>: <span class="lg-highlight-string">"medium"</span> } }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">$group</span>: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-string">"$type"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">totalMediumPizzaOrdersGroupedByType</span>: <!-- -->{ <span class="lg-highlight-attr">$sum</span>: <span class="lg-highlight-string">"$totalNumber"</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> } }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> ]<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">$db</span>: <span class="lg-highlight-string">"test"</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">settings</span>: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">indexHints</span>: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">ns</span>: <!-- -->{ <span class="lg-highlight-attr">db</span>: <span class="lg-highlight-string">"test"</span>, <span class="lg-highlight-attr">coll</span>: <span class="lg-highlight-string">"pizzaOrders"</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">allowedIndexes</span>: <!-- -->[ <span class="lg-highlight-string">"totalNumber_1"</span> ]</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">queryFramework</span>: <span class="lg-highlight-string">"classic"</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">} )</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> </section> </div> </div> </div> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Learn More <a class="headerlink leafygreen-ui-1kepx47" href="#learn-more" 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="learn-more"> </div> </a> </h2> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/query-plans/#std-label-query-plans-query-optimization"> Query Plans </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/indexes/#std-label-indexes"> Indexes </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/querySettings/#mongodb-pipeline-pipe.-querySettings"> <code class="leafygreen-ui-1l06pbn"> $querySettings </code> </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/command/removeQuerySettings/#mongodb-dbcommand-dbcmd.removeQuerySettings"> <code class="leafygreen-ui-1l06pbn"> removeQuerySettings </code> </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/aggregation-pipeline/#std-label-aggregation-pipeline"> Aggregation Pipeline </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/query-shapes/#std-label-query-shapes"> Query Shapes </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/queryStats/#std-label-queryStats-queryShape"> Query statistics for query shapes </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/tutorial/operation-rejection-filters/#std-label-operation-rejection-filters"> Block Slow Queries with Operation Rejection Filters </a> </p> </li> </ul> </section> </section>
https://www.mongodb.com/docs/manual/core/csfle/fundamentals/manual-encryption/
<section> <h1 class="contains-headerlink leafygreen-ui-41fr9s" weight="medium"> Explicit Encryption <a class="headerlink leafygreen-ui-1kepx47" href="#explicit-encryption" 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="explicit-encryption"> </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="#overview" target="_self"> <span> Overview </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#use-explicit-encryption" target="_self"> <span> Use Explicit Encryption </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-x9koo9" href="#create-a-clientencryption-instance" target="_self"> <span> Create a ClientEncryption Instance </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-x9koo9" href="#encrypt-fields-in-read-and-write-operations" target="_self"> <span> Encrypt Fields in Read and Write Operations </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-x9koo9" href="#manual-decryption" target="_self"> <span> Manual Decryption </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-x9koo9" href="#automatic-decryption" target="_self"> <span> Automatic Decryption </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#example" target="_self"> <span> Example </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-x9koo9" href="#create-a-mongoclient-instance" target="_self"> <span> Create a MongoClient Instance </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-x9koo9" href="#create-a-clientencryption-instance-1" target="_self"> <span> Create a ClientEncryption Instance </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-x9koo9" href="#encrypt-fields-and-insert" target="_self"> <span> Encrypt Fields and Insert </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-x9koo9" href="#retrieve-document-and-decrypt-fields" target="_self"> <span> Retrieve Document and Decrypt Fields </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#server-side-field-level-encryption-enforcement" target="_self"> <span> Server-Side Field Level Encryption Enforcement </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#learn-more" target="_self"> <span> Learn More </span> </a> </li> </ul> </div> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Overview <a class="headerlink leafygreen-ui-1kepx47" href="#overview" 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="overview"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> Explicit encryption provides fine-grained control over security, at the cost of increased complexity when configuring collections and writing code for MongoDB Drivers. With explicit encryption, you specify how to encrypt fields in your document for each operation you perform on the database, and you include this logic throughout your application. </p> <p class="leafygreen-ui-1kp3ins"> Explicit encryption is available in the following MongoDB products: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> MongoDB Community Server </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> MongoDB Enterprise Advanced </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> MongoDB Atlas </p> </li> </ul> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Use Explicit Encryption <a class="headerlink leafygreen-ui-1kepx47" href="#use-explicit-encryption" 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="use-explicit-encryption"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> To use explicit encryption you must perform the following actions in your CSFLE-enabled application: </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="#std-label-csfle-fundamentals-manual-encryption-client-enc" target="_self"> <span> Create a ClientEncryption Instance </span> </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-csfle-fundamentals-manual-encryption-update-operations" target="_self"> <span> Encrypt Fields in Read and Write Operations </span> </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-csfle-fundamentals-manual-encryption-manual-decryption" target="_self"> <span> Manually </span> </a> or <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-csfle-fundamentals-manual-encryption-automatic-decryption" target="_self"> <span> Automatically </span> </a> Decrypt Fields in Your Documents </p> </li> </ul> <span class="leafygreen-ui-1qnjd6d" id="std-label-csfle-fundamentals-manual-encryption-client-enc"> </span> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Create a ClientEncryption Instance <a class="headerlink leafygreen-ui-1kepx47" href="#create-a-clientencryption-instance" 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="create-a-clientencryption-instance"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> To use explicit encryption, you must create a <code class="leafygreen-ui-1l06pbn"> ClientEncryption </code> instance. <code class="leafygreen-ui-1l06pbn"> ClientEncryption </code> is an abstraction used across drivers and <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/mongodb-shell/#mongodb-binary-bin.mongosh" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongosh </code> </span> </a> that encapsulates the Key Vault collection and <span class="leafygreen-ui-vm4wms" tabindex="0"> KMS </span> operations involved in explicit encryption. </p> <p class="leafygreen-ui-1kp3ins"> To create a <code class="leafygreen-ui-1l06pbn"> ClientEncryption </code> instance, you must specify the following information: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> A <code class="leafygreen-ui-1l06pbn"> MongoClient </code> instance with access to your Key Vault collection </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> The namespace of your Key Vault collection </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> A <code class="leafygreen-ui-1l06pbn"> kmsProviders </code> object configured with access to the <span class="leafygreen-ui-vm4wms" tabindex="0"> KMS </span> provider hosting your Customer Master Key </p> </li> </ul> <p class="leafygreen-ui-1kp3ins"> For more <code class="leafygreen-ui-1l06pbn"> ClientEncryption </code> options, see <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/csfle/reference/csfle-options-clients/#std-label-csfle-reference-mongo-client"> MongoClient Options for CSFLE <!-- --> . </a> </p> <p class="leafygreen-ui-1kp3ins"> To view code snippets that show how to create a <code class="leafygreen-ui-1l06pbn"> ClientEncryption </code> instance, see the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-csfle-fundamentals-manual-encryption-example" target="_self"> <span> Example </span> </a> section of this guide. </p> <span class="leafygreen-ui-1qnjd6d" id="std-label-csfle-fundamentals-manual-encryption-update-operations"> </span> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Encrypt Fields in Read and Write Operations <a class="headerlink leafygreen-ui-1kepx47" href="#encrypt-fields-in-read-and-write-operations" 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="encrypt-fields-in-read-and-write-operations"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> You must update read and write operations throughout your application such that your application encrypts fields before performing read and write operations. </p> <p class="leafygreen-ui-1kp3ins"> To encrypt fields, use the <code class="leafygreen-ui-1l06pbn"> encrypt </code> method of your <code class="leafygreen-ui-1l06pbn"> ClientEncryption </code> instance. </p> <p class="leafygreen-ui-1kp3ins"> To view code snippets that show how to use the <code class="leafygreen-ui-1l06pbn"> encrypt </code> method, see the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-csfle-fundamentals-manual-encryption-example" target="_self"> <span> Example </span> </a> section of this guide. </p> <span class="leafygreen-ui-1qnjd6d" id="std-label-csfle-fundamentals-manual-encryption-manual-decryption"> </span> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Manual Decryption <a class="headerlink leafygreen-ui-1kepx47" href="#manual-decryption" 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="manual-decryption"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> You can decrypt your encrypted fields manually or automatically when using explicit encryption. </p> <p class="leafygreen-ui-1kp3ins"> To decrypt your fields manually, use the <code class="leafygreen-ui-1l06pbn"> decrypt </code> method of your <code class="leafygreen-ui-1l06pbn"> ClientEncryption </code> instance. </p> <p class="leafygreen-ui-1kp3ins"> To view code snippets that show how to use the <code class="leafygreen-ui-1l06pbn"> decrypt </code> method, see the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-csfle-fundamentals-manual-encryption-example" target="_self"> <span> Example </span> </a> section of this guide. </p> <span class="leafygreen-ui-1qnjd6d" id="std-label-csfle-fundamentals-manual-encryption-automatic-decryption"> </span> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Automatic Decryption <a class="headerlink leafygreen-ui-1kepx47" href="#automatic-decryption" 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="automatic-decryption"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> To decrypt your fields automatically, configure your <code class="leafygreen-ui-1l06pbn"> MongoClient </code> instance as follows: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Specify your Key Vault collection </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Specify a <code class="leafygreen-ui-1l06pbn"> kmsProviders </code> object </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> If you use MongoDB Community Server, set the <code class="leafygreen-ui-1l06pbn"> bypassAutoEncryption </code> option to <code class="leafygreen-ui-1l06pbn"> True </code> </p> </li> </ul> <div class="leafygreen-ui-15mdk4" role="note"> <h2 class="leafygreen-ui-6n7b7d"> Note </h2> <h3 class="leafygreen-ui-144d5kf"> <strong> Automatic Decryption is Available in MongoDB Community Server </strong> </h3> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> Although automatic encryption requires MongoDB Enterprise or MongoDB Atlas, automatic decryption is available in the following MongoDB products: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> MongoDB Community Server </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> MongoDB Enterprise Advanced </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> MongoDB Atlas </p> </li> </ul> </div> </div> <p class="leafygreen-ui-1kp3ins"> To view a code snippet demonstrating how to enable automatic decryption, select the tab corresponding to your preferred language: </p> <div aria-hidden="true"> </div> <div class="leafygreen-ui-f2qztv" data-lgid="lg-tabs"> <div class="leafygreen-ui-jp7pox" id="tabs-10"> <div aria-label="Tabs to describe usage of drivers" aria-orientation="horizontal" class="leafygreen-ui-m8p1vb lg-ui-tab-list-0000" data-lgid="lg-tabs-tab_list" role="tablist"> <button aria-controls="_mhsqthbhv" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_fatcp3pcy" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> MongoDB Shell </div> </button> <button aria-controls="_5z8mrcp92" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_jrrqyt2m7" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> C# </div> </button> <button aria-controls="_hllmib7ke" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_19ko76gvq" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Go </div> </button> <button aria-controls="_5bc0ob6k6" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_y5ce26euo" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Java (Sync) </div> </button> <button aria-controls="_np0vsqb3l" aria-selected="true" class="leafygreen-ui-1l773z1" data-text="" id="_q0mzrhmzm" name="" role="tab" tabindex="0"> <div class="leafygreen-ui-1nxuzmg"> Node.js </div> </button> <button aria-controls="_n21fxgcb1" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_zx8wx1l56" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Python </div> </button> </div> <div class="leafygreen-ui-ov1ktg"> <div class="leafygreen-ui-1sg2lsz"> </div> </div> </div> <div class="lg-ui-tab-panels-0000" data-lgid="lg-tabs-tab_panels"> <div> <div aria-labelledby="_vr5qgq4kt" class="leafygreen-ui-38lglc" id="_e6fzk2s2g" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"var autoEncryptionOpts = {\n keyVaultNamespace: keyVaultNamespace,\n kmsProviders: kmsProviders,\n bypassAutoEncryption: true,\n};\nvar encryptedClient = Mongo(\n connectionString,\n autoEncryptionOpts\n);\n","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <pre class="leafygreen-ui-11itue3" 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"><span class="lg-highlight-keyword">var</span> autoEncryptionOpts <!-- -->= <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">keyVaultNamespace</span>: <!-- -->keyVaultNamespace<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">kmsProviders</span>: <!-- -->kmsProviders<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">bypassAutoEncryption</span>: <span class="lg-highlight-literal">true</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">}<!-- -->;</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-keyword">var</span> encryptedClient <!-- -->= <span class="lg-highlight-title lg-highlight-class">Mongo</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->connectionString<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->autoEncryptionOpts</td></tr><tr class=""><td class="leafygreen-ui-7razhx">)<!-- -->;</td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-30-menu" aria-describedby="select-30-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-31" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:r4r:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":r4r:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r4r:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r4r:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_p7igpqhxz" class="leafygreen-ui-38lglc" id="_3501hkap8" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"var clientSettings = MongoClientSettings.FromConnectionString(connectionString);\nvar autoEncryptionOptions = new AutoEncryptionOptions(\n keyVaultNamespace: keyVaultNamespace,\n kmsProviders: kmsProviders,\n bypassAutoEncryption: true);\nclientSettings.AutoEncryptionOptions = autoEncryptionOptions;\nvar client = new MongoClient(clientSettings);\n","programmingLanguage":"C#"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <pre class="leafygreen-ui-11itue3" 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"><span class="lg-highlight-keyword">var</span> clientSettings = <span class="lg-highlight-title lg-highlight-class">MongoClientSettings</span>.<span class="lg-highlight-title lg-highlight-class">FromConnectionString</span>(connectionString);</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-keyword">var</span> autoEncryptionOptions = <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">AutoEncryptionOptions</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">keyVaultNamespace</span>: keyVaultNamespace,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">kmsProviders</span>: kmsProviders,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">bypassAutoEncryption</span>: <span class="lg-highlight-literal">true</span>);</td></tr><tr class=""><td class="leafygreen-ui-7razhx">clientSettings.<span class="lg-highlight-property">AutoEncryptionOptions</span> = autoEncryptionOptions;</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-keyword">var</span> client = <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">MongoClient</span>(clientSettings);</td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-33-menu" aria-describedby="select-33-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-34" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:r4s:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":r4s:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r4s:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r4s:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_c4d6gablt" class="leafygreen-ui-38lglc" id="_dnyjbqx4v" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"autoEncryptionOpts := options.AutoEncryption().\n\tSetKmsProviders(kmsProviders).\n\tSetKeyVaultNamespace(KeyVaultNamespace).\n\tSetBypassAutoEncryption(true)\nclient, err := mongo.Connect(context.TODO(), options.Client().ApplyURI(URI).SetAutoEncryptionOptions(autoEncryptionOpts))\nif err != nil {\n\treturn fmt.Errorf(\"Connect error for encrypted client: %v\", err)\n}\ndefer func() {\n\t_ = client.Disconnect(context.TODO())\n}()\n","programmingLanguage":"Golang"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <pre class="leafygreen-ui-11itue3" 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">autoEncryptionOpts <!-- -->:<!-- -->= options.<span class="lg-highlight-title lg-highlight-class">AutoEncryption</span>().</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-title lg-highlight-class">SetKmsProviders</span>(kmsProviders).</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-title lg-highlight-class">SetKeyVaultNamespace</span>(<span class="lg-highlight-title lg-highlight-class">KeyVaultNamespace</span>).</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-title lg-highlight-class">SetBypassAutoEncryption</span>(<span class="lg-highlight-literal">true</span>)</td></tr><tr class=""><td class="leafygreen-ui-7razhx">client<!-- -->, <!-- -->err := mongo.<span class="lg-highlight-title lg-highlight-class">Connect</span>(context.<span class="lg-highlight-title lg-highlight-function">TODO</span>(), options.<span class="lg-highlight-title lg-highlight-class">Client</span>().<span class="lg-highlight-title lg-highlight-class">ApplyURI</span>(<span class="lg-highlight-variable lg-highlight-constant">URI</span>).<span class="lg-highlight-title lg-highlight-class">SetAutoEncryptionOptions</span>(autoEncryptionOpts))</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-keyword">if</span> err != nil {</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-keyword">return</span> fmt.<span class="lg-highlight-title lg-highlight-class">Errorf</span>(<span class="lg-highlight-string">"Connect error for encrypted client: %v"</span>, err)</td></tr><tr class=""><td class="leafygreen-ui-7razhx">}</td></tr><tr class=""><td class="leafygreen-ui-7razhx">defer <span class="lg-highlight-title lg-highlight-function">func</span>() {</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> _ = client.<span class="lg-highlight-title lg-highlight-class">Disconnect</span>(context.<span class="lg-highlight-title lg-highlight-function">TODO</span>())</td></tr><tr class=""><td class="leafygreen-ui-7razhx">}()</td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-36-menu" aria-describedby="select-36-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-37" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:r4t:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":r4t:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r4t:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r4t:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_sgdde10ew" class="leafygreen-ui-38lglc" id="_2nli7sz9y" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"MongoClientSettings clientSettings = MongoClientSettings.builder()\n.applyConnectionString(new ConnectionString(connectionString))\n.autoEncryptionSettings(AutoEncryptionSettings.builder()\n .keyVaultNamespace(keyVaultNamespace)\n .kmsProviders(kmsProviders).bypassAutoEncryption(true)\n .build())\n.build();\nMongoClient mongoClient = MongoClients.create(clientSettings);\n","programmingLanguage":"Java"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <pre class="leafygreen-ui-11itue3" 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"><span class="lg-highlight-title lg-highlight-class">MongoClientSettings</span> clientSettings = <span class="lg-highlight-title lg-highlight-class">MongoClientSettings</span>.<span class="lg-highlight-title lg-highlight-function">builder</span>()</td></tr><tr class=""><td class="leafygreen-ui-7razhx">.<span class="lg-highlight-title lg-highlight-function">applyConnectionString</span>(<span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">ConnectionString</span>(connectionString))</td></tr><tr class=""><td class="leafygreen-ui-7razhx">.<span class="lg-highlight-title lg-highlight-function">autoEncryptionSettings</span>(<span class="lg-highlight-title lg-highlight-class">AutoEncryptionSettings</span>.<span class="lg-highlight-title lg-highlight-function">builder</span>()</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> .<span class="lg-highlight-title lg-highlight-function">keyVaultNamespace</span>(keyVaultNamespace)</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> .<span class="lg-highlight-title lg-highlight-function">kmsProviders</span>(kmsProviders).<span class="lg-highlight-title lg-highlight-function">bypassAutoEncryption</span>(<span class="lg-highlight-literal">true</span>)</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> .<span class="lg-highlight-title lg-highlight-function">build</span>())</td></tr><tr class=""><td class="leafygreen-ui-7razhx">.<span class="lg-highlight-title lg-highlight-function">build</span>();</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-title lg-highlight-class">MongoClient</span> mongoClient = <span class="lg-highlight-title lg-highlight-class">MongoClients</span>.<span class="lg-highlight-title lg-highlight-function">create</span>(clientSettings);</td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-39-menu" aria-describedby="select-39-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-40" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:r4u:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":r4u:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r4u:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r4u:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_1mad4b7l4" class="" id="_mp4ylj5es" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"const client = new MongoClient(connectionString, {\n monitorCommands: true,\n autoEncryption: {\n keyVaultNamespace,\n kmsProviders,\n bypassAutoEncryption: true,\n },\n});\n","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <pre class="leafygreen-ui-11itue3" 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"><span class="lg-highlight-keyword">const</span> client <!-- -->= <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">MongoClient</span>(<!-- -->connectionString<!-- -->, <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">monitorCommands</span>: <span class="lg-highlight-literal">true</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">autoEncryption</span>: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->keyVaultNamespace<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->kmsProviders<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">bypassAutoEncryption</span>: <span class="lg-highlight-literal">true</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->}<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">})<!-- -->;</td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-42-menu" aria-describedby="select-42-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-43" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:r4v:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":r4v:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r4v:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r4v:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_0qao6wymz" class="leafygreen-ui-38lglc" id="_yz8cihtki" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"auto_encryption_opts = AutoEncryptionOpts(\n kms_providers=kms_providers,\n key_vault_namespace=key_vault_namespace,\n bypass_auto_encryption=True,\n)\nclient = MongoClient(auto_encryption_opts=auto_encryption_opts)\n","programmingLanguage":"Python"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <pre class="leafygreen-ui-11itue3" 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">auto_encryption_opts = <span class="lg-highlight-title lg-highlight-class">AutoEncryptionOpts</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> kms_providers=kms_providers,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> key_vault_namespace=key_vault_namespace,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> bypass_auto_encryption=<span class="lg-highlight-title lg-highlight-class">True</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">)</td></tr><tr class=""><td class="leafygreen-ui-7razhx">client = <span class="lg-highlight-title lg-highlight-class">MongoClient</span>(auto_encryption_opts=auto_encryption_opts)</td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-45-menu" aria-describedby="select-45-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-46" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:r50:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":r50:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r50:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r50:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> </div> </div> <span class="leafygreen-ui-1qnjd6d" id="std-label-csfle-fundamentals-manual-encryption-example"> </span> </section> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Example <a class="headerlink leafygreen-ui-1kepx47" href="#example" 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="example"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> Assume you want to insert documents with the following structure into your MongoDB instance: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{\n \"name\": \"&lt;name&gt;\",\n \"age\": &lt;age&gt;,\n \"favorite-foods\": [\"&lt;array&gt;\"]\n}\n","programmingLanguage":"JSON"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" tabindex="-1"><code class="lg-highlight-hljs-light json leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-punctuation">{</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">"name"</span><span class="lg-highlight-punctuation">:</span> <span class="lg-highlight-string">"&lt;name of person&gt;"</span><span class="lg-highlight-punctuation">,</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">"age"</span><span class="lg-highlight-punctuation">:</span> &lt;age of person&gt;<span class="lg-highlight-punctuation">,</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">"favorite-foods"</span><span class="lg-highlight-punctuation">:</span> <span class="lg-highlight-punctuation">[</span><span class="lg-highlight-string">"&lt;array of foods&gt;"</span><span class="lg-highlight-punctuation">]</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-punctuation">}</span></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> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"HowTo","steps":[{"@type":"HowToStep","text":"In this example, you use the same MongoClient instance to access your\nKey Vault collection and to read and write encrypted data.The following code snippets show how to create a MongoClient instance:","name":"Create a MongoClient Instance"},{"@type":"HowToStep","text":"The following code snippets show how to create a ClientEncryption\ninstance:The MongoDB Python driver requires that you specify the\nCodecOptions with which you would like to encrypt and\ndecrypt your documents.Specify the CodecOptions you have configured on the\nMongoClient, Database, or Collection with which\nyou are writing encrypted and decrypted application data to MongoDB.","name":"Create a ClientEncryption Instance"},{"@type":"HowToStep","text":"You want to encrypt the fields of your document using the\nfollowing algorithms:Field NameEncryption AlgorithmBSON Type of FieldnameDeterministicStringageNo encryptionIntfavorite-foodsRandomArrayThe following code snippets show how to manually encrypt the fields in\nyour document and insert your document into MongoDB:The dataKeyId variable in the following examples refers to a\nData Encryption Key (DEK). To learn how to generate a DEK with your Local Key\nProvider, see the Quick Start. To learn how to create a\nDEK with a specific Key Management System, see Tutorials.The dataKeyId variable in the following examples refers to a\nData Encryption Key (DEK). To learn how to generate a DEK with your Local Key\nProvider, see the Quick Start. To learn how to create a\nDEK with a specific Key Management System, see Tutorials.The dataKeyId variable in the following examples refers to a\nData Encryption Key (DEK). To learn how to generate a DEK with your Local Key\nProvider, see the Quick Start. To learn how to create a\nDEK with a specific Key Management System, see Tutorials.The dataKeyId variable in the following examples refers to a\nData Encryption Key (DEK). To learn how to generate a DEK with your Local Key\nProvider, see the Quick Start. To learn how to create a\nDEK with a specific Key Management System, see Tutorials.The dataKeyId variable in the following examples refers to a\nData Encryption Key (DEK). To learn how to generate a DEK with your Local Key\nProvider, see the Quick Start. To learn how to create a\nDEK with a specific Key Management System, see Tutorials.The data_key_id variable in the following examples refers to a\nData Encryption Key (DEK). To learn how to generate a DEK with your Local Key\nProvider, see the Quick Start. To learn how to create a\nDEK with a specific Key Management System, see Tutorials.","name":"Encrypt Fields and Insert"},{"@type":"HowToStep","text":"The following code snippets show how to retrieve your inserted document\nand manually decrypt the encrypted fields:","name":"Retrieve Document and Decrypt Fields"}],"name":"Example","image":"https://webimages.mongodb.com/_com_assets/cms/kuyj2focmkbxv7gh3-stacked_default_slate_blue.svg?auto=format%252Ccompress"} </script> <div class="css-4nyere eccljxs0"> <div class="css-1nuklj8 e1ckbxcu1"> <div class="css-18fui5z e1ckbxcu0"> <div class="css-19lsqsq e1ckbxcu2"> 1 </div> </div> <div class="css-1ed38mk"> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Create a MongoClient Instance <a class="headerlink leafygreen-ui-1kepx47" href="#create-a-mongoclient-instance" 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="create-a-mongoclient-instance"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> In this example, you use the same <code class="leafygreen-ui-1l06pbn"> MongoClient </code> instance to access your Key Vault collection and to read and write encrypted data. </p> <p class="leafygreen-ui-1kp3ins"> The following code snippets show how to create a <code class="leafygreen-ui-1l06pbn"> MongoClient </code> instance: </p> <div aria-hidden="true"> </div> <div class="leafygreen-ui-f2qztv" data-lgid="lg-tabs"> <div class="leafygreen-ui-jp7pox" id="tabs-13"> <div aria-label="Tabs to describe usage of drivers" aria-orientation="horizontal" class="leafygreen-ui-m8p1vb lg-ui-tab-list-0000" data-lgid="lg-tabs-tab_list" role="tablist"> <button aria-controls="_bm7uhqjjw" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_hddrrl2c9" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> MongoDB Shell </div> </button> <button aria-controls="_yas65aamb" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_q6qvhf5pt" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> C# </div> </button> <button aria-controls="_3jaet0vug" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_jbzieedez" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Go </div> </button> <button aria-controls="_smxmkkyc2" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_1c1799eja" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Java (Sync) </div> </button> <button aria-controls="_51p8zipag" aria-selected="true" class="leafygreen-ui-1l773z1" data-text="" id="_vza1qgmzf" name="" role="tab" tabindex="0"> <div class="leafygreen-ui-1nxuzmg"> Node.js </div> </button> <button aria-controls="_xwhvgclve" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_wdw9u0e1f" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Python </div> </button> </div> <div class="leafygreen-ui-ov1ktg"> <div class="leafygreen-ui-1sg2lsz"> </div> </div> </div> <div class="lg-ui-tab-panels-0000" data-lgid="lg-tabs-tab_panels"> <div> <div aria-labelledby="_hqwq04c4q" class="leafygreen-ui-38lglc" id="_b6hbrykl9" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"const autoEncryptionOpts = {\n keyVaultNamespace: keyVaultNamespace,\n kmsProviders: kmsProviders,\n};\nconst encryptedClient = Mongo(connectionString, autoEncryptionOpts);","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <pre class="leafygreen-ui-11itue3" 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"><span class="lg-highlight-keyword">const</span> autoEncryptionOpts <!-- -->= <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">keyVaultNamespace</span>: <!-- -->keyVaultNamespace<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">kmsProviders</span>: <!-- -->kmsProviders<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">}<!-- -->;</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-keyword">const</span> encryptedClient <!-- -->= <span class="lg-highlight-title lg-highlight-class">Mongo</span>(<!-- -->connectionString<!-- -->, <!-- -->autoEncryptionOpts)<!-- -->;</td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-49-menu" aria-describedby="select-49-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-50" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:r51:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":r51:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r51:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r51:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_exax4v8q3" class="leafygreen-ui-38lglc" id="_0jk0x2s25" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"var client = new MongoClient(connectionString);","programmingLanguage":"C#"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <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"><span class="lg-highlight-keyword">var</span> client = <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">MongoClient</span>(connectionString);</td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-52-menu" aria-describedby="select-52-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-53" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:r52:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":r52:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r52:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r52:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_3pfena0tk" class="leafygreen-ui-38lglc" id="_45gs5562z" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"client, err := mongo.Connect(context.TODO(), options.Client().ApplyURI(URI))\nif err != nil {\n\tpanic(fmt.Errorf(\"Client connect error %v\", err))\n}","programmingLanguage":"Golang"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <pre class="leafygreen-ui-11itue3" 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">client<!-- -->, <!-- -->err := mongo.<span class="lg-highlight-title lg-highlight-class">Connect</span>(context.<span class="lg-highlight-title lg-highlight-function">TODO</span>(), options.<span class="lg-highlight-title lg-highlight-class">Client</span>().<span class="lg-highlight-title lg-highlight-class">ApplyURI</span>(<span class="lg-highlight-variable lg-highlight-constant">URI</span>))</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-keyword">if</span> err != nil {</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-title lg-highlight-function">panic</span>(fmt.<span class="lg-highlight-title lg-highlight-class">Errorf</span>(<span class="lg-highlight-string">"Client connect error %v"</span>, err))</td></tr><tr class=""><td class="leafygreen-ui-7razhx">}</td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-55-menu" aria-describedby="select-55-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-56" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:r53:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":r53:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r53:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r53:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_fjvwfbjuw" class="leafygreen-ui-38lglc" id="_z2p7azjd2" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"MongoClient client = MongoClients.create(connectionString);","programmingLanguage":"Java"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <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"><span class="lg-highlight-title lg-highlight-class">MongoClient</span> client = <span class="lg-highlight-title lg-highlight-class">MongoClients</span>.<span class="lg-highlight-title lg-highlight-function">create</span>(connectionString);</td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-58-menu" aria-describedby="select-58-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-59" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:r54:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":r54:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r54:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r54:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_236nsmy29" class="" id="_xzrx1l349" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"const client = new MongoClient(connectionString);","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <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"><span class="lg-highlight-keyword">const</span> client <!-- -->= <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">MongoClient</span>(<!-- -->connectionString)<!-- -->;</td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-61-menu" aria-describedby="select-61-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-62" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:r55:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":r55:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r55:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r55:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_j45pvrivv" class="leafygreen-ui-38lglc" id="_kzdka1l5k" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":" client = MongoClient(your_connection_uri)","programmingLanguage":"Python"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <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"> client = <span class="lg-highlight-title lg-highlight-class">MongoClient</span>(your_connection_uri)</td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-64-menu" aria-describedby="select-64-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-65" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:r56:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":r56:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r56:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r56:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> </div> </div> </section> </div> </div> <div class="css-1nuklj8 e1ckbxcu1"> <div class="css-18fui5z e1ckbxcu0"> <div class="css-19lsqsq e1ckbxcu2"> 2 </div> </div> <div class="css-1ed38mk"> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Create a ClientEncryption Instance <a class="headerlink leafygreen-ui-1kepx47" href="#create-a-clientencryption-instance-1" 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="create-a-clientencryption-instance-1"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> The following code snippets show how to create a <code class="leafygreen-ui-1l06pbn"> ClientEncryption </code> instance: </p> <div aria-hidden="true"> </div> <div class="leafygreen-ui-f2qztv" data-lgid="lg-tabs"> <div class="leafygreen-ui-jp7pox" id="tabs-15"> <div aria-label="Tabs to describe usage of drivers" aria-orientation="horizontal" class="leafygreen-ui-m8p1vb lg-ui-tab-list-0000" data-lgid="lg-tabs-tab_list" role="tablist"> <button aria-controls="_3urg8xefx" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_f56mitox1" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> MongoDB Shell </div> </button> <button aria-controls="_uklu1jvtc" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_jzsznblql" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> C# </div> </button> <button aria-controls="_7m6kdcpps" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_ttnz1oi0t" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Go </div> </button> <button aria-controls="_3iltuu3ao" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_7h6j5ne6b" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Java (Sync) </div> </button> <button aria-controls="_t4n4067a6" aria-selected="true" class="leafygreen-ui-1l773z1" data-text="" id="_m9d9a5wo6" name="" role="tab" tabindex="0"> <div class="leafygreen-ui-1nxuzmg"> Node.js </div> </button> <button aria-controls="_vzyaa7blp" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_e6vd47sl1" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Python </div> </button> </div> <div class="leafygreen-ui-ov1ktg"> <div class="leafygreen-ui-1sg2lsz"> </div> </div> </div> <div class="lg-ui-tab-panels-0000" data-lgid="lg-tabs-tab_panels"> <div> <div aria-labelledby="_6l619s3q6" class="leafygreen-ui-38lglc" id="_c3n24fggx" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"const clientEncryption = encryptedClient.getClientEncryption();","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <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"><span class="lg-highlight-keyword">const</span> clientEncryption <!-- -->= <!-- -->encryptedClient.<span class="lg-highlight-title lg-highlight-function">getClientEncryption</span>(<!-- -->)<!-- -->;</td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-67-menu" aria-describedby="select-67-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-68" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:r57:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":r57:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r57:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r57:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_cn09svs0w" class="leafygreen-ui-38lglc" id="_opbyoo0ru" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"var collection = client.GetDatabase(db).GetCollection&lt;bsondocument&gt;(coll);\nvar clientEncryptionOptions = new ClientEncryptionOptions(\n keyVaultClient: client,\n keyVaultNamespace: keyVaultNamespace,\n kmsProviders: kmsProviders);\nvar clientEncryption = new ClientEncryption(clientEncryptionOptions);","programmingLanguage":"C#"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <pre class="leafygreen-ui-11itue3" 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"><span class="lg-highlight-keyword">var</span> collection = client.<span class="lg-highlight-title lg-highlight-class">GetDatabase</span>(db).<span class="lg-highlight-property">GetCollection</span>&lt;<span class="lg-highlight-title lg-highlight-class">BsonDocument</span>&gt;(coll);</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-keyword">var</span> clientEncryptionOptions = <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">ClientEncryptionOptions</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">keyVaultClient</span>: client,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">keyVaultNamespace</span>: keyVaultNamespace,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">kmsProviders</span>: kmsProviders);</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-keyword">var</span> clientEncryption = <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">ClientEncryption</span>(clientEncryptionOptions);</td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-70-menu" aria-describedby="select-70-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-71" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:r58:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":r58:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r58:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r58:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_an28zawjt" class="leafygreen-ui-38lglc" id="_m0qs1zna5" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"coll := client.Database(DbName).Collection(CollName)\nclientEncryptionOpts := options.ClientEncryption().SetKeyVaultNamespace(KeyVaultNamespace).SetKmsProviders(kmsProviders)\nclientEnc, err := mongo.NewClientEncryption(client, clientEncryptionOpts)\nif err != nil {\n\tpanic(fmt.Errorf(\"NewClientEncryption error %v\", err))\n}\ndefer func() {\n\t_ = clientEnc.Close(context.TODO())\n}()","programmingLanguage":"Golang"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <pre class="leafygreen-ui-11itue3" 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">coll <!-- -->:<!-- -->= client.<span class="lg-highlight-title lg-highlight-class">Database</span>(<span class="lg-highlight-title lg-highlight-class">DbName</span>).<span class="lg-highlight-title lg-highlight-class">Collection</span>(<span class="lg-highlight-title lg-highlight-class">CollName</span>)</td></tr><tr class=""><td class="leafygreen-ui-7razhx">clientEncryptionOpts <!-- -->:<!-- -->= options.<span class="lg-highlight-title lg-highlight-class">ClientEncryption</span>().<span class="lg-highlight-title lg-highlight-class">SetKeyVaultNamespace</span>(<span class="lg-highlight-title lg-highlight-class">KeyVaultNamespace</span>).<span class="lg-highlight-title lg-highlight-class">SetKmsProviders</span>(kmsProviders)</td></tr><tr class=""><td class="leafygreen-ui-7razhx">clientEnc<!-- -->, <!-- -->err := mongo.<span class="lg-highlight-title lg-highlight-class">NewClientEncryption</span>(client, clientEncryptionOpts)</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-keyword">if</span> err != nil {</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-title lg-highlight-function">panic</span>(fmt.<span class="lg-highlight-title lg-highlight-class">Errorf</span>(<span class="lg-highlight-string">"NewClientEncryption error %v"</span>, err))</td></tr><tr class=""><td class="leafygreen-ui-7razhx">}</td></tr><tr class=""><td class="leafygreen-ui-7razhx">defer <span class="lg-highlight-title lg-highlight-function">func</span>() {</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> _ = clientEnc.<span class="lg-highlight-title lg-highlight-class">Close</span>(context.<span class="lg-highlight-title lg-highlight-function">TODO</span>())</td></tr><tr class=""><td class="leafygreen-ui-7razhx">}()</td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-73-menu" aria-describedby="select-73-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-74" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:r59:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":r59:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r59:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r59:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_u40xwl8c8" class="leafygreen-ui-38lglc" id="_157gvow1w" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"MongoCollection&lt;document&gt; collection = client.getDatabase(db).getCollection(coll);\nClientEncryptionSettings clientEncryptionSettings = ClientEncryptionSettings.builder()\n .keyVaultMongoClientSettings(MongoClientSettings.builder()\n .applyConnectionString(new ConnectionString(connectionString))\n .build())\n .keyVaultNamespace(keyVaultNamespace)\n .kmsProviders(kmsProviders)\n .build();\nClientEncryption clientEncryption = ClientEncryptions.create(clientEncryptionSettings);","programmingLanguage":"Java"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <pre class="leafygreen-ui-11itue3" 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"><span class="lg-highlight-title lg-highlight-class">MongoCollection</span>&lt;<span class="lg-highlight-title lg-highlight-class">Document</span>&gt; collection = client.<span class="lg-highlight-title lg-highlight-function">getDatabase</span>(db).<span class="lg-highlight-title lg-highlight-function">getCollection</span>(coll);</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-title lg-highlight-class">ClientEncryptionSettings</span> clientEncryptionSettings = <span class="lg-highlight-title lg-highlight-class">ClientEncryptionSettings</span>.<span class="lg-highlight-title lg-highlight-function">builder</span>()</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> .<span class="lg-highlight-title lg-highlight-function">keyVaultMongoClientSettings</span>(<span class="lg-highlight-title lg-highlight-class">MongoClientSettings</span>.<span class="lg-highlight-title lg-highlight-function">builder</span>()</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> .<span class="lg-highlight-title lg-highlight-function">applyConnectionString</span>(<span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">ConnectionString</span>(connectionString))</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> .<span class="lg-highlight-title lg-highlight-function">build</span>())</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> .<span class="lg-highlight-title lg-highlight-function">keyVaultNamespace</span>(keyVaultNamespace)</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> .<span class="lg-highlight-title lg-highlight-function">kmsProviders</span>(kmsProviders)</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> .<span class="lg-highlight-title lg-highlight-function">build</span>();</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-title lg-highlight-class">ClientEncryption</span> clientEncryption = <span class="lg-highlight-title lg-highlight-class">ClientEncryptions</span>.<span class="lg-highlight-title lg-highlight-function">create</span>(clientEncryptionSettings);</td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-76-menu" aria-describedby="select-76-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-77" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:r5a:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":r5a:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r5a:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r5a:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_jsc3usyre" class="" id="_74gqt8j7j" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"const collection = client.db(db).collection(coll);\nconst encryption = new ClientEncryption(client, {\n keyVaultNamespace,\n kmsProviders,\n});","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <pre class="leafygreen-ui-11itue3" 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"><span class="lg-highlight-keyword">const</span> collection <!-- -->= <!-- -->client.<span class="lg-highlight-title lg-highlight-function">db</span>(<!-- -->db).<span class="lg-highlight-title lg-highlight-function">collection</span>(<!-- -->coll)<!-- -->;</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-keyword">const</span> encryption <!-- -->= <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">ClientEncryption</span>(<!-- -->client<!-- -->, <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->keyVaultNamespace<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->kmsProviders<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">})<!-- -->;</td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-79-menu" aria-describedby="select-79-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-80" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:r5b:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":r5b:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r5b:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r5b:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_ionnm5wiv" class="leafygreen-ui-38lglc" id="_upg3ft178" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"coll = client.employees.foods\nclient_encryption = ClientEncryption(\n kms_providers,\n \"encryption.___keyVault\",\n client,\n coll.codec_options,\n)","programmingLanguage":"Python"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <pre class="leafygreen-ui-11itue3" 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">coll = client.<span class="lg-highlight-property">employees</span>.<span class="lg-highlight-property">foods</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx">client_encryption = <span class="lg-highlight-title lg-highlight-class">ClientEncryption</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> kms_providers,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"encryption.___keyVault"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> client,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> coll.<span class="lg-highlight-property">codec_options</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">)</td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-82-menu" aria-describedby="select-82-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-83" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:r5c:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":r5c:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r5c:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r5c:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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-15mdk4" role="note"> <h2 class="leafygreen-ui-6n7b7d"> Note </h2> <h3 class="leafygreen-ui-144d5kf"> <strong> CodecOptions </strong> </h3> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> The MongoDB Python driver requires that you specify the <code class="leafygreen-ui-1l06pbn"> CodecOptions </code> with which you would like to encrypt and decrypt your documents. </p> <p class="leafygreen-ui-1kp3ins"> Specify the <code class="leafygreen-ui-1l06pbn"> CodecOptions </code> you have configured on the <code class="leafygreen-ui-1l06pbn"> MongoClient </code> , <code class="leafygreen-ui-1l06pbn"> Database </code> , or <code class="leafygreen-ui-1l06pbn"> Collection </code> with which you are writing encrypted and decrypted application data to MongoDB. </p> </div> </div> </div> </div> </div> </div> </div> </section> </div> </div> <div class="css-1nuklj8 e1ckbxcu1"> <div class="css-18fui5z e1ckbxcu0"> <div class="css-19lsqsq e1ckbxcu2"> 3 </div> </div> <div class="css-1ed38mk"> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Encrypt Fields and Insert <a class="headerlink leafygreen-ui-1kepx47" href="#encrypt-fields-and-insert" 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="encrypt-fields-and-insert"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> You want to encrypt the fields of your document using the following algorithms: </p> <div class="leafygreen-ui-skkc39" tabindex="0"> <table class="leafygreen-ui-hr8lsv"> <colgroup> <col style="width:33%"/> <col style="width:34%"/> <col style="width:33%"/> </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> Field Name </div> </div> </th> <th class="leafygreen-ui-13uteka" role="columnheader" scope="col"> <div class="leafygreen-ui-ui0te9"> <div> Encryption Algorithm </div> </div> </th> <th class="leafygreen-ui-13uteka" role="columnheader" scope="col"> <div class="leafygreen-ui-ui0te9"> <div> BSON Type of Field </div> </div> </th> </tr> </thead> <tbody> <tr class=""> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> name </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Deterministic </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> String </div> </div> </td> </tr> <tr class=""> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> age </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> No encryption </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Int </div> </div> </td> </tr> <tr class=""> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> favorite-foods </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Random </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Array </div> </div> </td> </tr> </tbody> </table> </div> <p class="leafygreen-ui-1kp3ins"> The following code snippets show how to manually encrypt the fields in your document and insert your document into MongoDB: </p> <div aria-hidden="true"> </div> <div class="leafygreen-ui-f2qztv" data-lgid="lg-tabs"> <div class="leafygreen-ui-jp7pox" id="tabs-17"> <div aria-label="Tabs to describe usage of drivers" aria-orientation="horizontal" class="leafygreen-ui-m8p1vb lg-ui-tab-list-0000" data-lgid="lg-tabs-tab_list" role="tablist"> <button aria-controls="_r1c4gz2xq" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_kjxxagsq5" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> MongoDB Shell </div> </button> <button aria-controls="_kzvv1euk0" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_3ch6kvijx" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> C# </div> </button> <button aria-controls="_ro5l8052t" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_74vff6o4p" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Go </div> </button> <button aria-controls="_ggh59n8t4" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_g1s587ve9" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Java (Sync) </div> </button> <button aria-controls="_a7c1jdaez" aria-selected="true" class="leafygreen-ui-1l773z1" data-text="" id="_pgc20vwub" name="" role="tab" tabindex="0"> <div class="leafygreen-ui-1nxuzmg"> Node.js </div> </button> <button aria-controls="_vbn6ab5y7" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_dl06iujrg" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Python </div> </button> </div> <div class="leafygreen-ui-ov1ktg"> <div class="leafygreen-ui-1sg2lsz"> </div> </div> </div> <div class="lg-ui-tab-panels-0000" data-lgid="lg-tabs-tab_panels"> <div> <div aria-labelledby="_moctsvii9" class="leafygreen-ui-38lglc" id="_pvukzvgd3" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <div class="leafygreen-ui-15mdk4" role="note"> <h2 class="leafygreen-ui-6n7b7d"> Note </h2> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> The <code class="leafygreen-ui-1l06pbn"> dataKeyId </code> variable in the following examples refers to a Data Encryption Key (DEK). To learn how to generate a DEK with your Local Key Provider, see the <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/csfle/quick-start/#std-label-csfle-quick-start-create-dek"> Quick Start </a> . To learn how to create a DEK with a specific Key Management System, see <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/csfle/tutorials/#std-label-csfle-tutorials"> Tutorials <!-- --> . </a> </p> </div> </div> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"const encName = clientEncryption.encrypt(\n dataKeyId,\n \"Greg\",\n \"AEAD_AES_256_CBC_HMAC_SHA_512-Deterministic\"\n);\nconst encFoods = clientEncryption.encrypt(\n dataKeyId,\n [\"Cheese\", \"Grapes\"],\n \"AEAD_AES_256_CBC_HMAC_SHA_512-Random\"\n);\ndb.getSiblingDB(database).getCollection(collection).insertOne({\n name: encName,\n foods: encFoods,\n});","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <pre class="leafygreen-ui-11itue3" 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"><span class="lg-highlight-keyword">const</span> encName <!-- -->= <!-- -->clientEncryption.<span class="lg-highlight-title lg-highlight-function">encrypt</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->dataKeyId<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"Greg"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"AEAD_AES_256_CBC_HMAC_SHA_512-Deterministic"</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx">)<!-- -->;</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-keyword">const</span> encFoods <!-- -->= <!-- -->clientEncryption.<span class="lg-highlight-title lg-highlight-function">encrypt</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->dataKeyId<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->[<span class="lg-highlight-string">"Cheese"</span>, <span class="lg-highlight-string">"Grapes"</span>]<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"AEAD_AES_256_CBC_HMAC_SHA_512-Random"</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx">)<!-- -->;</td></tr><tr class=""><td class="leafygreen-ui-7razhx">db.<span class="lg-highlight-title lg-highlight-function">getSiblingDB</span>(<!-- -->database).<span class="lg-highlight-title lg-highlight-function">getCollection</span>(<!-- -->collection).<span class="lg-highlight-title lg-highlight-function">insertOne</span>(<!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">name</span>: <!-- -->encName<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">foods</span>: <!-- -->encFoods<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">})<!-- -->;</td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-85-menu" aria-describedby="select-85-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-86" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:r5d:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":r5d:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r5d:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r5d:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_vwtne5lcw" class="leafygreen-ui-38lglc" id="_an0tzo25z" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <div class="leafygreen-ui-15mdk4" role="note"> <h2 class="leafygreen-ui-6n7b7d"> Note </h2> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> The <code class="leafygreen-ui-1l06pbn"> dataKeyId </code> variable in the following examples refers to a Data Encryption Key (DEK). To learn how to generate a DEK with your Local Key Provider, see the <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/csfle/quick-start/#std-label-csfle-quick-start-create-dek"> Quick Start </a> . To learn how to create a DEK with a specific Key Management System, see <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/csfle/tutorials/#std-label-csfle-tutorials"> Tutorials <!-- --> . </a> </p> </div> </div> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"var encryptedName = clientEncryption.Encrypt(\n \"Greg\",\n new EncryptOptions(algorithm: \"AEAD_AES_256_CBC_HMAC_SHA_512-Deterministic\", keyId: dataKeyId),\n CancellationToken.None);\nvar encryptedFoods = clientEncryption.Encrypt(\n new BsonArray { \"Cheese\", \"Grapes\" },\n new EncryptOptions(algorithm: \"AEAD_AES_256_CBC_HMAC_SHA_512-Random\", keyId: dataKeyId),\n CancellationToken.None);\ncollection.InsertOne(new BsonDocument { { \"name\", encryptedName }, { \"age\", 83 }, { \"foods\", encryptedFoods } });","programmingLanguage":"C#"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <pre class="leafygreen-ui-11itue3" 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"><span class="lg-highlight-keyword">var</span> encryptedName = clientEncryption.<span class="lg-highlight-title lg-highlight-class">Encrypt</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"Greg"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">EncryptOptions</span>(<span class="lg-highlight-attr">algorithm</span>: <span class="lg-highlight-string">"AEAD_AES_256_CBC_HMAC_SHA_512-Deterministic"</span>, <span class="lg-highlight-attr">keyId</span>: dataKeyId),</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-title lg-highlight-class">CancellationToken</span>.<span class="lg-highlight-property">None</span>);</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-keyword">var</span> encryptedFoods = clientEncryption.<span class="lg-highlight-title lg-highlight-class">Encrypt</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">BsonArray</span> { <span class="lg-highlight-string">"Cheese"</span>, <span class="lg-highlight-string">"Grapes"</span> },</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">EncryptOptions</span>(<span class="lg-highlight-attr">algorithm</span>: <span class="lg-highlight-string">"AEAD_AES_256_CBC_HMAC_SHA_512-Random"</span>, <span class="lg-highlight-attr">keyId</span>: dataKeyId),</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-title lg-highlight-class">CancellationToken</span>.<span class="lg-highlight-property">None</span>);</td></tr><tr class=""><td class="leafygreen-ui-7razhx">collection.<span class="lg-highlight-title lg-highlight-class">InsertOne</span>(<span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">BsonDocument</span> { { <span class="lg-highlight-string">"name"</span>, encryptedName }, { <span class="lg-highlight-string">"age"</span>, <span class="lg-highlight-number">83</span> }, { <span class="lg-highlight-string">"foods"</span>, encryptedFoods } });</td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-88-menu" aria-describedby="select-88-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-89" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:r5e:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":r5e:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r5e:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r5e:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_gdj7kxvkc" class="leafygreen-ui-38lglc" id="_dpigwa3ce" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <div class="leafygreen-ui-15mdk4" role="note"> <h2 class="leafygreen-ui-6n7b7d"> Note </h2> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> The <code class="leafygreen-ui-1l06pbn"> dataKeyId </code> variable in the following examples refers to a Data Encryption Key (DEK). To learn how to generate a DEK with your Local Key Provider, see the <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/csfle/quick-start/#std-label-csfle-quick-start-create-dek"> Quick Start </a> . To learn how to create a DEK with a specific Key Management System, see <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/csfle/tutorials/#std-label-csfle-tutorials"> Tutorials <!-- --> . </a> </p> </div> </div> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"nameRawValueType, nameRawValueData, err := bson.MarshalValue(\"Greg\")\nif err != nil {\n\tpanic(err)\n}\nnameRawValue := bson.RawValue{Type: nameRawValueType, Value: nameRawValueData}\nnameEncryptionOpts := options.Encrypt().\n\tSetAlgorithm(\"AEAD_AES_256_CBC_HMAC_SHA_512-Deterministic\").\n\tSetKeyID(dataKeyId)\nnameEncryptedField, err := clientEnc.Encrypt(\n\tcontext.TODO(),\n\tnameRawValue,\n\tnameEncryptionOpts)\nif err != nil {\n\tpanic(err)\n}\nfoodsRawValueType, foodsRawValueData, err := bson.MarshalValue(bson.A{\"Grapes\", \"Cheese\"})\nif err != nil {\n\tpanic(err)\n}\nfoodsRawValue := bson.RawValue{Type: foodsRawValueType, Value: foodsRawValueData}\nencryptionOpts := options.Encrypt().\n\tSetAlgorithm(\"AEAD_AES_256_CBC_HMAC_SHA_512-Random\").\n\tSetKeyID(dataKeyId)\nfoodsEncryptedField, err := clientEnc.Encrypt(\n\tcontext.TODO(),\n\tfoodsRawValue,\n\tencryptionOpts)\nif err != nil {\n\tpanic(err)\n}\n\n_, err = coll.InsertOne(\n\tcontext.TODO(),\n\tbson.D{{\"name\", nameEncryptedField}, {\"foods\", foodsEncryptedField}, {\"age\", 83}})\nif err != nil {\n\tpanic(err)\n}","programmingLanguage":"Golang"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <pre class="leafygreen-ui-11itue3" 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">nameRawValueType<!-- -->, <!-- -->nameRawValueData, err := bson.<span class="lg-highlight-title lg-highlight-class">MarshalValue</span>(<span class="lg-highlight-string">"Greg"</span>)</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-keyword">if</span> err != nil {</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-title lg-highlight-function">panic</span>(err)</td></tr><tr class=""><td class="leafygreen-ui-7razhx">}</td></tr><tr class=""><td class="leafygreen-ui-7razhx">nameRawValue <!-- -->:<!-- -->= bson.<span class="lg-highlight-property">RawValue</span>{<span class="lg-highlight-title lg-highlight-class">Type</span>: nameRawValueType, <span class="lg-highlight-title lg-highlight-class">Value</span>: nameRawValueData}</td></tr><tr class=""><td class="leafygreen-ui-7razhx">nameEncryptionOpts <!-- -->:<!-- -->= options.<span class="lg-highlight-title lg-highlight-class">Encrypt</span>().</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-title lg-highlight-class">SetAlgorithm</span>(<span class="lg-highlight-string">"AEAD_AES_256_CBC_HMAC_SHA_512-Deterministic"</span>).</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-title lg-highlight-class">SetKeyID</span>(dataKeyId)</td></tr><tr class=""><td class="leafygreen-ui-7razhx">nameEncryptedField<!-- -->, <!-- -->err := clientEnc.<span class="lg-highlight-title lg-highlight-class">Encrypt</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> context.<span class="lg-highlight-title lg-highlight-function">TODO</span>(),</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> nameRawValue,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> nameEncryptionOpts)</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-keyword">if</span> err != nil {</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-title lg-highlight-function">panic</span>(err)</td></tr><tr class=""><td class="leafygreen-ui-7razhx">}</td></tr><tr class=""><td class="leafygreen-ui-7razhx">foodsRawValueType<!-- -->, <!-- -->foodsRawValueData, err := bson.<span class="lg-highlight-title lg-highlight-class">MarshalValue</span>(bson.<span class="lg-highlight-property">A</span>{<span class="lg-highlight-string">"Grapes"</span>, <span class="lg-highlight-string">"Cheese"</span>})</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-keyword">if</span> err != nil {</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-title lg-highlight-function">panic</span>(err)</td></tr><tr class=""><td class="leafygreen-ui-7razhx">}</td></tr><tr class=""><td class="leafygreen-ui-7razhx">foodsRawValue <!-- -->:<!-- -->= bson.<span class="lg-highlight-property">RawValue</span>{<span class="lg-highlight-title lg-highlight-class">Type</span>: foodsRawValueType, <span class="lg-highlight-title lg-highlight-class">Value</span>: foodsRawValueData}</td></tr><tr class=""><td class="leafygreen-ui-7razhx">encryptionOpts <!-- -->:<!-- -->= options.<span class="lg-highlight-title lg-highlight-class">Encrypt</span>().</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-title lg-highlight-class">SetAlgorithm</span>(<span class="lg-highlight-string">"AEAD_AES_256_CBC_HMAC_SHA_512-Random"</span>).</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-title lg-highlight-class">SetKeyID</span>(dataKeyId)</td></tr><tr class=""><td class="leafygreen-ui-7razhx">foodsEncryptedField<!-- -->, <!-- -->err := clientEnc.<span class="lg-highlight-title lg-highlight-class">Encrypt</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> context.<span class="lg-highlight-title lg-highlight-function">TODO</span>(),</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> foodsRawValue,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> encryptionOpts)</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-keyword">if</span> err != nil {</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-title lg-highlight-function">panic</span>(err)</td></tr><tr class=""><td class="leafygreen-ui-7razhx">}</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><div class="leafygreen-ui-ihxujy"></div></td></tr><tr class=""><td class="leafygreen-ui-7razhx">_, err = coll.<span class="lg-highlight-title lg-highlight-class">InsertOne</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> context.<span class="lg-highlight-title lg-highlight-function">TODO</span>(),</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> bson.<span class="lg-highlight-property">D</span>{{<span class="lg-highlight-string">"name"</span>, nameEncryptedField}, {<span class="lg-highlight-string">"foods"</span>, foodsEncryptedField}, {<span class="lg-highlight-string">"age"</span>, <span class="lg-highlight-number">83</span>}})</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-keyword">if</span> err != nil {</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-title lg-highlight-function">panic</span>(err)</td></tr><tr class=""><td class="leafygreen-ui-7razhx">}</td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-91-menu" aria-describedby="select-91-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-92" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:r5f:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":r5f:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r5f:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r5f:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_wx7gqy3x3" class="leafygreen-ui-38lglc" id="_fm70u87cv" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <div class="leafygreen-ui-15mdk4" role="note"> <h2 class="leafygreen-ui-6n7b7d"> Note </h2> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> The <code class="leafygreen-ui-1l06pbn"> dataKeyId </code> variable in the following examples refers to a Data Encryption Key (DEK). To learn how to generate a DEK with your Local Key Provider, see the <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/csfle/quick-start/#std-label-csfle-quick-start-create-dek"> Quick Start </a> . To learn how to create a DEK with a specific Key Management System, see <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/csfle/tutorials/#std-label-csfle-tutorials"> Tutorials <!-- --> . </a> </p> </div> </div> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"BsonBinary encryptedName = clientEncryption.encrypt(new BsonString(\"Greg\"), new EncryptOptions(\"AEAD_AES_256_CBC_HMAC_SHA_512-Deterministic\").keyId(dataKeyId));\nBsonBinary encryptedFoods = clientEncryption.encrypt(new BsonArray().parse(\"[\\\"Grapes\\\", \\\"Foods\\\"]\"), new EncryptOptions(\"AEAD_AES_256_CBC_HMAC_SHA_512-Random\").keyId(dataKeyId));\ncollection.insertOne(new Document(\"name\", encryptedName).append(\"foods\", encryptedFoods).append(\"age\", 83));","programmingLanguage":"Java"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <pre class="leafygreen-ui-11itue3" 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"><span class="lg-highlight-title lg-highlight-class">BsonBinary</span> encryptedName = clientEncryption.<span class="lg-highlight-title lg-highlight-function">encrypt</span>(<span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">BsonString</span>(<span class="lg-highlight-string">"Greg"</span>), <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">EncryptOptions</span>(<span class="lg-highlight-string">"AEAD_AES_256_CBC_HMAC_SHA_512-Deterministic"</span>).<span class="lg-highlight-title lg-highlight-function">keyId</span>(dataKeyId));</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-title lg-highlight-class">BsonBinary</span> encryptedFoods = clientEncryption.<span class="lg-highlight-title lg-highlight-function">encrypt</span>(<span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">BsonArray</span>().<span class="lg-highlight-title lg-highlight-function">parse</span>(<span class="lg-highlight-string">"[</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">Grapes</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">, </span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">Foods</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">]"</span>), <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">EncryptOptions</span>(<span class="lg-highlight-string">"AEAD_AES_256_CBC_HMAC_SHA_512-Random"</span>).<span class="lg-highlight-title lg-highlight-function">keyId</span>(dataKeyId));</td></tr><tr class=""><td class="leafygreen-ui-7razhx">collection.<span class="lg-highlight-title lg-highlight-function">insertOne</span>(<span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">Document</span>(<span class="lg-highlight-string">"name"</span>, encryptedName).<span class="lg-highlight-title lg-highlight-function">append</span>(<span class="lg-highlight-string">"foods"</span>, encryptedFoods).<span class="lg-highlight-title lg-highlight-function">append</span>(<span class="lg-highlight-string">"age"</span>, <span class="lg-highlight-number">83</span>));</td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-94-menu" aria-describedby="select-94-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-95" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:r5g:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":r5g:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r5g:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r5g:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_ovanbd7co" class="" id="_iz0p3kvrb" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <div class="leafygreen-ui-15mdk4" role="note"> <h2 class="leafygreen-ui-6n7b7d"> Note </h2> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> The <code class="leafygreen-ui-1l06pbn"> dataKeyId </code> variable in the following examples refers to a Data Encryption Key (DEK). To learn how to generate a DEK with your Local Key Provider, see the <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/csfle/quick-start/#std-label-csfle-quick-start-create-dek"> Quick Start </a> . To learn how to create a DEK with a specific Key Management System, see <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/csfle/tutorials/#std-label-csfle-tutorials"> Tutorials <!-- --> . </a> </p> </div> </div> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"encryptedName = await encryption.encrypt(\"Greg\", {\n algorithm: \"AEAD_AES_256_CBC_HMAC_SHA_512-Deterministic\",\n keyId: dataKeyId,\n});\nencryptedFoods = await encryption.encrypt([\"Cheese\", \"Grapes\"], {\n algorithm: \"AEAD_AES_256_CBC_HMAC_SHA_512-Random\",\n keyId: dataKeyId,\n});\nawait collection.insertOne({\n name: encryptedName,\n age: 83,\n foods: encryptedFoods,\n});","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <pre class="leafygreen-ui-11itue3" 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">encryptedName <!-- -->= <span class="lg-highlight-keyword">await</span> encryption.<span class="lg-highlight-title lg-highlight-function">encrypt</span>(<span class="lg-highlight-string">"Greg"</span>, <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">algorithm</span>: <span class="lg-highlight-string">"AEAD_AES_256_CBC_HMAC_SHA_512-Deterministic"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">keyId</span>: <!-- -->dataKeyId<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">})<!-- -->;</td></tr><tr class=""><td class="leafygreen-ui-7razhx">encryptedFoods <!-- -->= <span class="lg-highlight-keyword">await</span> encryption.<span class="lg-highlight-title lg-highlight-function">encrypt</span>(<!-- -->[<span class="lg-highlight-string">"Cheese"</span>, <span class="lg-highlight-string">"Grapes"</span>]<!-- -->, <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">algorithm</span>: <span class="lg-highlight-string">"AEAD_AES_256_CBC_HMAC_SHA_512-Random"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">keyId</span>: <!-- -->dataKeyId<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">})<!-- -->;</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-keyword">await</span> collection.<span class="lg-highlight-title lg-highlight-function">insertOne</span>(<!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">name</span>: <!-- -->encryptedName<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">age</span>: <span class="lg-highlight-number">83</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">foods</span>: <!-- -->encryptedFoods<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">})<!-- -->;</td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-97-menu" aria-describedby="select-97-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-98" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:r5h:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":r5h:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r5h:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r5h:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_whdcg6gmn" class="leafygreen-ui-38lglc" id="_ohp2gfukp" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <div class="leafygreen-ui-15mdk4" role="note"> <h2 class="leafygreen-ui-6n7b7d"> Note </h2> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> The <code class="leafygreen-ui-1l06pbn"> data_key_id </code> variable in the following examples refers to a Data Encryption Key (DEK). To learn how to generate a DEK with your Local Key Provider, see the <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/csfle/quick-start/#std-label-csfle-quick-start-create-dek"> Quick Start </a> . To learn how to create a DEK with a specific Key Management System, see <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/csfle/tutorials/#std-label-csfle-tutorials"> Tutorials <!-- --> . </a> </p> </div> </div> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"encrypted_name = client_encryption.encrypt(\n \"Greg\",\n Algorithm.AEAD_AES_256_CBC_HMAC_SHA_512_Deterministic,\n key_id=data_key_id,\n)\nencrypted_foods = client_encryption.encrypt(\n [\"Cheese\", \"Grapes\"],\n Algorithm.AEAD_AES_256_CBC_HMAC_SHA_512_Random,\n key_id=data_key_id,\n)\ncoll.insert_one({\"name\": encrypted_name, \"age\": 83, \"foods\": encrypted_foods})","programmingLanguage":"Python"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <pre class="leafygreen-ui-11itue3" 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">encrypted_name = client_encryption.<span class="lg-highlight-title lg-highlight-function">encrypt</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"Greg"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-title lg-highlight-class">Algorithm</span>.<span class="lg-highlight-property">AEAD_AES_256_CBC_HMAC_SHA_512_Deterministic</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> key_id=data_key_id,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">)</td></tr><tr class=""><td class="leafygreen-ui-7razhx">encrypted_foods = client_encryption.<span class="lg-highlight-title lg-highlight-function">encrypt</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> [<span class="lg-highlight-string">"Cheese"</span>, <span class="lg-highlight-string">"Grapes"</span>],</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-title lg-highlight-class">Algorithm</span>.<span class="lg-highlight-property">AEAD_AES_256_CBC_HMAC_SHA_512_Random</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> key_id=data_key_id,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">)</td></tr><tr class=""><td class="leafygreen-ui-7razhx">coll.<span class="lg-highlight-title lg-highlight-function">insert_one</span>({<span class="lg-highlight-string">"name"</span>: encrypted_name, <span class="lg-highlight-string">"age"</span>: <span class="lg-highlight-number">83</span>, <span class="lg-highlight-string">"foods"</span>: encrypted_foods})</td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-100-menu" aria-describedby="select-100-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-101" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:r5i:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":r5i:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r5i:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r5i:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> </div> </div> </section> </div> </div> <div class="css-1nuklj8 e1ckbxcu1"> <div class="css-18fui5z e1ckbxcu0"> <div class="css-19lsqsq e1ckbxcu2"> 4 </div> </div> <div class="css-1ed38mk"> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Retrieve Document and Decrypt Fields <a class="headerlink leafygreen-ui-1kepx47" href="#retrieve-document-and-decrypt-fields" 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="retrieve-document-and-decrypt-fields"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> The following code snippets show how to retrieve your inserted document and manually decrypt the encrypted fields: </p> <div aria-hidden="true"> </div> <div class="leafygreen-ui-f2qztv" data-lgid="lg-tabs"> <div class="leafygreen-ui-jp7pox" id="tabs-19"> <div aria-label="Tabs to describe usage of drivers" aria-orientation="horizontal" class="leafygreen-ui-m8p1vb lg-ui-tab-list-0000" data-lgid="lg-tabs-tab_list" role="tablist"> <button aria-controls="_kod76428b" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_90h1rvb8u" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> MongoDB Shell </div> </button> <button aria-controls="_xia99vxxy" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_8206odinn" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> C# </div> </button> <button aria-controls="_qamtvlyig" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_irvcqjjbt" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Go </div> </button> <button aria-controls="_vbgfqr5i9" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_hwgqzhri5" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Java (Sync) </div> </button> <button aria-controls="_lphcigj0i" aria-selected="true" class="leafygreen-ui-1l773z1" data-text="" id="_blq6xoqcz" name="" role="tab" tabindex="0"> <div class="leafygreen-ui-1nxuzmg"> Node.js </div> </button> <button aria-controls="_r0nandx50" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_vrn89ap2g" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Python </div> </button> </div> <div class="leafygreen-ui-ov1ktg"> <div class="leafygreen-ui-1sg2lsz"> </div> </div> </div> <div class="lg-ui-tab-panels-0000" data-lgid="lg-tabs-tab_panels"> <div> <div aria-labelledby="_78za7m42n" class="leafygreen-ui-38lglc" id="_fmrvlfn5h" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"const encNameQuery = clientEncryption.encrypt(\n dataKeyId,\n \"Greg\",\n \"AEAD_AES_256_CBC_HMAC_SHA_512-Deterministic\"\n);\nlet doc = db.getSiblingDB(database).getCollection(collection).findOne({\n name: encNameQuery,\n});\nconsole.log(doc);\ndoc.name = clientEncryption.decrypt(doc.name);\ndoc.foods = clientEncryption.decrypt(doc.foods);\nconsole.log(doc);","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <pre class="leafygreen-ui-11itue3" 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"><span class="lg-highlight-keyword">const</span> encNameQuery <!-- -->= <!-- -->clientEncryption.<span class="lg-highlight-title lg-highlight-function">encrypt</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->dataKeyId<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"Greg"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"AEAD_AES_256_CBC_HMAC_SHA_512-Deterministic"</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx">)<!-- -->;</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-keyword">let</span> doc <!-- -->= <!-- -->db.<span class="lg-highlight-title lg-highlight-function">getSiblingDB</span>(<!-- -->database).<span class="lg-highlight-title lg-highlight-function">getCollection</span>(<!-- -->collection).<span class="lg-highlight-title lg-highlight-function">findOne</span>(<!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">name</span>: <!-- -->encNameQuery<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">})<!-- -->;</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-variable lg-highlight-language">console</span>.<span class="lg-highlight-title lg-highlight-function">log</span>(<!-- -->doc)<!-- -->;</td></tr><tr class=""><td class="leafygreen-ui-7razhx">doc.<span class="lg-highlight-property">name</span> <!-- -->= <!-- -->clientEncryption.<span class="lg-highlight-title lg-highlight-function">decrypt</span>(<!-- -->doc.<span class="lg-highlight-property">name</span>)<!-- -->;</td></tr><tr class=""><td class="leafygreen-ui-7razhx">doc.<span class="lg-highlight-property">foods</span> <!-- -->= <!-- -->clientEncryption.<span class="lg-highlight-title lg-highlight-function">decrypt</span>(<!-- -->doc.<span class="lg-highlight-property">foods</span>)<!-- -->;</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-variable lg-highlight-language">console</span>.<span class="lg-highlight-title lg-highlight-function">log</span>(<!-- -->doc)<!-- -->;</td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-103-menu" aria-describedby="select-103-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-104" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:r5j:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":r5j:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r5j:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r5j:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_x62bsxili" class="leafygreen-ui-38lglc" id="_4v3xp38eg" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"var nameToQuery = \"Greg\";\nvar encryptedNameToQuery = clientEncryption.Encrypt(\n nameToQuery,\n new EncryptOptions(algorithm: \"AEAD_AES_256_CBC_HMAC_SHA_512-Deterministic\", keyId: dataKeyId),\n CancellationToken.None);\nvar doc = collection.Find(new BsonDocument { { \"name\", encryptedNameToQuery } }).Single();\nConsole.WriteLine($\"Encrypted document: {doc}\");\ndoc[\"name\"] = clientEncryption.Decrypt(doc[\"name\"].AsBsonBinaryData, CancellationToken.None);\ndoc[\"foods\"] = clientEncryption.Decrypt(doc[\"foods\"].AsBsonBinaryData, CancellationToken.None);\nConsole.WriteLine($\"Decrypted field: {doc}\");","programmingLanguage":"C#"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <pre class="leafygreen-ui-11itue3" 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"><span class="lg-highlight-keyword">var</span> nameToQuery = <span class="lg-highlight-string">"Greg"</span>;</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-keyword">var</span> encryptedNameToQuery = clientEncryption.<span class="lg-highlight-title lg-highlight-class">Encrypt</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> nameToQuery,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">EncryptOptions</span>(<span class="lg-highlight-attr">algorithm</span>: <span class="lg-highlight-string">"AEAD_AES_256_CBC_HMAC_SHA_512-Deterministic"</span>, <span class="lg-highlight-attr">keyId</span>: dataKeyId),</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-title lg-highlight-class">CancellationToken</span>.<span class="lg-highlight-property">None</span>);</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-keyword">var</span> doc = collection.<span class="lg-highlight-title lg-highlight-class">Find</span>(<span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">BsonDocument</span> { { <span class="lg-highlight-string">"name"</span>, encryptedNameToQuery } }).<span class="lg-highlight-title lg-highlight-class">Single</span>();</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-title lg-highlight-class">Console</span>.<span class="lg-highlight-title lg-highlight-class">WriteLine</span>($<span class="lg-highlight-string">"Encrypted document: {doc}"</span>);</td></tr><tr class=""><td class="leafygreen-ui-7razhx">doc[<span class="lg-highlight-string">"name"</span>] = clientEncryption.<span class="lg-highlight-title lg-highlight-class">Decrypt</span>(doc[<span class="lg-highlight-string">"name"</span>].<span class="lg-highlight-property">AsBsonBinaryData</span>, <span class="lg-highlight-title lg-highlight-class">CancellationToken</span>.<span class="lg-highlight-property">None</span>);</td></tr><tr class=""><td class="leafygreen-ui-7razhx">doc[<span class="lg-highlight-string">"foods"</span>] = clientEncryption.<span class="lg-highlight-title lg-highlight-class">Decrypt</span>(doc[<span class="lg-highlight-string">"foods"</span>].<span class="lg-highlight-property">AsBsonBinaryData</span>, <span class="lg-highlight-title lg-highlight-class">CancellationToken</span>.<span class="lg-highlight-property">None</span>);</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-title lg-highlight-class">Console</span>.<span class="lg-highlight-title lg-highlight-class">WriteLine</span>($<span class="lg-highlight-string">"Decrypted field: {doc}"</span>);</td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-106-menu" aria-describedby="select-106-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-107" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:r5k:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":r5k:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r5k:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r5k:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_cppzytl1k" class="leafygreen-ui-38lglc" id="_e6p3j6lix" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"nameQueryRawValueType, nameQueryRawValueData, err := bson.MarshalValue(\"Greg\")\nif err != nil {\n\tpanic(err)\n}\nnameQueryRawValue := bson.RawValue{Type: nameQueryRawValueType, Value: nameQueryRawValueData}\nnameQueryEncryptionOpts := options.Encrypt().\n\tSetAlgorithm(\"AEAD_AES_256_CBC_HMAC_SHA_512-Deterministic\").\n\tSetKeyID(dataKeyId)\nnameQueryEncryptedField, err := clientEnc.Encrypt(\n\tcontext.TODO(),\n\tnameQueryRawValue,\n\tnameQueryEncryptionOpts)\nif err != nil {\n\tpanic(err)\n}\nvar result bson.M\nerr = coll.FindOne(\n\tcontext.TODO(),\n\tbson.D{{\"name\", nameQueryEncryptedField}}).Decode(&amp;result)\nif err != nil {\n\tif err == mongo.ErrNoDocuments {\n\t\treturn\n\t}\n\tpanic(err)\n}\nfmt.Printf(\"Encrypted Document: %s\\n\", result)\nnameDecrypted, err := clientEnc.Decrypt(\n\tcontext.TODO(),\n\tresult[\"name\"].(primitive.Binary))\nfoodsDecrypted, err := clientEnc.Decrypt(\n\tcontext.TODO(),\n\tresult[\"foods\"].(primitive.Binary))\nresult[\"foods\"] = foodsDecrypted\nresult[\"name\"] = nameDecrypted\nfmt.Printf(\"Decrypted Document: %s\\n\", result)","programmingLanguage":"Golang"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <pre class="leafygreen-ui-11itue3" 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">nameQueryRawValueType<!-- -->, <!-- -->nameQueryRawValueData, err := bson.<span class="lg-highlight-title lg-highlight-class">MarshalValue</span>(<span class="lg-highlight-string">"Greg"</span>)</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-keyword">if</span> err != nil {</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-title lg-highlight-function">panic</span>(err)</td></tr><tr class=""><td class="leafygreen-ui-7razhx">}</td></tr><tr class=""><td class="leafygreen-ui-7razhx">nameQueryRawValue <!-- -->:<!-- -->= bson.<span class="lg-highlight-property">RawValue</span>{<span class="lg-highlight-title lg-highlight-class">Type</span>: nameQueryRawValueType, <span class="lg-highlight-title lg-highlight-class">Value</span>: nameQueryRawValueData}</td></tr><tr class=""><td class="leafygreen-ui-7razhx">nameQueryEncryptionOpts <!-- -->:<!-- -->= options.<span class="lg-highlight-title lg-highlight-class">Encrypt</span>().</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-title lg-highlight-class">SetAlgorithm</span>(<span class="lg-highlight-string">"AEAD_AES_256_CBC_HMAC_SHA_512-Deterministic"</span>).</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-title lg-highlight-class">SetKeyID</span>(dataKeyId)</td></tr><tr class=""><td class="leafygreen-ui-7razhx">nameQueryEncryptedField<!-- -->, <!-- -->err := clientEnc.<span class="lg-highlight-title lg-highlight-class">Encrypt</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> context.<span class="lg-highlight-title lg-highlight-function">TODO</span>(),</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> nameQueryRawValue,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> nameQueryEncryptionOpts)</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-keyword">if</span> err != nil {</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-title lg-highlight-function">panic</span>(err)</td></tr><tr class=""><td class="leafygreen-ui-7razhx">}</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-keyword">var</span> result bson.<span class="lg-highlight-property">M</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx">err = coll.<span class="lg-highlight-title lg-highlight-class">FindOne</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> context.<span class="lg-highlight-title lg-highlight-function">TODO</span>(),</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> bson.<span class="lg-highlight-property">D</span>{{<span class="lg-highlight-string">"name"</span>, nameQueryEncryptedField}}).<span class="lg-highlight-title lg-highlight-class">Decode</span>(&amp;result)</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-keyword">if</span> err != nil {</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-keyword">if</span> err == mongo.<span class="lg-highlight-property">ErrNoDocuments</span> {</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-keyword">return</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-title lg-highlight-function">panic</span>(err)</td></tr><tr class=""><td class="leafygreen-ui-7razhx">}</td></tr><tr class=""><td class="leafygreen-ui-7razhx">fmt.<span class="lg-highlight-title lg-highlight-class">Printf</span>(<span class="lg-highlight-string">"Encrypted Document: %s</span><span class="lg-highlight-string">\n</span><span class="lg-highlight-string">"</span>, result)</td></tr><tr class=""><td class="leafygreen-ui-7razhx">nameDecrypted<!-- -->, <!-- -->err := clientEnc.<span class="lg-highlight-title lg-highlight-class">Decrypt</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> context.<span class="lg-highlight-title lg-highlight-function">TODO</span>(),</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> result[<span class="lg-highlight-string">"name"</span>].(primitive.<span class="lg-highlight-property">Binary</span>))</td></tr><tr class=""><td class="leafygreen-ui-7razhx">foodsDecrypted<!-- -->, <!-- -->err := clientEnc.<span class="lg-highlight-title lg-highlight-class">Decrypt</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> context.<span class="lg-highlight-title lg-highlight-function">TODO</span>(),</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> result[<span class="lg-highlight-string">"foods"</span>].(primitive.<span class="lg-highlight-property">Binary</span>))</td></tr><tr class=""><td class="leafygreen-ui-7razhx">result[<span class="lg-highlight-string">"foods"</span>] = foodsDecrypted</td></tr><tr class=""><td class="leafygreen-ui-7razhx">result[<span class="lg-highlight-string">"name"</span>] = nameDecrypted</td></tr><tr class=""><td class="leafygreen-ui-7razhx">fmt.<span class="lg-highlight-title lg-highlight-class">Printf</span>(<span class="lg-highlight-string">"Decrypted Document: %s</span><span class="lg-highlight-string">\n</span><span class="lg-highlight-string">"</span>, result)</td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-109-menu" aria-describedby="select-109-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-110" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:r5l:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":r5l:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r5l:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r5l:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_7vdvxrjxr" class="leafygreen-ui-38lglc" id="_9hwgkleoa" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"BsonBinary encryptedNameQuery = clientEncryption.encrypt(new BsonString(\"Greg\"), new EncryptOptions(\"AEAD_AES_256_CBC_HMAC_SHA_512-Deterministic\").keyId(dataKeyId));\nDocument result = collection.find(eq(\"name\", encryptedNameQuery)).first();\nSystem.out.println(\"Encrypted Document: \" + result.toJson());\nresult.replace(\"name\", clientEncryption.decrypt(new BsonBinary(result.get(\"name\", Binary.class).getData())));\nresult.replace(\"foods\", clientEncryption.decrypt(new BsonBinary(result.get(\"foods\", Binary.class).getData())));\nSystem.out.println(\"Decrypted Document: \" + result.toJson());","programmingLanguage":"Java"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <pre class="leafygreen-ui-11itue3" 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"><span class="lg-highlight-title lg-highlight-class">BsonBinary</span> encryptedNameQuery = clientEncryption.<span class="lg-highlight-title lg-highlight-function">encrypt</span>(<span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">BsonString</span>(<span class="lg-highlight-string">"Greg"</span>), <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">EncryptOptions</span>(<span class="lg-highlight-string">"AEAD_AES_256_CBC_HMAC_SHA_512-Deterministic"</span>).<span class="lg-highlight-title lg-highlight-function">keyId</span>(dataKeyId));</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-title lg-highlight-class">Document</span> result = collection.<span class="lg-highlight-title lg-highlight-function">find</span>(<span class="lg-highlight-title lg-highlight-function">eq</span>(<span class="lg-highlight-string">"name"</span>, encryptedNameQuery)).<span class="lg-highlight-title lg-highlight-function">first</span>();</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-title lg-highlight-class">System</span>.<span class="lg-highlight-property">out</span>.<span class="lg-highlight-title lg-highlight-function">println</span>(<span class="lg-highlight-string">"Encrypted Document: "</span> + result.<span class="lg-highlight-title lg-highlight-function">toJson</span>());</td></tr><tr class=""><td class="leafygreen-ui-7razhx">result.<span class="lg-highlight-title lg-highlight-function">replace</span>(<span class="lg-highlight-string">"name"</span>, clientEncryption.<span class="lg-highlight-title lg-highlight-function">decrypt</span>(<span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">BsonBinary</span>(result.<span class="lg-highlight-title lg-highlight-function">get</span>(<span class="lg-highlight-string">"name"</span>, <span class="lg-highlight-title lg-highlight-class">Binary</span>.<span class="lg-highlight-property lg-highlight-class">class</span>).<span class="lg-highlight-title lg-highlight-function">getData</span>())));</td></tr><tr class=""><td class="leafygreen-ui-7razhx">result.<span class="lg-highlight-title lg-highlight-function">replace</span>(<span class="lg-highlight-string">"foods"</span>, clientEncryption.<span class="lg-highlight-title lg-highlight-function">decrypt</span>(<span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">BsonBinary</span>(result.<span class="lg-highlight-title lg-highlight-function">get</span>(<span class="lg-highlight-string">"foods"</span>, <span class="lg-highlight-title lg-highlight-class">Binary</span>.<span class="lg-highlight-property lg-highlight-class">class</span>).<span class="lg-highlight-title lg-highlight-function">getData</span>())));</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-title lg-highlight-class">System</span>.<span class="lg-highlight-property">out</span>.<span class="lg-highlight-title lg-highlight-function">println</span>(<span class="lg-highlight-string">"Decrypted Document: "</span> + result.<span class="lg-highlight-title lg-highlight-function">toJson</span>());</td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-112-menu" aria-describedby="select-112-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-113" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:r5m:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":r5m:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r5m:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r5m:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_gkv0va4j8" class="" id="_bz5tqb26b" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"queryEncryptedName = await encryption.encrypt(\"Greg\", {\n algorithm: \"AEAD_AES_256_CBC_HMAC_SHA_512-Deterministic\",\n keyId: dataKeyId,\n});\nlet doc = await collection.findOne({ name: queryEncryptedName });\nconsole.log(\"Encrypted Document: \", doc);\ndoc.name = encryption.decrypt(doc.name);\ndoc.foods = encryption.decrypt(doc.foods);\nconsole.log(\"Decrypted document: \", doc);","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <pre class="leafygreen-ui-11itue3" 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">queryEncryptedName <!-- -->= <span class="lg-highlight-keyword">await</span> encryption.<span class="lg-highlight-title lg-highlight-function">encrypt</span>(<span class="lg-highlight-string">"Greg"</span>, <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">algorithm</span>: <span class="lg-highlight-string">"AEAD_AES_256_CBC_HMAC_SHA_512-Deterministic"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">keyId</span>: <!-- -->dataKeyId<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">})<!-- -->;</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-keyword">let</span> doc <!-- -->= <span class="lg-highlight-keyword">await</span> collection.<span class="lg-highlight-title lg-highlight-function">findOne</span>(<!-- -->{ <span class="lg-highlight-attr">name</span>: <!-- -->queryEncryptedName })<!-- -->;</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-variable lg-highlight-language">console</span>.<span class="lg-highlight-title lg-highlight-function">log</span>(<span class="lg-highlight-string">"Encrypted Document: "</span>, <!-- -->doc)<!-- -->;</td></tr><tr class=""><td class="leafygreen-ui-7razhx">doc.<span class="lg-highlight-property">name</span> <!-- -->= <!-- -->encryption.<span class="lg-highlight-title lg-highlight-function">decrypt</span>(<!-- -->doc.<span class="lg-highlight-property">name</span>)<!-- -->;</td></tr><tr class=""><td class="leafygreen-ui-7razhx">doc.<span class="lg-highlight-property">foods</span> <!-- -->= <!-- -->encryption.<span class="lg-highlight-title lg-highlight-function">decrypt</span>(<!-- -->doc.<span class="lg-highlight-property">foods</span>)<!-- -->;</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-variable lg-highlight-language">console</span>.<span class="lg-highlight-title lg-highlight-function">log</span>(<span class="lg-highlight-string">"Decrypted document: "</span>, <!-- -->doc)<!-- -->;</td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-115-menu" aria-describedby="select-115-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-116" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:r5n:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":r5n:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r5n:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r5n:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_fanixxfnj" class="leafygreen-ui-38lglc" id="_1xrx0if6v" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"name_to_query = \"Greg\"\nencrypted_name_to_query = client_encryption.encrypt(\n name_to_query,\n Algorithm.AEAD_AES_256_CBC_HMAC_SHA_512_Deterministic,\n key_id=data_key_id,\n)\ndoc = client.employees.foods.find_one({\"name\": encrypted_name_to_query})\nprint(\"Encrypted document: %s\" % (doc,))\ndoc[\"name\"] = client_encryption.decrypt(doc[\"name\"])\ndoc[\"foods\"] = client_encryption.decrypt(doc[\"foods\"])\nprint(\"Decrypted document: %s\" % (doc,))","programmingLanguage":"Python"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <pre class="leafygreen-ui-11itue3" 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">name_to_query = <span class="lg-highlight-string">"Greg"</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx">encrypted_name_to_query = client_encryption.<span class="lg-highlight-title lg-highlight-function">encrypt</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> name_to_query,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-title lg-highlight-class">Algorithm</span>.<span class="lg-highlight-property">AEAD_AES_256_CBC_HMAC_SHA_512_Deterministic</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> key_id=data_key_id,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">)</td></tr><tr class=""><td class="leafygreen-ui-7razhx">doc = client.<span class="lg-highlight-property">employees</span>.<span class="lg-highlight-property">foods</span>.<span class="lg-highlight-title lg-highlight-function">find_one</span>({<span class="lg-highlight-string">"name"</span>: encrypted_name_to_query})</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-title lg-highlight-function">print</span>(<span class="lg-highlight-string">"Encrypted document: %s"</span> % (doc,))</td></tr><tr class=""><td class="leafygreen-ui-7razhx">doc[<span class="lg-highlight-string">"name"</span>] = client_encryption.<span class="lg-highlight-title lg-highlight-function">decrypt</span>(doc[<span class="lg-highlight-string">"name"</span>])</td></tr><tr class=""><td class="leafygreen-ui-7razhx">doc[<span class="lg-highlight-string">"foods"</span>] = client_encryption.<span class="lg-highlight-title lg-highlight-function">decrypt</span>(doc[<span class="lg-highlight-string">"foods"</span>])</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-title lg-highlight-function">print</span>(<span class="lg-highlight-string">"Decrypted document: %s"</span> % (doc,))</td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-118-menu" aria-describedby="select-118-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-119" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:r5o:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":r5o:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r5o:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":r5o:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> </div> </div> </section> </div> </div> </div> <span class="leafygreen-ui-1qnjd6d" id="std-label-csfle-fundamentals-manual-encryption-server-side-schema"> </span> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Server-Side Field Level Encryption Enforcement <a class="headerlink leafygreen-ui-1kepx47" href="#server-side-field-level-encryption-enforcement" 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="server-side-field-level-encryption-enforcement"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> MongoDB supports using <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/schema-validation/#std-label-schema-validation-overview"> schema validation </a> to enforce encryption of specific fields in a collection. </p> <p class="leafygreen-ui-1kp3ins"> A client performing Client-Side Field Level Encryption with the explicit encryption mechanism on a MongoDB instance configured to enforce encryption of certain fields must encrypt those fields as specified on the MongoDB instance. </p> <p class="leafygreen-ui-1kp3ins"> To learn how to set up server-side CSFLE enforcement, see <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/csfle/reference/server-side-schema/#std-label-csfle-reference-server-side-schema"> CSFLE Server-Side Schema Enforcement <!-- --> . </a> </p> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Learn More <a class="headerlink leafygreen-ui-1kepx47" href="#learn-more" 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="learn-more"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> To learn more about Key Vault collections, Data Encryption Keys, and Customer Master Keys, see <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/queryable-encryption/fundamentals/keys-key-vaults/#std-label-qe-reference-keys-key-vaults"> Encryption Keys and Key Vaults <!-- --> . </a> </p> <p class="leafygreen-ui-1kp3ins"> To learn more about <span class="leafygreen-ui-vm4wms" tabindex="0"> KMS </span> providers and <code class="leafygreen-ui-1l06pbn"> kmsProviders </code> objects, see <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/queryable-encryption/fundamentals/kms-providers/#std-label-qe-fundamentals-kms-providers"> KMS Providers <!-- --> . </a> </p> </section> </section>
https://www.mongodb.com/docs/manual/reference/operator/aggregation/dateTrunc/
<section> <h1 class="contains-headerlink leafygreen-ui-41fr9s" weight="medium"> $dateTrunc (aggregation) <a class="headerlink leafygreen-ui-1kepx47" href="#-datetrunc--aggregation-" 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="-datetrunc--aggregation-"> </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="#definition" target="_self"> <span> Definition </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#behavior" target="_self"> <span> Behavior </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#examples" target="_self"> <span> Examples </span> </a> </li> </ul> </div> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Definition <a class="headerlink leafygreen-ui-1kepx47" href="#definition" 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="definition"> </div> </a> </h2> <dl class="expression"> <dt> <code class="leafygreen-ui-1l06pbn"> $dateTrunc </code> <a class="headerlink leafygreen-ui-1kepx47" href="#mongodb-expression-exp.-dateTrunc" title="Permalink to this definition"> <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="mongodb-expression-exp.-dateTrunc"> </div> </a> </dt> <dd> </dd> </dl> <div> <p> <em> New <!-- --> in version <!-- --> 5.0 </em> . </p> </div> <p class="leafygreen-ui-1kp3ins"> Truncates a date. </p> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-expression-exp.-dateTrunc" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $dateTrunc </code> </span> </a> syntax: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{\n $dateTrunc: {\n date: &lt;expression&gt;,\n unit: &lt;expression&gt;,\n binSize: &lt;expression&gt;,\n timezone: &lt;tzexpression&gt;,\n startOfWeek: &lt;expression&gt;\n }\n}"} </script> <div class="css-1lju8ps"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1jheeh3"> <pre class="leafygreen-ui-1453az5" tabindex="-1"><code class="lg-highlight-hljs-light none leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> $dateTrunc: {</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> date: &lt;Expression&gt;,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> unit: &lt;Expression&gt;,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> binSize: &lt;Expression&gt;,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> timezone: &lt;tzExpression&gt;,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> startOfWeek: &lt;Expression&gt;</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">}</td></tr></tbody></table></code></pre> </div> </div> </div> <div class="leafygreen-ui-skkc39" tabindex="0"> <table class="leafygreen-ui-hr8lsv"> <colgroup> <col style="width:20%"/> <col style="width:20%"/> <col style="width:60%"/> </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> Field </div> </div> </th> <th class="leafygreen-ui-13uteka" role="columnheader" scope="col"> <div class="leafygreen-ui-ui0te9"> <div> Required / Optional </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="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-dateTrunc-date" target="_self"> <span> date </span> </a> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Required </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <span class="leafygreen-ui-1qnjd6d" id="std-label-dateTrunc-date"> </span> <p class="leafygreen-ui-1kp3ins"> The date to truncate, specified in UTC. The <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-dateTrunc-date" target="_self"> <span> date </span> </a> can be any <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/#std-label-aggregation-expressions"> expression </a> that resolves to a <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/bson-types/#std-label-document-bson-type-date"> Date </a> , a <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/bson-types/#std-label-document-bson-type-timestamp"> Timestamp </a> , or an <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/bson-types/#std-label-document-bson-type-object-id"> ObjectID <!-- --> . </a> </p> </div> </div> </td> </tr> <tr class=""> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-dateTrunc-unit" target="_self"> <span> unit </span> </a> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Required </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <span class="leafygreen-ui-1qnjd6d" id="std-label-dateTrunc-unit"> </span> <p class="leafygreen-ui-1kp3ins"> The unit of time, specified as an <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/#std-label-aggregation-expressions"> expression </a> that must resolve to one of these strings: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <code class="leafygreen-ui-1l06pbn"> year </code> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <code class="leafygreen-ui-1l06pbn"> quarter </code> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <code class="leafygreen-ui-1l06pbn"> week </code> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <code class="leafygreen-ui-1l06pbn"> month </code> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <code class="leafygreen-ui-1l06pbn"> day </code> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <code class="leafygreen-ui-1l06pbn"> hour </code> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <code class="leafygreen-ui-1l06pbn"> minute </code> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <code class="leafygreen-ui-1l06pbn"> second </code> </p> </li> </ul> <p class="leafygreen-ui-1kp3ins"> Together, <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-dateTrunc-binSize" target="_self"> <span> binSize </span> </a> and <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-dateTrunc-unit" target="_self"> <span> unit </span> </a> specify the time period used in the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-expression-exp.-dateTrunc" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $dateTrunc </code> </span> </a> calculation. </p> </div> </div> </td> </tr> <tr class=""> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-dateTrunc-binSize" target="_self"> <span> binSize </span> </a> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Optional </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <span class="leafygreen-ui-1qnjd6d" id="std-label-dateTrunc-binSize"> </span> <p class="leafygreen-ui-1kp3ins"> The numeric time value, specified as an <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/#std-label-aggregation-expressions"> expression </a> that must resolve to a positive non-zero number. Defaults to 1. </p> <p class="leafygreen-ui-1kp3ins"> Together, <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-dateTrunc-binSize" target="_self"> <span> binSize </span> </a> and <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-dateTrunc-unit" target="_self"> <span> unit </span> </a> specify the time period used in the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-expression-exp.-dateTrunc" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $dateTrunc </code> </span> </a> calculation. </p> </div> </div> </td> </tr> <tr class=""> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-dateTrunc-timezone" target="_self"> <span> timezone </span> </a> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Optional </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <span class="leafygreen-ui-1qnjd6d" id="std-label-dateTrunc-timezone"> </span> <p class="leafygreen-ui-1kp3ins"> The timezone for the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-expression-exp.-dateTrunc" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $dateTrunc </code> </span> </a> calculation, specified as an <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/#std-label-aggregation-expressions"> expression </a> that must resolve to a string that contains one of these values: </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://en.wikipedia.org/wiki/List_of_tz_database_time_zones" rel="noopener noreferrer"> <span> Olson Timezone Identifier </span> <svg alt="" aria-hidden="true" class="leafygreen-ui-1ie5kuq" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M13.823 2.4491C13.8201 2.30008 13.6999 2.17994 13.5509 2.17704L9.5062 2.09836C9.25654 2.09351 9.12821 2.39519 9.30482 2.5718L10.3856 3.65257L7.93433 6.10383C7.87964 6.15852 7.83047 6.21665 7.78683 6.27752L5.99909 8.06525C5.46457 8.59977 5.46457 9.4664 5.99909 10.0009C6.53361 10.5354 7.40023 10.5354 7.93475 10.0009L9.72249 8.21317C9.78336 8.16953 9.84148 8.12037 9.89618 8.06567L12.3474 5.61441L13.4282 6.69518C13.6048 6.87179 13.9065 6.74347 13.9016 6.4938L13.823 2.4491Z" fill="currentColor"> </path> <path d="M7.25 3.12893C7.66421 3.12893 8 3.46472 8 3.87893C8 4.29315 7.66421 4.62893 7.25 4.62893H4C3.72386 4.62893 3.5 4.85279 3.5 5.12893V11.9929C3.5 12.2691 3.72386 12.4929 4 12.4929H10.864C11.1401 12.4929 11.364 12.2691 11.364 11.9929V8.75C11.364 8.33579 11.6998 8 12.114 8C12.5282 8 12.864 8.33579 12.864 8.75V11.9929C12.864 13.0975 11.9686 13.9929 10.864 13.9929H4C2.89543 13.9929 2 13.0975 2 11.9929V5.12893C2 4.02436 2.89543 3.12893 4 3.12893H7.25Z" fill="currentColor"> </path> </svg> </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://en.wikipedia.org/wiki/List_of_UTC_time_offsets" rel="noopener noreferrer"> <span> UTC Offset </span> <svg alt="" aria-hidden="true" class="leafygreen-ui-1ie5kuq" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M13.823 2.4491C13.8201 2.30008 13.6999 2.17994 13.5509 2.17704L9.5062 2.09836C9.25654 2.09351 9.12821 2.39519 9.30482 2.5718L10.3856 3.65257L7.93433 6.10383C7.87964 6.15852 7.83047 6.21665 7.78683 6.27752L5.99909 8.06525C5.46457 8.59977 5.46457 9.4664 5.99909 10.0009C6.53361 10.5354 7.40023 10.5354 7.93475 10.0009L9.72249 8.21317C9.78336 8.16953 9.84148 8.12037 9.89618 8.06567L12.3474 5.61441L13.4282 6.69518C13.6048 6.87179 13.9065 6.74347 13.9016 6.4938L13.823 2.4491Z" fill="currentColor"> </path> <path d="M7.25 3.12893C7.66421 3.12893 8 3.46472 8 3.87893C8 4.29315 7.66421 4.62893 7.25 4.62893H4C3.72386 4.62893 3.5 4.85279 3.5 5.12893V11.9929C3.5 12.2691 3.72386 12.4929 4 12.4929H10.864C11.1401 12.4929 11.364 12.2691 11.364 11.9929V8.75C11.364 8.33579 11.6998 8 12.114 8C12.5282 8 12.864 8.33579 12.864 8.75V11.9929C12.864 13.0975 11.9686 13.9929 10.864 13.9929H4C2.89543 13.9929 2 13.0975 2 11.9929V5.12893C2 4.02436 2.89543 3.12893 4 3.12893H7.25Z" fill="currentColor"> </path> </svg> </a> </p> </li> </ul> <p class="leafygreen-ui-1kp3ins"> If no <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-dateTrunc-timezone" target="_self"> <span> timezone </span> </a> is provided, the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-expression-exp.-dateTrunc" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $dateTrunc </code> </span> </a> calculation is performed in UTC. </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> Format </div> </div> </th> <th class="leafygreen-ui-13uteka" role="columnheader" scope="col"> <div class="leafygreen-ui-ui0te9"> <div> Examples </div> </div> </th> </tr> </thead> <tbody> <tr class=""> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Olson Timezone Identifier </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <code class="leafygreen-ui-1l06pbn"> America/New_York </code> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <code class="leafygreen-ui-1l06pbn"> Europe/London </code> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <code class="leafygreen-ui-1l06pbn"> GMT </code> </p> </li> </ul> </div> </div> </td> </tr> <tr class=""> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> UTC Offset </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <code class="leafygreen-ui-1l06pbn"> +/-[hh]:[mm] </code> (example, <code class="leafygreen-ui-1l06pbn"> +04:45 </code> ) </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <code class="leafygreen-ui-1l06pbn"> +/-[hh][mm] </code> (example, <code class="leafygreen-ui-1l06pbn"> -0530 </code> ) </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <code class="leafygreen-ui-1l06pbn"> +/-[hh] </code> (example, <code class="leafygreen-ui-1l06pbn"> +03 </code> ) </p> </li> </ul> </div> </div> </td> </tr> </tbody> </table> </div> </div> </div> </td> </tr> <tr class=""> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-dateTrunc-startOfWeek" target="_self"> <span> startOfWeek </span> </a> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Optional </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <span class="leafygreen-ui-1qnjd6d" id="std-label-dateTrunc-startOfWeek"> </span> <p class="leafygreen-ui-1kp3ins"> The start of the week. Used when <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-dateTrunc-unit" target="_self"> <span> unit </span> </a> is <code class="leafygreen-ui-1l06pbn"> week </code> . Defaults to <code class="leafygreen-ui-1l06pbn"> Sunday </code> . </p> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-dateTrunc-startOfWeek" target="_self"> <span> startOfWeek </span> </a> is an <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/#std-label-aggregation-expressions"> expression </a> that must resolve to one of these case insensitive strings: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <code class="leafygreen-ui-1l06pbn"> monday </code> (or <code class="leafygreen-ui-1l06pbn"> mon </code> ) </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <code class="leafygreen-ui-1l06pbn"> tuesday </code> (or <code class="leafygreen-ui-1l06pbn"> tue </code> ) </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <code class="leafygreen-ui-1l06pbn"> wednesday </code> (or <code class="leafygreen-ui-1l06pbn"> wed </code> ) </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <code class="leafygreen-ui-1l06pbn"> thursday </code> (or <code class="leafygreen-ui-1l06pbn"> thu </code> ) </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <code class="leafygreen-ui-1l06pbn"> friday </code> (or <code class="leafygreen-ui-1l06pbn"> fri </code> ) </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <code class="leafygreen-ui-1l06pbn"> saturday </code> (or <code class="leafygreen-ui-1l06pbn"> sat </code> ) </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <code class="leafygreen-ui-1l06pbn"> sunday </code> (or <code class="leafygreen-ui-1l06pbn"> sun </code> ) </p> </li> </ul> </div> </div> </td> </tr> </tbody> </table> </div> <div class="leafygreen-ui-13vw3ie" role="note"> <h2 class="leafygreen-ui-1fn4p2b"> Tip </h2> <h3 class="leafygreen-ui-144d5kf"> <strong> See also: </strong> </h3> <div class="leafygreen-ui-9mycqc"> <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/#std-label-aggregation-expressions"> Expression Operators </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/bson-types/#std-label-bson-types"> BSON Types </a> </p> </li> </ul> </div> </div> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Behavior <a class="headerlink leafygreen-ui-1kepx47" href="#behavior" 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="behavior"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-expression-exp.-dateTrunc" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $dateTrunc </code> : </span> </a> </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Returns <code class="leafygreen-ui-1l06pbn"> null </code> if: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> any of the input fields except <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-dateTrunc-startOfWeek" target="_self"> <span> startOfWeek </span> </a> is missing or set to <code class="leafygreen-ui-1l06pbn"> null </code> , or </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> if <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-dateTrunc-unit" target="_self"> <span> unit </span> </a> is <code class="leafygreen-ui-1l06pbn"> week </code> and <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-dateTrunc-startOfWeek" target="_self"> <span> startOfWeek </span> </a> is missing or set to <code class="leafygreen-ui-1l06pbn"> null </code> . </p> </li> </ul> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Uses the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://en.wikipedia.org/wiki/Proleptic_Gregorian_calendar" rel="noopener noreferrer"> <span> proleptic Gregorian calendar </span> <svg alt="" aria-hidden="true" class="leafygreen-ui-1ie5kuq" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M13.823 2.4491C13.8201 2.30008 13.6999 2.17994 13.5509 2.17704L9.5062 2.09836C9.25654 2.09351 9.12821 2.39519 9.30482 2.5718L10.3856 3.65257L7.93433 6.10383C7.87964 6.15852 7.83047 6.21665 7.78683 6.27752L5.99909 8.06525C5.46457 8.59977 5.46457 9.4664 5.99909 10.0009C6.53361 10.5354 7.40023 10.5354 7.93475 10.0009L9.72249 8.21317C9.78336 8.16953 9.84148 8.12037 9.89618 8.06567L12.3474 5.61441L13.4282 6.69518C13.6048 6.87179 13.9065 6.74347 13.9016 6.4938L13.823 2.4491Z" fill="currentColor"> </path> <path d="M7.25 3.12893C7.66421 3.12893 8 3.46472 8 3.87893C8 4.29315 7.66421 4.62893 7.25 4.62893H4C3.72386 4.62893 3.5 4.85279 3.5 5.12893V11.9929C3.5 12.2691 3.72386 12.4929 4 12.4929H10.864C11.1401 12.4929 11.364 12.2691 11.364 11.9929V8.75C11.364 8.33579 11.6998 8 12.114 8C12.5282 8 12.864 8.33579 12.864 8.75V11.9929C12.864 13.0975 11.9686 13.9929 10.864 13.9929H4C2.89543 13.9929 2 13.0975 2 11.9929V5.12893C2 4.02436 2.89543 3.12893 4 3.12893H7.25Z" fill="currentColor"> </path> </svg> </a> for dates preceding the year 1583. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Accounts for Daylight Savings Time, but does not account for <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://en.wikipedia.org/wiki/Leap_second" rel="noopener noreferrer"> <span> leap seconds <!-- --> . </span> <svg alt="" aria-hidden="true" class="leafygreen-ui-1ie5kuq" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M13.823 2.4491C13.8201 2.30008 13.6999 2.17994 13.5509 2.17704L9.5062 2.09836C9.25654 2.09351 9.12821 2.39519 9.30482 2.5718L10.3856 3.65257L7.93433 6.10383C7.87964 6.15852 7.83047 6.21665 7.78683 6.27752L5.99909 8.06525C5.46457 8.59977 5.46457 9.4664 5.99909 10.0009C6.53361 10.5354 7.40023 10.5354 7.93475 10.0009L9.72249 8.21317C9.78336 8.16953 9.84148 8.12037 9.89618 8.06567L12.3474 5.61441L13.4282 6.69518C13.6048 6.87179 13.9065 6.74347 13.9016 6.4938L13.823 2.4491Z" fill="currentColor"> </path> <path d="M7.25 3.12893C7.66421 3.12893 8 3.46472 8 3.87893C8 4.29315 7.66421 4.62893 7.25 4.62893H4C3.72386 4.62893 3.5 4.85279 3.5 5.12893V11.9929C3.5 12.2691 3.72386 12.4929 4 12.4929H10.864C11.1401 12.4929 11.364 12.2691 11.364 11.9929V8.75C11.364 8.33579 11.6998 8 12.114 8C12.5282 8 12.864 8.33579 12.864 8.75V11.9929C12.864 13.0975 11.9686 13.9929 10.864 13.9929H4C2.89543 13.9929 2 13.0975 2 11.9929V5.12893C2 4.02436 2.89543 3.12893 4 3.12893H7.25Z" fill="currentColor"> </path> </svg> </a> </p> </li> </ul> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> <code class="leafygreen-ui-1l06pbn"> binSize </code> and <code class="leafygreen-ui-1l06pbn"> unit </code> Fields <a class="headerlink leafygreen-ui-1kepx47" href="#binsize-and-unit-fields" 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="binsize-and-unit-fields"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> Together, <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-dateTrunc-binSize" target="_self"> <span> binSize </span> </a> and <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-dateTrunc-unit" target="_self"> <span> unit </span> </a> specify the time period used in the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-expression-exp.-dateTrunc" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $dateTrunc </code> </span> </a> calculation. </p> <p class="leafygreen-ui-1kp3ins"> For example: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> If <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-dateTrunc-binSize" target="_self"> <span> binSize </span> </a> is <code class="leafygreen-ui-1l06pbn"> 1 </code> and <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-dateTrunc-unit" target="_self"> <span> unit </span> </a> is <code class="leafygreen-ui-1l06pbn"> hour </code> , the time period is one hour. For the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-dateTrunc-date" target="_self"> <span> date </span> </a> <code class="leafygreen-ui-1l06pbn"> 2021-03-20T11:30:05Z </code> , <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-expression-exp.-dateTrunc" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $dateTrunc </code> </span> </a> returns <code class="leafygreen-ui-1l06pbn"> 2021-03-20T11:00:00Z </code> . </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> If <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-dateTrunc-binSize" target="_self"> <span> binSize </span> </a> is <code class="leafygreen-ui-1l06pbn"> 2 </code> and <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-dateTrunc-unit" target="_self"> <span> unit </span> </a> is <code class="leafygreen-ui-1l06pbn"> hour </code> , the time period is two hours. For the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-dateTrunc-date" target="_self"> <span> date </span> </a> <code class="leafygreen-ui-1l06pbn"> 2021-03-20T11:30:05Z </code> , <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-expression-exp.-dateTrunc" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $dateTrunc </code> </span> </a> returns <code class="leafygreen-ui-1l06pbn"> 2021-03-20T10:00:00Z </code> . </p> </li> </ul> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-expression-exp.-dateTrunc" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $dateTrunc </code> : </span> </a> </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Divides the time for the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-expression-exp.-dateTrunc" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $dateTrunc </code> </span> </a> calculation into <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-dateTrunc-binSize" target="_self"> <span> binSize </span> </a> time periods in the specified time <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-dateTrunc-unit" target="_self"> <span> unit <!-- --> . </span> </a> </p> <p class="leafygreen-ui-1kp3ins"> The time periods start at a reference date, which is determined by <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-dateTrunc-unit" target="_self"> <span> unit </span> </a> . If <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-dateTrunc-unit" target="_self"> <span> unit </span> </a> is: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> A string other than <code class="leafygreen-ui-1l06pbn"> week </code> , <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-expression-exp.-dateTrunc" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $dateTrunc </code> </span> </a> uses a reference date of <code class="leafygreen-ui-1l06pbn"> 2000-01-01T00:00:00.00Z </code> . For example, if <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-dateTrunc-binSize" target="_self"> <span> binSize </span> </a> is <code class="leafygreen-ui-1l06pbn"> 10 </code> and <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-dateTrunc-unit" target="_self"> <span> unit </span> </a> is <code class="leafygreen-ui-1l06pbn"> year </code> , example time periods are: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <code class="leafygreen-ui-1l06pbn"> 2000-01-01T00:00:00.00Z </code> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <code class="leafygreen-ui-1l06pbn"> 2010-01-01T00:00:00.00Z </code> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <code class="leafygreen-ui-1l06pbn"> 2020-01-01T00:00:00.00Z </code> </p> </li> </ul> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Equal to <code class="leafygreen-ui-1l06pbn"> week </code> , <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-expression-exp.-dateTrunc" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $dateTrunc </code> </span> </a> uses a reference date that is set to the earliest first day of the week that is greater than or equal to <code class="leafygreen-ui-1l06pbn"> 2000-01-01 </code> . The first day is set using <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-dateTrunc-startOfWeek" target="_self"> <span> startOfWeek </span> </a> (the default is Sunday). </p> </li> </ul> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Returns the lower boundary of the time period that the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-dateTrunc-date" target="_self"> <span> date </span> </a> is in. The boundary is returned as an <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-ISODate"> ISODate </a> . If the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-dateTrunc-binSize" target="_self"> <span> binSize </span> </a> field is <code class="leafygreen-ui-1l06pbn"> 1 </code> , <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-expression-exp.-dateTrunc" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $dateTrunc </code> </span> </a> sets the least significant parts (as determined by <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-dateTrunc-unit" target="_self"> <span> unit </span> </a> ) of the returned <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-ISODate"> ISODate </a> to <code class="leafygreen-ui-1l06pbn"> 0 </code> and keeps the rest of the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-ISODate"> ISODate </a> the same. </p> </li> </ul> <p class="leafygreen-ui-1kp3ins"> If <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-dateTrunc-unit" target="_self"> <span> unit </span> </a> is: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <code class="leafygreen-ui-1l06pbn"> year </code> : <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-expression-exp.-dateTrunc" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $dateTrunc </code> </span> </a> returns the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-ISODate"> ISODate </a> for the start of January 1 for the year in <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-dateTrunc-date" target="_self"> <span> date <!-- --> . </span> </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <code class="leafygreen-ui-1l06pbn"> quarter </code> : <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-expression-exp.-dateTrunc" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $dateTrunc </code> </span> </a> returns the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-ISODate"> ISODate </a> for the start of the first day of the calendar quarter in <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-dateTrunc-date" target="_self"> <span> date <!-- --> . </span> </a> </p> <p class="leafygreen-ui-1kp3ins"> The quarters are: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> January to March </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> April to June </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> July to September </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> October to December </p> </li> </ul> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <code class="leafygreen-ui-1l06pbn"> month </code> : <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-expression-exp.-dateTrunc" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $dateTrunc </code> </span> </a> returns the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-ISODate"> ISODate </a> for the start of the first day of the month in <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-dateTrunc-date" target="_self"> <span> date <!-- --> . </span> </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <code class="leafygreen-ui-1l06pbn"> week </code> : <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-expression-exp.-dateTrunc" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $dateTrunc </code> </span> </a> returns the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-ISODate"> ISODate </a> for the start of the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-dateTrunc-startOfWeek" target="_self"> <span> startOfWeek </span> </a> day in <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-dateTrunc-date" target="_self"> <span> date </span> </a> . The default for <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-dateTrunc-startOfWeek" target="_self"> <span> startOfWeek </span> </a> is Sunday. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <code class="leafygreen-ui-1l06pbn"> day </code> : <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-expression-exp.-dateTrunc" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $dateTrunc </code> </span> </a> returns the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-ISODate"> ISODate </a> for the start of the day in <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-dateTrunc-date" target="_self"> <span> date <!-- --> . </span> </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <code class="leafygreen-ui-1l06pbn"> hour </code> : <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-expression-exp.-dateTrunc" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $dateTrunc </code> </span> </a> returns the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-ISODate"> ISODate </a> for the start of the hour in <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-dateTrunc-date" target="_self"> <span> date <!-- --> . </span> </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <code class="leafygreen-ui-1l06pbn"> minute </code> : <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-expression-exp.-dateTrunc" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $dateTrunc </code> </span> </a> returns the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-ISODate"> ISODate </a> for the start of the minute in <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-dateTrunc-date" target="_self"> <span> date <!-- --> . </span> </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <code class="leafygreen-ui-1l06pbn"> second </code> : <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-expression-exp.-dateTrunc" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $dateTrunc </code> </span> </a> returns the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-ISODate"> ISODate </a> for start of the second in <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-dateTrunc-date" target="_self"> <span> date <!-- --> . </span> </a> </p> </li> </ul> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> <code class="leafygreen-ui-1l06pbn"> unit </code> and <code class="leafygreen-ui-1l06pbn"> startOfWeek </code> Fields <a class="headerlink leafygreen-ui-1kepx47" href="#unit-and-startofweek-fields" 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="unit-and-startofweek-fields"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> If <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-dateTrunc-unit" target="_self"> <span> unit </span> </a> is: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> A string other than <code class="leafygreen-ui-1l06pbn"> week </code> , <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-dateTrunc-startOfWeek" target="_self"> <span> startOfWeek </span> </a> is ignored. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Equal to <code class="leafygreen-ui-1l06pbn"> week </code> and <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-dateTrunc-startOfWeek" target="_self"> <span> startOfWeek </span> </a> is: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Specified: <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-expression-exp.-dateTrunc" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $dateTrunc </code> </span> </a> uses <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-dateTrunc-startOfWeek" target="_self"> <span> startOfWeek </span> </a> as the first day of the week for the calculation. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Omitted: <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-expression-exp.-dateTrunc" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $dateTrunc </code> </span> </a> uses Sunday as the start of the week for the calculation. </p> </li> </ul> </li> </ul> </section> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Examples <a class="headerlink leafygreen-ui-1kepx47" href="#examples" 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="examples"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> Create a <code class="leafygreen-ui-1l06pbn"> cakeSales </code> collection that contains cake sales in the states of California ( <code class="leafygreen-ui-1l06pbn"> CA </code> ) and Washington ( <code class="leafygreen-ui-1l06pbn"> WA </code> ): </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.cakeSales.insertMany( [\n { _id: 0, type: \"chocolate\", orderDate: new Date(\"2020-05-18T14:10:30Z\"),\n state: \"CA\", price: 13, quantity: 120 },\n { _id: 1, type: \"chocolate\", orderDate: new Date(\"2021-03-20T11:30:05Z\"),\n state: \"WA\", price: 14, quantity: 140 },\n { _id: 2, type: \"vanilla\", orderDate: new Date(\"2021-01-11T06:31:15Z\"),\n state: \"CA\", price: 12, quantity: 145 },\n { _id: 3, type: \"vanilla\", orderDate: new Date(\"2020-02-08T13:13:23Z\"),\n state: \"WA\", price: 13, quantity: 104 },\n { _id: 4, type: \"strawberry\", orderDate: new Date(\"2019-05-18T16:09:01Z\"),\n state: \"CA\", price: 41, quantity: 162 },\n { _id: 5, type: \"strawberry\", orderDate: new Date(\"2019-01-08T06:12:03Z\"),\n state: \"WA\", price: 43, quantity: 134 }\n] )","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><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">cakeSales</span>.<span class="lg-highlight-title lg-highlight-function">insertMany</span>( <!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">0</span>, <span class="lg-highlight-attr">type</span>: <span class="lg-highlight-string">"chocolate"</span>, <span class="lg-highlight-attr">orderDate</span>: <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">Date</span>(<span class="lg-highlight-string">"2020-05-18T14:10:30Z"</span>)<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">state</span>: <span class="lg-highlight-string">"CA"</span>, <span class="lg-highlight-attr">price</span>: <span class="lg-highlight-number">13</span>, <span class="lg-highlight-attr">quantity</span>: <span class="lg-highlight-number">120</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">1</span>, <span class="lg-highlight-attr">type</span>: <span class="lg-highlight-string">"chocolate"</span>, <span class="lg-highlight-attr">orderDate</span>: <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">Date</span>(<span class="lg-highlight-string">"2021-03-20T11:30:05Z"</span>)<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">state</span>: <span class="lg-highlight-string">"WA"</span>, <span class="lg-highlight-attr">price</span>: <span class="lg-highlight-number">14</span>, <span class="lg-highlight-attr">quantity</span>: <span class="lg-highlight-number">140</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">2</span>, <span class="lg-highlight-attr">type</span>: <span class="lg-highlight-string">"vanilla"</span>, <span class="lg-highlight-attr">orderDate</span>: <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">Date</span>(<span class="lg-highlight-string">"2021-01-11T06:31:15Z"</span>)<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">state</span>: <span class="lg-highlight-string">"CA"</span>, <span class="lg-highlight-attr">price</span>: <span class="lg-highlight-number">12</span>, <span class="lg-highlight-attr">quantity</span>: <span class="lg-highlight-number">145</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">3</span>, <span class="lg-highlight-attr">type</span>: <span class="lg-highlight-string">"vanilla"</span>, <span class="lg-highlight-attr">orderDate</span>: <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">Date</span>(<span class="lg-highlight-string">"2020-02-08T13:13:23Z"</span>)<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">state</span>: <span class="lg-highlight-string">"WA"</span>, <span class="lg-highlight-attr">price</span>: <span class="lg-highlight-number">13</span>, <span class="lg-highlight-attr">quantity</span>: <span class="lg-highlight-number">104</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">4</span>, <span class="lg-highlight-attr">type</span>: <span class="lg-highlight-string">"strawberry"</span>, <span class="lg-highlight-attr">orderDate</span>: <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">Date</span>(<span class="lg-highlight-string">"2019-05-18T16:09:01Z"</span>)<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">state</span>: <span class="lg-highlight-string">"CA"</span>, <span class="lg-highlight-attr">price</span>: <span class="lg-highlight-number">41</span>, <span class="lg-highlight-attr">quantity</span>: <span class="lg-highlight-number">162</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">5</span>, <span class="lg-highlight-attr">type</span>: <span class="lg-highlight-string">"strawberry"</span>, <span class="lg-highlight-attr">orderDate</span>: <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">Date</span>(<span class="lg-highlight-string">"2019-01-08T06:12:03Z"</span>)<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">state</span>: <span class="lg-highlight-string">"WA"</span>, <span class="lg-highlight-attr">price</span>: <span class="lg-highlight-number">43</span>, <span class="lg-highlight-attr">quantity</span>: <span class="lg-highlight-number">134</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">] )</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 <code class="leafygreen-ui-1l06pbn"> cakeSales </code> collection is used in the following examples. </p> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Truncate Order Dates in a <code class="leafygreen-ui-1l06pbn"> $project </code> Pipeline Stage <a class="headerlink leafygreen-ui-1kepx47" href="#truncate-order-dates-in-a--project-pipeline-stage" 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="truncate-order-dates-in-a--project-pipeline-stage"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> This example uses <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-expression-exp.-dateTrunc" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $dateTrunc </code> </span> </a> in a <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 to truncate the cake sales <code class="leafygreen-ui-1l06pbn"> orderDate </code> values to two weeks: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.cakeSales.aggregate( [\n {\n $project: {\n _id: 1,\n orderDate: 1,\n truncatedOrderDate: {\n $dateTrunc: {\n date: \"$orderDate\", unit: \"week\", binSize: 2,\n timezone: \"America/Los_Angeles\", startOfWeek: \"Monday\"\n }\n }\n }\n }\n] )","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><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">cakeSales</span>.<span class="lg-highlight-title lg-highlight-function">aggregate</span>( <!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">$project</span>: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">1</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">orderDate</span>: <span class="lg-highlight-number">1</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">truncatedOrderDate</span>: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">$dateTrunc</span>: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">date</span>: <span class="lg-highlight-string">"$orderDate"</span>, <span class="lg-highlight-attr">unit</span>: <span class="lg-highlight-string">"week"</span>, <span class="lg-highlight-attr">binSize</span>: <span class="lg-highlight-number">2</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">timezone</span>: <span class="lg-highlight-string">"America/Los_Angeles"</span>, <span class="lg-highlight-attr">startOfWeek</span>: <span class="lg-highlight-string">"Monday"</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">] )</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"> In the example: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <code class="leafygreen-ui-1l06pbn"> $project </code> includes the <code class="leafygreen-ui-1l06pbn"> _id </code> , <code class="leafygreen-ui-1l06pbn"> orderDate </code> , and <code class="leafygreen-ui-1l06pbn"> truncatedOrderDate </code> fields in the output. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <code class="leafygreen-ui-1l06pbn"> $dateTrunc </code> truncates the <code class="leafygreen-ui-1l06pbn"> orderDate </code> field to a <code class="leafygreen-ui-1l06pbn"> 2 </code> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-dateTrunc-binSize" target="_self"> <span> binSize </span> </a> <code class="leafygreen-ui-1l06pbn"> week </code> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-dateTrunc-unit" target="_self"> <span> unit </span> </a> time period in the <code class="leafygreen-ui-1l06pbn"> America/Los_Angeles </code> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-dateTrunc-timezone" target="_self"> <span> timezone </span> </a> with <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-dateTrunc-startOfWeek" target="_self"> <span> startOfWeek </span> </a> set to <code class="leafygreen-ui-1l06pbn"> Monday </code> . </p> </li> </ul> <p class="leafygreen-ui-1kp3ins"> In this example output, the truncated <code class="leafygreen-ui-1l06pbn"> orderDate </code> is shown in the <code class="leafygreen-ui-1l06pbn"> truncatedOrderDate </code> field: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"[\n {\n _id: 0,\n orderDate: ISODate(\"2020-05-18T14:10:30.000Z\"),\n truncatedOrderDate: ISODate(\"2020-05-11T07:00:00.000Z\")\n },\n {\n _id: 1,\n orderDate: ISODate(\"2021-03-20T11:30:05.000Z\"),\n truncatedOrderDate: ISODate(\"2021-03-15T07:00:00.000Z\")\n },\n {\n _id: 2,\n orderDate: ISODate(\"2021-01-11T06:31:15.000Z\"),\n truncatedOrderDate: ISODate(\"2021-01-04T08:00:00.000Z\")\n },\n {\n _id: 3,\n orderDate: ISODate(\"2020-02-08T13:13:23.000Z\"),\n truncatedOrderDate: ISODate(\"2020-02-03T08:00:00.000Z\")\n },\n {\n _id: 4,\n orderDate: ISODate(\"2019-05-18T16:09:01.000Z\"),\n truncatedOrderDate: ISODate(\"2019-05-13T07:00:00.000Z\")\n },\n {\n _id: 5,\n orderDate: ISODate(\"2019-01-08T06:12:03.000Z\"),\n truncatedOrderDate: ISODate(\"2019-01-07T08:00:00.000Z\")\n }\n]","programmingLanguage":"JavaScript"} </script> <div class="css-1lju8ps"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1jheeh3"> <pre class="leafygreen-ui-1453az5" 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">[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">0</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">orderDate</span>: <span class="lg-highlight-title lg-highlight-class">ISODate</span>(<span class="lg-highlight-string">"2020-05-18T14:10:30.000Z"</span>)<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">truncatedOrderDate</span>: <span class="lg-highlight-title lg-highlight-class">ISODate</span>(<span class="lg-highlight-string">"2020-05-11T07:00:00.000Z"</span>)</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">1</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">orderDate</span>: <span class="lg-highlight-title lg-highlight-class">ISODate</span>(<span class="lg-highlight-string">"2021-03-20T11:30:05.000Z"</span>)<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">truncatedOrderDate</span>: <span class="lg-highlight-title lg-highlight-class">ISODate</span>(<span class="lg-highlight-string">"2021-03-15T07:00:00.000Z"</span>)</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">2</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">orderDate</span>: <span class="lg-highlight-title lg-highlight-class">ISODate</span>(<span class="lg-highlight-string">"2021-01-11T06:31:15.000Z"</span>)<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">truncatedOrderDate</span>: <span class="lg-highlight-title lg-highlight-class">ISODate</span>(<span class="lg-highlight-string">"2021-01-04T08:00:00.000Z"</span>)</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">3</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">orderDate</span>: <span class="lg-highlight-title lg-highlight-class">ISODate</span>(<span class="lg-highlight-string">"2020-02-08T13:13:23.000Z"</span>)<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">truncatedOrderDate</span>: <span class="lg-highlight-title lg-highlight-class">ISODate</span>(<span class="lg-highlight-string">"2020-02-03T08:00:00.000Z"</span>)</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">4</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">orderDate</span>: <span class="lg-highlight-title lg-highlight-class">ISODate</span>(<span class="lg-highlight-string">"2019-05-18T16:09:01.000Z"</span>)<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">truncatedOrderDate</span>: <span class="lg-highlight-title lg-highlight-class">ISODate</span>(<span class="lg-highlight-string">"2019-05-13T07:00:00.000Z"</span>)</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">5</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">orderDate</span>: <span class="lg-highlight-title lg-highlight-class">ISODate</span>(<span class="lg-highlight-string">"2019-01-08T06:12:03.000Z"</span>)<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">truncatedOrderDate</span>: <span class="lg-highlight-title lg-highlight-class">ISODate</span>(<span class="lg-highlight-string">"2019-01-07T08:00:00.000Z"</span>)</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">]</td></tr></tbody></table></code></pre> </div> </div> </div> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Truncate Order Dates and Obtain Quantity Sum in a <code class="leafygreen-ui-1l06pbn"> $group </code> Pipeline Stage <a class="headerlink leafygreen-ui-1kepx47" href="#truncate-order-dates-and-obtain-quantity-sum-in-a--group-pipeline-stage" 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="truncate-order-dates-and-obtain-quantity-sum-in-a--group-pipeline-stage"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> This example uses <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-expression-exp.-dateTrunc" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $dateTrunc </code> </span> </a> in a <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/group/#mongodb-pipeline-pipe.-group"> <code class="leafygreen-ui-1l06pbn"> $group </code> </a> stage to truncate the cake sales <code class="leafygreen-ui-1l06pbn"> orderDate </code> values to six months and return the sum of the <code class="leafygreen-ui-1l06pbn"> quantity </code> values: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.cakeSales.aggregate( [\n {\n $group: {\n _id: {\n truncatedOrderDate: {\n $dateTrunc: {\n date: \"$orderDate\", unit: \"month\", binSize: 6\n }\n }\n },\n sumQuantity: { $sum: \"$quantity\" }\n }\n }\n] )","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><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">cakeSales</span>.<span class="lg-highlight-title lg-highlight-function">aggregate</span>( <!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">$group</span>: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">_id</span>: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">truncatedOrderDate</span>: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">$dateTrunc</span>: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">date</span>: <span class="lg-highlight-string">"$orderDate"</span>, <span class="lg-highlight-attr">unit</span>: <span class="lg-highlight-string">"month"</span>, <span class="lg-highlight-attr">binSize</span>: <span class="lg-highlight-number">6</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">sumQuantity</span>: <!-- -->{ <span class="lg-highlight-attr">$sum</span>: <span class="lg-highlight-string">"$quantity"</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">] )</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"> In the example: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <code class="leafygreen-ui-1l06pbn"> $group </code> has the <code class="leafygreen-ui-1l06pbn"> _id </code> field set to the <code class="leafygreen-ui-1l06pbn"> truncatedOrderDate </code> field to group the <code class="leafygreen-ui-1l06pbn"> cakeSales </code> documents, and returns the sum of the <code class="leafygreen-ui-1l06pbn"> quantity </code> values for each group using <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/sum/#mongodb-group-grp.-sum"> <code class="leafygreen-ui-1l06pbn"> $sum </code> . </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <code class="leafygreen-ui-1l06pbn"> $dateTrunc </code> truncates the <code class="leafygreen-ui-1l06pbn"> orderDate </code> field to a <code class="leafygreen-ui-1l06pbn"> 6 </code> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-dateTrunc-binSize" target="_self"> <span> binSize </span> </a> <code class="leafygreen-ui-1l06pbn"> month </code> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-dateTrunc-unit" target="_self"> <span> unit </span> </a> time period. </p> </li> </ul> <p class="leafygreen-ui-1kp3ins"> In this example output, the truncated <code class="leafygreen-ui-1l06pbn"> orderDate </code> is shown in the <code class="leafygreen-ui-1l06pbn"> truncatedOrderDate </code> field and the <code class="leafygreen-ui-1l06pbn"> quantity </code> sum is shown in the <code class="leafygreen-ui-1l06pbn"> sumQuantity </code> field: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"[\n {\n _id: { truncatedOrderDate: ISODate(\"2020-01-01T00:00:00.000Z\") },\n sumQuantity: 224\n },\n {\n _id: { truncatedOrderDate: ISODate(\"2021-01-01T00:00:00.000Z\") },\n sumQuantity: 285\n },\n {\n _id: { truncatedOrderDate: ISODate(\"2019-01-01T00:00:00.000Z\") },\n sumQuantity: 296\n }\n]","programmingLanguage":"JavaScript"} </script> <div class="css-1lju8ps"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-tyg50d"> <pre class="leafygreen-ui-1453az5" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">_id</span>: <!-- -->{ <span class="lg-highlight-attr">truncatedOrderDate</span>: <span class="lg-highlight-title lg-highlight-class">ISODate</span>(<span class="lg-highlight-string">"2020-01-01T00:00:00.000Z"</span>) }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">sumQuantity</span>: <span class="lg-highlight-number">224</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">_id</span>: <!-- -->{ <span class="lg-highlight-attr">truncatedOrderDate</span>: <span class="lg-highlight-title lg-highlight-class">ISODate</span>(<span class="lg-highlight-string">"2021-01-01T00:00:00.000Z"</span>) }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">sumQuantity</span>: <span class="lg-highlight-number">285</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">_id</span>: <!-- -->{ <span class="lg-highlight-attr">truncatedOrderDate</span>: <span class="lg-highlight-title lg-highlight-class">ISODate</span>(<span class="lg-highlight-string">"2019-01-01T00:00:00.000Z"</span>) }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">sumQuantity</span>: <span class="lg-highlight-number">296</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">]</td></tr></tbody></table></code></pre> </div> </div> </div> </section> </section> </section>
https://www.mongodb.com/docs/manual/reference/operator/query/center/
<section> <h1 class="contains-headerlink leafygreen-ui-41fr9s" weight="medium"> $center <a class="headerlink leafygreen-ui-1kepx47" href="#-center" 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="-center"> </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="#definition" target="_self"> <span> Definition </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#behavior" target="_self"> <span> Behavior </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#example" target="_self"> <span> Example </span> </a> </li> </ul> </div> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Definition <a class="headerlink leafygreen-ui-1kepx47" href="#definition" 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="definition"> </div> </a> </h2> <dl class="query"> <dt> <code class="leafygreen-ui-1l06pbn"> $center </code> <a class="headerlink leafygreen-ui-1kepx47" href="#mongodb-query-op.-center" title="Permalink to this definition"> <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="mongodb-query-op.-center"> </div> </a> </dt> <dd> <p class="leafygreen-ui-1kp3ins"> The <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-query-op.-center" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $center </code> </span> </a> operator specifies a circle for a <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/query/geoWithin/#mongodb-query-op.-geoWithin"> <code class="leafygreen-ui-1l06pbn"> $geoWithin </code> </a> query. The query returns legacy coordinate pairs that are within the bounds of the circle. The operator does <em> not </em> return GeoJSON objects. </p> <p class="leafygreen-ui-1kp3ins"> To use the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-query-op.-center" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $center </code> </span> </a> operator, specify an array that contains: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> The grid coordinates of the circle's center point, and </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> The circle's radius, as measured in the units used by the coordinate system. </p> </li> </ul> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{\n &lt;location&gt;: {\n $geoWithin: { $center: [ [ &lt;x&gt;, &lt;y&gt; ] , &lt;radius&gt; ] }\n }\n}","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->&lt;location field&gt;: {</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> $geoWithin: { $center: [ [ &lt;x&gt;, &lt;y&gt; ] , &lt;radius&gt; ] }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">}</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-85da11" role="note"> <h2 class="leafygreen-ui-1ac4g5h"> Important </h2> <h3 class="leafygreen-ui-144d5kf"> <strong> If you use longitude and latitude, specify longitude first. </strong> </h3> <div class="leafygreen-ui-9mycqc"> </div> </div> </dd> </dl> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Behavior <a class="headerlink leafygreen-ui-1kepx47" href="#behavior" 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="behavior"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> The query calculates distances using flat (planar) geometry. </p> <p class="leafygreen-ui-1kp3ins"> Applications can use <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-query-op.-center" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $center </code> </span> </a> <em> without </em> having a geospatial index. However, geospatial indexes support much faster queries than the unindexed equivalents. </p> <p class="leafygreen-ui-1kp3ins"> Only the <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/indexes/index-types/geospatial/2d/#std-label-2d-index"> 2d </a> geospatial index supports <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-query-op.-center" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $center </code> . </span> </a> </p> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Example <a class="headerlink leafygreen-ui-1kepx47" href="#example" 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="example"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> The following example query returns all documents that have coordinates that exist within the circle centered on <code class="leafygreen-ui-1l06pbn"> [ -74, 40.74 ] </code> and with a radius of <code class="leafygreen-ui-1l06pbn"> 10 </code> : </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.places.find(\n { loc: { $geoWithin: { $center: [ [-74, 40.74], 10 ] } } }\n)","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><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">places</span>.<span class="lg-highlight-title lg-highlight-function">find</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">loc</span>: <!-- -->{ <span class="lg-highlight-attr">$geoWithin</span>: <!-- -->{ <span class="lg-highlight-attr">$center</span>: <!-- -->[ <!-- -->[<!-- -->-<span class="lg-highlight-number">74</span>, <span class="lg-highlight-number">40.74</span>]<!-- -->, <span class="lg-highlight-number">10</span> ] } } }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">)</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> </section> </section>
https://www.mongodb.com/docs/manual/reference/command/getDefaultRWConcern/
<section> <h1 class="contains-headerlink leafygreen-ui-41fr9s" weight="medium"> getDefaultRWConcern <a class="headerlink leafygreen-ui-1kepx47" href="#getdefaultrwconcern" 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="getdefaultrwconcern"> </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="#definition" target="_self"> <span> Definition </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#compatibility" target="_self"> <span> Compatibility </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#syntax" target="_self"> <span> Syntax </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#command-fields" target="_self"> <span> Command Fields </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#output" target="_self"> <span> Output </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#behavior" target="_self"> <span> Behavior </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#example" target="_self"> <span> Example </span> </a> </li> </ul> </div> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Definition <a class="headerlink leafygreen-ui-1kepx47" href="#definition" 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="definition"> </div> </a> </h2> <dl class="dbcommand"> <dt> <code class="leafygreen-ui-1l06pbn"> getDefaultRWConcern </code> <a class="headerlink leafygreen-ui-1kepx47" href="#mongodb-dbcommand-dbcmd.getDefaultRWConcern" title="Permalink to this definition"> <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="mongodb-dbcommand-dbcmd.getDefaultRWConcern"> </div> </a> </dt> <dd> <p class="leafygreen-ui-1kp3ins"> The <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-dbcommand-dbcmd.getDefaultRWConcern" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> getDefaultRWConcern </code> </span> </a> administrative command retrieves the global default read or write concern settings. </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> For sharded clusters, issue the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-dbcommand-dbcmd.getDefaultRWConcern" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> getDefaultRWConcern </code> </span> </a> on a <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongos/#mongodb-binary-bin.mongos"> <code class="leafygreen-ui-1l06pbn"> mongos </code> . </a> </p> </li> </ul> </dd> </dl> </section> <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"> This command is available in 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> <div class="leafygreen-ui-15mdk4" role="note"> <h2 class="leafygreen-ui-6n7b7d"> Note </h2> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> This command is supported in all MongoDB Atlas clusters. For information on Atlas support for all commands, see <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/atlas/unsupported-commands/" target="_self"> <span> Unsupported Commands <!-- --> . </span> </a> </p> </div> </div> <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"> Syntax <a class="headerlink leafygreen-ui-1kepx47" href="#syntax" 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="syntax"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> The command has the following form: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.adminCommand(\n {\n getDefaultRWConcern: 1 ,\n inMemory: &lt;boolean&gt;,\n comment: &lt;any&gt;\n }\n)","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">adminCommand</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">getDefaultRWConcern</span>: <span class="lg-highlight-number">1</span> <!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">inMemory</span>: &lt;<!-- -->boolean<!-- -->&gt;<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">comment</span>: &lt;<!-- -->any<!-- -->&gt;</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->}</td></tr><tr class=""><td class="leafygreen-ui-7razhx">)</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> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Command Fields <a class="headerlink leafygreen-ui-1kepx47" href="#command-fields" 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="command-fields"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> The command has the following fields: </p> <div class="leafygreen-ui-skkc39" tabindex="0"> <table class="leafygreen-ui-hr8lsv"> <colgroup> <col style="width:20%"/> <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> Field </div> </div> </th> <th class="leafygreen-ui-13uteka" role="columnheader" scope="col"> <div class="leafygreen-ui-ui0te9"> <div> Type </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="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-getDefaultRWConcern-cmd-getDefaultRWConcern" target="_self"> <span> getDefaultRWConcern </span> </a> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> int </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <span class="leafygreen-ui-1qnjd6d" id="std-label-getDefaultRWConcern-cmd-getDefaultRWConcern"> </span> <p class="leafygreen-ui-1kp3ins"> Set to <code class="leafygreen-ui-1l06pbn"> 1 </code> . </p> </div> </div> </td> </tr> <tr class=""> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-getDefaultRWConcern-cmd-inMemory" target="_self"> <span> inMemory </span> </a> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> boolean </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <span class="leafygreen-ui-1qnjd6d" id="std-label-getDefaultRWConcern-cmd-inMemory"> </span> <p class="leafygreen-ui-1kp3ins"> Optional. </p> <p class="leafygreen-ui-1kp3ins"> Set to <code class="leafygreen-ui-1l06pbn"> true </code> to return the in-memory cached copy of the global default read or write concern settings. The instance uses the in-memory copy when applying the global defaults to an operation. </p> <p class="leafygreen-ui-1kp3ins"> Set to <code class="leafygreen-ui-1l06pbn"> false </code> to return the on-disk copy of the deployment's global default read or write concern. Defaults to <code class="leafygreen-ui-1l06pbn"> false </code> . </p> </div> </div> </td> </tr> <tr class=""> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> comment </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> any </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <p class="leafygreen-ui-1kp3ins"> Optional. A user-provided comment to attach to this command. Once set, this comment appears alongside records of this command in the following locations: </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/log-messages/#std-label-log-messages-ref"> mongod log messages </a> , in the <code class="leafygreen-ui-1l06pbn"> attr.command.cursor.comment </code> field. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/database-profiler/#std-label-profiler"> Database profiler </a> output, in the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/database-profiler/#mongodb-data-system.profile.command"> <code class="leafygreen-ui-1l06pbn"> command.comment </code> </a> field. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/command/currentOp/#mongodb-dbcommand-dbcmd.currentOp"> <code class="leafygreen-ui-1l06pbn"> currentOp </code> </a> output, in the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/command/currentOp/#mongodb-data-currentOp.command"> <code class="leafygreen-ui-1l06pbn"> command.comment </code> </a> field. </p> </li> </ul> <p class="leafygreen-ui-1kp3ins"> A comment can be any valid <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/bson-types/#std-label-bson-types"> BSON type </a> (string, integer, object, array, etc). </p> </div> </div> </td> </tr> </tbody> </table> </div> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Output <a class="headerlink leafygreen-ui-1kepx47" href="#output" 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="output"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> The output may include the following fields: </p> <div class="leafygreen-ui-skkc39" tabindex="0"> <table class="leafygreen-ui-hr8lsv"> <colgroup> <col style="width:20%"/> <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> Field </div> </div> </th> <th class="leafygreen-ui-13uteka" role="columnheader" scope="col"> <div class="leafygreen-ui-ui0te9"> <div> Type </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="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-getDefaultRWConcern-cmd-defaultWriteConcern" target="_self"> <span> defaultWriteConcern </span> </a> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> object </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <span class="leafygreen-ui-1qnjd6d" id="std-label-getDefaultRWConcern-cmd-defaultWriteConcern"> </span> <p class="leafygreen-ui-1kp3ins"> The global default <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/write-concern/#std-label-write-concern"> write concern </a> configuration. </p> <p class="leafygreen-ui-1kp3ins"> If the deployment has no global default write concern settings, this field is absent from <code class="leafygreen-ui-1l06pbn"> getDefaultRWConcern </code> output. </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="#std-label-getDefaultRWConcern-cmd-defaultReadConcern" target="_self"> <span> defaultReadConcern </span> </a> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> object </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <span class="leafygreen-ui-1qnjd6d" id="std-label-getDefaultRWConcern-cmd-defaultReadConcern"> </span> <p class="leafygreen-ui-1kp3ins"> The global default <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/read-concern/#std-label-read-concern"> read concern </a> configuration. </p> <p class="leafygreen-ui-1kp3ins"> If the deployment has no global default read concern settings, this field is absent from <code class="leafygreen-ui-1l06pbn"> getDefaultRWConcern </code> output. </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="#std-label-getDefaultRWConcern-cmd-defaultWriteConcernSource" target="_self"> <span> defaultWriteConcernSource </span> </a> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> String </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <span class="leafygreen-ui-1qnjd6d" id="std-label-getDefaultRWConcern-cmd-defaultWriteConcernSource"> </span> <p class="leafygreen-ui-1kp3ins"> The source of the default <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/write-concern/#std-label-write-concern"> write concern </a> . By default, the value is <code class="leafygreen-ui-1l06pbn"> "implicit" </code> . Once you set the default write concern with <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/command/setDefaultRWConcern/#mongodb-dbcommand-dbcmd.setDefaultRWConcern"> <code class="leafygreen-ui-1l06pbn"> setDefaultRWConcern </code> </a> , the value becomes <code class="leafygreen-ui-1l06pbn"> "global" </code> . </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="#std-label-getDefaultRWConcern-cmd-defaultReadConcernSource" target="_self"> <span> defaultReadConcernSource </span> </a> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> String </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <span class="leafygreen-ui-1qnjd6d" id="std-label-getDefaultRWConcern-cmd-defaultReadConcernSource"> </span> <p class="leafygreen-ui-1kp3ins"> The source of the default <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/read-concern/#std-label-read-concern"> read concern </a> . By default, the value is <code class="leafygreen-ui-1l06pbn"> "implicit" </code> . Once you set the default read concern with <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/command/setDefaultRWConcern/#mongodb-dbcommand-dbcmd.setDefaultRWConcern"> <code class="leafygreen-ui-1l06pbn"> setDefaultRWConcern </code> </a> , the value becomes <code class="leafygreen-ui-1l06pbn"> "global" </code> . </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="#std-label-getDefaultRWConcern-cmd-updateOpTime" target="_self"> <span> updateOpTime </span> </a> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Timestamp </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <span class="leafygreen-ui-1qnjd6d" id="std-label-getDefaultRWConcern-cmd-updateOpTime"> </span> <p class="leafygreen-ui-1kp3ins"> The operation timestamp of when any global default read or write concern setting was last modified. Present if a default has ever been set for the cluster. </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="#std-label-getDefaultRWConcern-cmd-updateWallClockTime" target="_self"> <span> updateWallClockTime </span> </a> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Date </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <span class="leafygreen-ui-1qnjd6d" id="std-label-getDefaultRWConcern-cmd-updateWallClockTime"> </span> <p class="leafygreen-ui-1kp3ins"> The wall clock date when an administrator last set the global default read or write concern. This value is informational and should not be used for any recency comparisons. </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="#std-label-getDefaultRWConcern-cmd-localUpdateWallClockTime" target="_self"> <span> localUpdateWallClockTime </span> </a> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Date </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <span class="leafygreen-ui-1qnjd6d" id="std-label-getDefaultRWConcern-cmd-localUpdateWallClockTime"> </span> <p class="leafygreen-ui-1kp3ins"> The wall clock date when the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> or <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongos/#mongodb-binary-bin.mongos"> <code class="leafygreen-ui-1l06pbn"> mongos </code> </a> last updated its local copy of the global default read and write concern settings. This value is informational and should not be used for any recency comparisons. </p> </div> </div> </td> </tr> </tbody> </table> </div> <div class="leafygreen-ui-13vw3ie" role="note"> <h2 class="leafygreen-ui-1fn4p2b"> Tip </h2> <h3 class="leafygreen-ui-144d5kf"> <strong> See also: </strong> </h3> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/command/setDefaultRWConcern/#mongodb-dbcommand-dbcmd.setDefaultRWConcern"> <code class="leafygreen-ui-1l06pbn"> setDefaultRWConcern </code> </a> </p> </div> </div> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Behavior <a class="headerlink leafygreen-ui-1kepx47" href="#behavior" 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="behavior"> </div> </a> </h2> <div class="leafygreen-ui-15mdk4" role="note"> <h2 class="leafygreen-ui-6n7b7d"> Note </h2> <h3 class="leafygreen-ui-144d5kf"> <strong> Requires featureCompatibilityVersion 4.4+ </strong> </h3> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> Each <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> in the replica set or sharded cluster <em> must </em> have <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/command/setFeatureCompatibilityVersion/#std-label-set-fcv"> featureCompatibilityVersion </a> set to at least <code class="leafygreen-ui-1l06pbn"> 4.4 </code> to use <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-dbcommand-dbcmd.getDefaultRWConcern" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> getDefaultRWConcern </code> </span> </a> . If you downgrade your deployment's <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/command/setFeatureCompatibilityVersion/#std-label-set-fcv"> featureCompatibilityVersion </a> from <code class="leafygreen-ui-1l06pbn"> 4.4 </code> to <code class="leafygreen-ui-1l06pbn"> 4.2 </code> , all cluster-wide read and write concern defaults are lost, but <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongos/#mongodb-binary-bin.mongos"> <code class="leafygreen-ui-1l06pbn"> mongos </code> </a> instances may continue applying the defaults for up to 30 seconds. </p> </div> </div> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Replica Sets <a class="headerlink leafygreen-ui-1kepx47" href="#replica-sets" 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="replica-sets"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> You can issue <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-dbcommand-dbcmd.getDefaultRWConcern" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> getDefaultRWConcern </code> </span> </a> against any data-bearing member of the replica set (i.e. not against an <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-arbiter"> arbiter </a> ). </p> <p class="leafygreen-ui-1kp3ins"> A secondary can return a 'stale' version of the global default settings if it has not yet replicated the latest changes from the primary. </p> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Sharded Clusters <a class="headerlink leafygreen-ui-1kepx47" href="#sharded-clusters" 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="sharded-clusters"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> Issue the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/command/setDefaultRWConcern/#mongodb-dbcommand-dbcmd.setDefaultRWConcern"> <code class="leafygreen-ui-1l06pbn"> setDefaultRWConcern </code> </a> against a <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongos/#mongodb-binary-bin.mongos"> <code class="leafygreen-ui-1l06pbn"> mongos </code> </a> in the cluster. </p> <p class="leafygreen-ui-1kp3ins"> Each <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongos/#mongodb-binary-bin.mongos"> <code class="leafygreen-ui-1l06pbn"> mongos </code> </a> periodically refreshes its local copy of the global default settings. A <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongos/#mongodb-binary-bin.mongos"> <code class="leafygreen-ui-1l06pbn"> mongos </code> </a> can return a 'stale' version of the global default settings if it has not yet refreshed its local copy after a recent update to the global default settings <em> or </em> if it fetched its settings from a lagged <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/sharded-cluster-config-servers/#std-label-sharding-config-server"> config server secondary <!-- --> . </a> </p> <p class="leafygreen-ui-1kp3ins"> The global default settings do <em> not </em> propagate to the individual shards. You cannot run <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-dbcommand-dbcmd.getDefaultRWConcern" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> getDefaultRWConcern </code> </span> </a> against a shard. </p> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Access Control <a class="headerlink leafygreen-ui-1kepx47" href="#access-control" 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="access-control"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> For replica sets or sharded clusters enforcing <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/authentication/#std-label-authentication"> Authentication on Self-Managed Deployments </a> , <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-dbcommand-dbcmd.getDefaultRWConcern" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> getDefaultRWConcern </code> </span> </a> requires that the authenticated user have the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/privilege-actions/#mongodb-authaction-getDefaultRWConcern"> <code class="leafygreen-ui-1l06pbn"> getDefaultRWConcern </code> </a> privilege action. </p> <p class="leafygreen-ui-1kp3ins"> The <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/built-in-roles/#mongodb-authrole-clusterManager"> <code class="leafygreen-ui-1l06pbn"> clusterManager </code> </a> or <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/built-in-roles/#mongodb-authrole-clusterMonitor"> <code class="leafygreen-ui-1l06pbn"> clusterMonitor </code> </a> built-in roles provides the required privileges to run <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-dbcommand-dbcmd.getDefaultRWConcern" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> getDefaultRWConcern </code> . </span> </a> </p> </section> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Example <a class="headerlink leafygreen-ui-1kepx47" href="#example" 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="example"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> The following operation retrieves the currently configured global default read and write concern for the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> . </a> </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.adminCommand({\n \"getDefaultRWConcern\": 1\n})","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">adminCommand</span>(<!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"getDefaultRWConcern"</span>: <span class="lg-highlight-number">1</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx">})</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 operation returns output similar to the following: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{\n \"defaultWriteConcern\" : {\n \"w\" : \"majority\"\n },\n \"defaultReadConcern\" : {\n \"level\" : \"majority\"\n },\n \"defaultWriteConcernSource\" : \"global\",\n \"defaultReadConcernSource\" : \"global\",\n \"updateOpTime\" : Timestamp(1586290895, 1),\n \"updateWallClockTime\" : ISODate(\"2020-04-07T20:21:41.849Z\"),\n \"localUpdateWallClockTime\" : ISODate(\"2020-04-07T20:21:41.862Z\"),\n \"ok\" : 1,\n \"$clusterTime\" : { ... }\n \"operationTime\" : Timestamp(1586290925, 1)\n}","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"defaultWriteConcern"</span> <!-- -->: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"w"</span> <!-- -->: <span class="lg-highlight-string">"majority"</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"defaultReadConcern"</span> <!-- -->: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"level"</span> <!-- -->: <span class="lg-highlight-string">"majority"</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"defaultWriteConcernSource"</span> <!-- -->: <span class="lg-highlight-string">"global"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"defaultReadConcernSource"</span> <!-- -->: <span class="lg-highlight-string">"global"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"updateOpTime"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">Timestamp</span>(<span class="lg-highlight-number">1586290895</span>, <span class="lg-highlight-number">1</span>)<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"updateWallClockTime"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">ISODate</span>(<span class="lg-highlight-string">"2020-04-07T20:21:41.849Z"</span>)<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"localUpdateWallClockTime"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">ISODate</span>(<span class="lg-highlight-string">"2020-04-07T20:21:41.862Z"</span>)<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"ok"</span> <!-- -->: <span class="lg-highlight-number">1</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"$clusterTime"</span> <!-- -->: <!-- -->{ <!-- -->...<!-- --> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"operationTime"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">Timestamp</span>(<span class="lg-highlight-number">1586290925</span>, <span class="lg-highlight-number">1</span>)</td></tr><tr class=""><td class="leafygreen-ui-7razhx">}</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> </section> </section>
https://www.mongodb.com/docs/manual/core/timeseries-collections/
<section> <h1 class="contains-headerlink leafygreen-ui-41fr9s" weight="medium"> Time Series <a class="headerlink leafygreen-ui-1kepx47" href="#time-series" 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="time-series"> </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="#time-series-collections" target="_self"> <span> Time Series Collections </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-x9koo9" href="#benefits" target="_self"> <span> Benefits </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-x9koo9" href="#example-use-cases" target="_self"> <span> Example Use Cases </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-x9koo9" href="#behavior" target="_self"> <span> Behavior </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-x9koo9" href="#metafields" target="_self"> <span> metaFields </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-x9koo9" href="#indexes" target="_self"> <span> Indexes </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#get-started" target="_self"> <span> Get Started </span> </a> </li> </ul> </div> <p class="leafygreen-ui-1kp3ins"> Time series data is a sequence of data points in which insights are gained by analyzing changes over time. </p> <p class="leafygreen-ui-1kp3ins"> Time series data is generally composed of these components: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <strong> Time </strong> when the data point was recorded. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <strong> metadata </strong> (sometimes referred to as source), which is a label or tag that identifies a data series and rarely changes. Metadata is stored in a metaField. You cannot add metaFields to time series documents after you create them. For more information on metaField behavior and selection, see <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-timeseries-collections-metafield" target="_self"> <span> metaFields. </span> </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <strong> Measurements </strong> (sometimes referred to as metrics or values), which are the data points tracked at increments in time. Generally these are key-value pairs that change over time. </p> </li> </ul> <p class="leafygreen-ui-1kp3ins"> This table shows examples of time series data: </p> <div class="leafygreen-ui-skkc39" tabindex="0"> <table class="leafygreen-ui-hr8lsv"> <colgroup> <col style="width: 30%;"/> <col style="width: 30%;"/> <col style="width: 40%;"/> </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> <strong> Example </strong> </div> </div> </th> <th class="leafygreen-ui-13uteka" role="columnheader" scope="col"> <div class="leafygreen-ui-ui0te9"> <div> <strong> Measurement </strong> </div> </div> </th> <th class="leafygreen-ui-13uteka" role="columnheader" scope="col"> <div class="leafygreen-ui-ui0te9"> <div> <strong> Metadata </strong> </div> </div> </th> </tr> </thead> <tbody> <tr class=""> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Stock data </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Stock price </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Stock ticker, exchange </div> </div> </td> </tr> <tr class=""> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Weather data </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Temperature </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Sensor identifier, location </div> </div> </td> </tr> <tr class=""> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Website visitors </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> View count </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> URL </div> </div> </td> </tr> </tbody> </table> </div> <p class="leafygreen-ui-1kp3ins"> For efficient time series data storage, MongoDB provides time series collections. </p> <span class="leafygreen-ui-1qnjd6d" id="std-label-manual-timeseries-collection"> </span> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Time Series Collections <a class="headerlink leafygreen-ui-1kepx47" href="#time-series-collections" 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="time-series-collections"> </div> </a> </h2> <div> <p> <em> New in version 5.0 </em> . </p> </div> <p class="leafygreen-ui-1kp3ins"> Time series collections efficiently store time series data. In time series collections, writes are organized so that data from the same source is stored alongside other data points from a similar point in time. </p> <a class="css-53dzkk" href="https://www.mongodb.com/docs/atlas/atlas-ui/collections/#std-label-atlas-ui-create-a-collection"> <div class="css-z0l49d"> <div class="css-fw7ipj"> <svg aria-label="Cloud Icon" class="leafygreen-ui-1t2jgtk" fill="none" height="16" role="img" viewbox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"> <path d="M12.571 8.143c0 1.775-.899 3.34-2.267 4.264l-.014.01a5.12 5.12 0 0 1-2.861.869H2.857a2.857 2.857 0 0 1-.545-5.663 5.144 5.144 0 0 1 10.26.52ZM13.821 8.143a6.38 6.38 0 0 1-2.358 4.96 3.429 3.429 0 1 0 2.17-6.506c.123.494.188 1.013.188 1.546Z" fill="currentColor"> </path> </svg> </div> <p class="leafygreen-ui-1kp3ins"> You can <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/atlas/atlas-ui/collections/#std-label-atlas-ui-create-a-collection" target="_self"> <span> create time series collections in the UI </span> </a> for deployments hosted in <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> </p> </div> </a> <div class="leafygreen-ui-85da11" role="note"> <h2 class="leafygreen-ui-1ac4g5h"> Important </h2> <h3 class="leafygreen-ui-144d5kf"> <strong> Backwards-Incompatible Feature </strong> </h3> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> You must drop time series collections before downgrading: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> MongoDB 6.0 or later to MongoDB 5.0.7 or earlier. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> MongoDB 5.3 to MongoDB 5.0.5 or earlier. </p> </li> </ul> </div> </div> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Benefits <a class="headerlink leafygreen-ui-1kepx47" href="#benefits" 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="benefits"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> Compared to normal collections, storing time series data in time series collections improves query efficiency and reduces the disk usage for time series data and <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-secondary-index"> secondary indexes </a> . MongoDB 6.3 and later automatically creates a <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/indexes/index-types/index-compound/#std-label-index-type-compound"> compound index </a> on the time and metadata fields for new time series collections. </p> <p class="leafygreen-ui-1kp3ins"> Time series collections use an underlying columnar storage format and store data in time-order. This format provides the following benefits: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Reduced complexity for working with time series data </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Improved query efficiency </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Reduced disk usage </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Reduced I/O for read operations </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Increased WiredTiger cache usage </p> </li> </ul> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Example Use Cases <a class="headerlink leafygreen-ui-1kepx47" href="#example-use-cases" 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="example-use-cases"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> Time Series collections are optimal for analyzing data over time. The following table illustrates use cases for time series data: </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> Industry </div> </div> </th> <th class="leafygreen-ui-13uteka" role="columnheader" scope="col"> <div class="leafygreen-ui-ui0te9"> <div> Examples </div> </div> </th> </tr> </thead> <tbody> <tr class=""> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Internet of Things (IoT) </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Sensor data (for example, smart home devices or fleet logistics) </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Machine learning and artificial intelligence scraping </p> </li> </ul> </div> </div> </td> </tr> <tr class=""> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Financial Services </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> High frequency trading </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Financial quantitative analysis </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Banking data (for example, accounting of banking transactions over time) </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Stock market data </p> </li> </ul> </div> </div> </td> </tr> <tr class=""> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Retail and E-Commerce </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Transaction, sales, and price analysis </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Inventory management </p> </li> </ul> </div> </div> </td> </tr> <tr class=""> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> DevOps </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Application logging </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Infrastructure and network monitoring </p> </li> </ul> </div> </div> </td> </tr> </tbody> </table> </div> <p class="leafygreen-ui-1kp3ins"> Time Series collections are not intended for the following types of data: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Unordered data </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Data that is not time-dependent </p> </li> </ul> <span class="leafygreen-ui-1qnjd6d" id="std-label-timeseries-collections-behavior"> </span> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Behavior <a class="headerlink leafygreen-ui-1kepx47" href="#behavior" 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="behavior"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> Time series collections generally behave like other MongoDB collections. You insert and query data as usual. </p> <div class="leafygreen-ui-1sjx7ru" role="note"> <h2 class="leafygreen-ui-29m78u"> Warning </h2> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> Match expressions in update commands can only specify the metaField. You can't update other fields in a time series document. For more details, see <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/timeseries/timeseries-limitations/#std-label-timeseries-limitations-updates"> Time Series Update Limitations. </a> </p> </div> </div> <p class="leafygreen-ui-1kp3ins"> MongoDB treats time series collections as writable non-materialized <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/views/#std-label-views-landing-page"> views </a> backed by an internal collection. When you insert data, the internal collection automatically organizes time series data into an optimized storage format. </p> <p class="leafygreen-ui-1kp3ins"> Starting in MongoDB 6.3: if you create a new time series collection, MongoDB also generates a <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/indexes/index-types/index-compound/create-compound-index/#std-label-index-create-compound"> compound index </a> on the <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/timeseries/timeseries-procedures/#std-label-time-series-fields"> metaField and timeField </a> fields. To improve query performance, queries on time series collections use the new compound index. The compound index also uses the optimized storage format. </p> <div class="leafygreen-ui-1sjx7ru" role="note"> <h2 class="leafygreen-ui-29m78u"> Warning </h2> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> Do not attempt to create a time series collection or view with the name <code class="leafygreen-ui-1l06pbn"> system.profile </code> . MongoDB 6.3 and later versions return an <code class="leafygreen-ui-1l06pbn"> IllegalOperation </code> error if you attempt to do so. <strong> Earlier MongoDB versions crash. </strong> </p> </div> </div> <p class="leafygreen-ui-1kp3ins"> Starting in MongoDB 8.0, use of the <code class="leafygreen-ui-1l06pbn"> timeField </code> as a shard key in a time series collection is deprecated. </p> <p class="leafygreen-ui-1kp3ins"> Also, starting in MongoDB 8.0, if you create a time series collection with a shard key containing the <code class="leafygreen-ui-1l06pbn"> timeField </code> , a <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/log-messages/#std-label-log-messages-ref"> log message </a> is added to the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/log-messages/#std-label-log-message-destinations"> log file </a> on the <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/sharded-cluster-shards/#std-label-primary-shard"> primary shard </a> . In addition, a log message is added every 12 hours on the primary node of the <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/sharded-cluster-config-servers/#std-label-csrs"> config server replica set </a> . The log messages state that using the <code class="leafygreen-ui-1l06pbn"> timeField </code> as a shard key in a time series collection is deprecated and you must reshard your collection using the <code class="leafygreen-ui-1l06pbn"> metaField </code> . </p> <span class="leafygreen-ui-1qnjd6d" id="std-label-timeseries-collections-metafield"> </span> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> metaFields <a class="headerlink leafygreen-ui-1kepx47" href="#metafields" 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="metafields"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> Time series documents can contain a metaField with metadata about each document. MongoDB uses the metaField to group sets of documents, both for internal storage optimization and query efficiency. For more information about the metaField, see <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/timeseries/timeseries-considerations/#std-label-timeseries-metafield-considerations"> metaField Considerations. </a> </p> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Indexes <a class="headerlink leafygreen-ui-1kepx47" href="#indexes" 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="indexes"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> MongoDB automatically creates a <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/indexes/index-types/index-compound/#std-label-index-type-compound"> compound index </a> on both the metaField and timeField of a time series collection. </p> <span class="leafygreen-ui-1qnjd6d" id="std-label-manual-timeseries-internal-index"> </span> </section> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Get Started <a class="headerlink leafygreen-ui-1kepx47" href="#get-started" 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="get-started"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> To get started with time series collections, see <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/timeseries/timeseries-procedures/#std-label-timeseries-create-query-procedures"> Create and Query a Time Series Collection. </a> </p> </section> </section>
https://www.mongodb.com/docs/manual/core/sharding-find-shard-key/
<section> <h1 class="contains-headerlink leafygreen-ui-41fr9s" weight="medium"> Find a Shard Key <a class="headerlink leafygreen-ui-1kepx47" href="#find-a-shard-key" 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="find-a-shard-key"> </div> </a> </h1> <p class="leafygreen-ui-1kp3ins"> Every shared collection has a <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/sharding-shard-key/#std-label-sharding-shard-key"> shard key </a> . To display the shard key, connect to a <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongos/#mongodb-binary-bin.mongos"> <code class="leafygreen-ui-1l06pbn"> mongos </code> </a> instance and run the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/db.printShardingStatus/#mongodb-method-db.printShardingStatus"> <code class="leafygreen-ui-1l06pbn"> db.printShardingStatus() </code> </a> method: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.printShardingStatus()","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">printShardingStatus</span>(<!-- -->)</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 output resembles: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"&lt;dbname&gt;.&lt;collection&gt;\n shard key: { &lt;shard&gt; : &lt;1 or hashed&gt; }\n unique: &lt;boolean&gt;\n balancing: &lt;boolean&gt;\n chunks:\n &lt;shard&gt; &lt;number&gt;\n &lt;shard&gt; &lt;number&gt;\n ...\n { &lt;shard&gt;: &lt;min&gt; } --&gt;&gt; { &lt;shard&gt; : &lt;max&gt; } on : &lt;shard&gt; &lt;last&gt;\n { &lt;shard&gt;: &lt;min&gt; } --&gt;&gt; { &lt;shard&gt; : &lt;max&gt; } on : &lt;shard&gt; &lt;last&gt;\n ...\n tag: &lt;tag1&gt; { &lt;shard&gt; : &lt;min&gt; } --&gt;&gt; { &lt;shard&gt; : &lt;max&gt; }\n ...","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">&lt;<!-- -->dbname<!-- -->&gt;<!-- -->.<!-- -->&lt;<!-- -->collection<!-- -->&gt;</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->shard <span class="lg-highlight-attr">key</span>: <!-- -->{ <!-- -->&lt;shard key&gt; : &lt;1 or hashed&gt; }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> unique: &lt;boolean&gt;</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> balancing: &lt;boolean&gt;</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> chunks:</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> &lt;shard name1&gt; &lt;number of chunks&gt;</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> &lt;shard name2&gt; &lt;number of chunks&gt;</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> ...</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> { &lt;shard key&gt;: &lt;min range1&gt; } --&gt;&gt; { &lt;shard key&gt; : &lt;max range1&gt; } on : &lt;shard name&gt; &lt;last modified timestamp&gt;</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> { &lt;shard key&gt;: &lt;min range2&gt; } --&gt;&gt; { &lt;shard key&gt; : &lt;max range2&gt; } on : &lt;shard name&gt; &lt;last modified timestamp&gt;</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> ...</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> tag: &lt;tag1&gt; { &lt;shard key&gt; : &lt;min range1&gt; } --&gt;&gt; { &lt;shard key&gt; : &lt;max range1&gt; }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> ...</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"> For more details on the <code class="leafygreen-ui-1l06pbn"> db.printShardingStatus() </code> output, see the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/sh.status/#std-label-sharded-collection-output-reference"> sharded collection section </a> on the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/sh.status/#mongodb-method-sh.status"> <code class="leafygreen-ui-1l06pbn"> sh.status() </code> </a> page. </p> </section>
https://www.mongodb.com/docs/manual/core/csfle/reference/cryptographic-primitives/
<section> <h1 class="contains-headerlink leafygreen-ui-41fr9s" weight="medium"> CSFLE Cryptographic Primitives <a class="headerlink leafygreen-ui-1kepx47" href="#csfle-cryptographic-primitives" 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="csfle-cryptographic-primitives"> </div> </a> </h1> <p class="leafygreen-ui-1kp3ins"> MongoDB encrypts all fields in CSFLE with the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://en.wikipedia.org/w/index.php?title=Authenticated_encryption&amp;oldid=1079879470#Authenticated_encryption_with_associated_data_(AEAD)" rel="noopener noreferrer"> <span> AEAD </span> <svg alt="" aria-hidden="true" class="leafygreen-ui-1ie5kuq" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M13.823 2.4491C13.8201 2.30008 13.6999 2.17994 13.5509 2.17704L9.5062 2.09836C9.25654 2.09351 9.12821 2.39519 9.30482 2.5718L10.3856 3.65257L7.93433 6.10383C7.87964 6.15852 7.83047 6.21665 7.78683 6.27752L5.99909 8.06525C5.46457 8.59977 5.46457 9.4664 5.99909 10.0009C6.53361 10.5354 7.40023 10.5354 7.93475 10.0009L9.72249 8.21317C9.78336 8.16953 9.84148 8.12037 9.89618 8.06567L12.3474 5.61441L13.4282 6.69518C13.6048 6.87179 13.9065 6.74347 13.9016 6.4938L13.823 2.4491Z" fill="currentColor"> </path> <path d="M7.25 3.12893C7.66421 3.12893 8 3.46472 8 3.87893C8 4.29315 7.66421 4.62893 7.25 4.62893H4C3.72386 4.62893 3.5 4.85279 3.5 5.12893V11.9929C3.5 12.2691 3.72386 12.4929 4 12.4929H10.864C11.1401 12.4929 11.364 12.2691 11.364 11.9929V8.75C11.364 8.33579 11.6998 8 12.114 8C12.5282 8 12.864 8.33579 12.864 8.75V11.9929C12.864 13.0975 11.9686 13.9929 10.864 13.9929H4C2.89543 13.9929 2 13.0975 2 11.9929V5.12893C2 4.02436 2.89543 3.12893 4 3.12893H7.25Z" fill="currentColor"> </path> </svg> </a> AES-256-CBC encryption algorithm. </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> If you specify deterministic encryption for a field, your application passes a deterministic initialization vector to AEAD. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> If you specify random encryption for a field, your application passes a random initialization vector to AEAD. </p> </li> </ul> <div class="leafygreen-ui-15mdk4" role="note"> <h2 class="leafygreen-ui-6n7b7d"> Note </h2> <h3 class="leafygreen-ui-144d5kf"> <strong> Authenticated Encryption </strong> </h3> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> MongoDB CSFLE uses the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://en.wikipedia.org/wiki/Authenticated_encryption#Encrypt-then-MAC_(EtM)" rel="noopener noreferrer"> <span> encrypt-then-MAC </span> <svg alt="" aria-hidden="true" class="leafygreen-ui-1ie5kuq" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M13.823 2.4491C13.8201 2.30008 13.6999 2.17994 13.5509 2.17704L9.5062 2.09836C9.25654 2.09351 9.12821 2.39519 9.30482 2.5718L10.3856 3.65257L7.93433 6.10383C7.87964 6.15852 7.83047 6.21665 7.78683 6.27752L5.99909 8.06525C5.46457 8.59977 5.46457 9.4664 5.99909 10.0009C6.53361 10.5354 7.40023 10.5354 7.93475 10.0009L9.72249 8.21317C9.78336 8.16953 9.84148 8.12037 9.89618 8.06567L12.3474 5.61441L13.4282 6.69518C13.6048 6.87179 13.9065 6.74347 13.9016 6.4938L13.823 2.4491Z" fill="currentColor"> </path> <path d="M7.25 3.12893C7.66421 3.12893 8 3.46472 8 3.87893C8 4.29315 7.66421 4.62893 7.25 4.62893H4C3.72386 4.62893 3.5 4.85279 3.5 5.12893V11.9929C3.5 12.2691 3.72386 12.4929 4 12.4929H10.864C11.1401 12.4929 11.364 12.2691 11.364 11.9929V8.75C11.364 8.33579 11.6998 8 12.114 8C12.5282 8 12.864 8.33579 12.864 8.75V11.9929C12.864 13.0975 11.9686 13.9929 10.864 13.9929H4C2.89543 13.9929 2 13.0975 2 11.9929V5.12893C2 4.02436 2.89543 3.12893 4 3.12893H7.25Z" fill="currentColor"> </path> </svg> </a> approach to perform authenticated encryption. MongoDB CSFLE uses the HMAC-SHA-512 algorithm to generate your MAC. </p> </div> </div> </section>
https://www.mongodb.com/docs/manual/reference/method/db.collection.drop/
<section> <h1 class="contains-headerlink leafygreen-ui-41fr9s" weight="medium"> db.collection.drop() <a class="headerlink leafygreen-ui-1kepx47" href="#db.collection.drop--" 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.drop--"> </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="#definition" target="_self"> <span> Definition </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#compatibility" target="_self"> <span> Compatibility </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#syntax" target="_self"> <span> Syntax </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#behavior" target="_self"> <span> Behavior </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#example" target="_self"> <span> Example </span> </a> </li> </ul> </div> <div class="leafygreen-ui-147elvs"> <p class="leafygreen-ui-1ronz74"> MongoDB with drivers </p> <div class="leafygreen-ui-18k5rfm"> <p class="leafygreen-ui-1kp3ins"> This page documents a <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/mongodb-shell/#mongodb-binary-bin.mongosh" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongosh </code> </span> </a> method. To see the equivalent method in a MongoDB driver, see the corresponding page for your programming language: </p> </div> <div class="leafygreen-ui-zgrwqu notranslate"> <a class="leafygreen-ui-v22cck" href="https://www.mongodb.com/docs/drivers/csharp/current/fundamentals/database-collection/#drop-a-collection" target="_self"> <svg class="leafygreen-ui-x3zji3" fill="none" height="24" viewbox="0 0 28 29" width="24" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_1351_59964)"> <g clip-path="url(#clip1_1351_59964)"> <path d="M25.7709 9.2495C25.7709 8.79827 25.678 8.39408 25.4827 8.04627C25.2874 7.70785 25.0084 7.42586 24.627 7.20025C21.465 5.35781 18.2937 3.51538 15.1317 1.67295C14.2761 1.17474 13.4484 1.19354 12.6021 1.70115C11.3466 2.45316 5.04112 6.10042 3.15321 7.20025C2.3813 7.65142 2 8.34705 2 9.24005C2 12.9531 2 16.6568 2 20.3698C2 20.8117 2.093 21.2064 2.279 21.5449C2.4743 21.8927 2.7626 22.1841 3.15321 22.4191C5.03182 23.5189 11.3373 27.1662 12.6021 27.9182C13.4484 28.4258 14.2761 28.4446 15.1317 27.9463C18.2937 26.1039 21.465 24.2615 24.627 22.4191C25.0177 22.1935 25.306 21.9021 25.5012 21.5449C25.6873 21.2064 25.7803 20.8117 25.7803 20.3698C25.7709 20.3698 25.7709 12.9531 25.7709 9.2495Z" fill="#A179DC"> </path> <path d="M13.9227 14.7673L2.27905 21.5449C2.47435 21.8927 2.76265 22.1841 3.15326 22.4191C5.03187 23.5189 11.3373 27.1662 12.6021 27.9182C13.4484 28.4258 14.2762 28.4445 15.1317 27.9463C18.2938 26.1039 21.4651 24.2615 24.6271 22.4191C25.0177 22.1935 25.306 21.9021 25.5013 21.5449L13.9227 14.7673Z" fill="#280068"> </path> <path d="M25.7711 9.24949C25.7711 8.79827 25.6781 8.39408 25.4828 8.04626L13.9229 14.7768L25.4921 21.5543C25.6781 21.2159 25.7711 20.8211 25.7711 20.3793C25.7711 20.3699 25.7711 12.9531 25.7711 9.24949Z" fill="#390091"> </path> <path d="M20.7771 12.2387V13.5078H22.0325V12.2387H22.6557V13.5078H23.9111V14.1376H22.6557V15.4066H23.9111V16.0364H22.6557V17.3054H22.0325V16.0364H20.7771V17.3054H20.1539V16.0364H18.8984V15.4066H20.1539V14.1376H18.8984V13.5078H20.1539V12.2387H20.7771ZM22.0325 14.1376H20.7771V15.4066H22.0325V14.1376Z" fill="white"> </path> <path d="M13.9508 5.87482C17.2151 5.87482 20.0702 7.67022 21.6047 10.3399L21.5861 10.3117L17.7452 12.5489C16.9919 11.2517 15.5969 10.3775 14.0066 10.3587H13.9601C11.5328 10.3587 9.56116 12.3515 9.56116 14.805C9.56116 15.604 9.77503 16.3654 10.1377 17.014C10.9004 18.3488 12.3232 19.2512 13.9601 19.2512C15.6062 19.2512 17.0384 18.3394 17.7917 16.9858L17.7731 17.014L21.614 19.2606C20.0981 21.9021 17.2895 23.6975 14.0531 23.7257H13.9508C10.6679 23.7257 7.81274 21.9209 6.28753 19.2418C5.54353 17.9352 5.11572 16.4124 5.11572 14.7956C5.11572 9.87931 9.06825 5.87482 13.9508 5.87482Z" fill="white"> </path> </g> </g> <defs> <clippath id="clip0_1351_59964"> <rect fill="white" height="28" transform="translate(0 0.809265)" width="28"> </rect> </clippath> <clippath id="clip1_1351_59964"> <rect fill="white" height="27" transform="translate(2 1.30966)" width="24"> </rect> </clippath> </defs> </svg> <span> C# </span> </a> <a class="leafygreen-ui-v22cck" href="https://mongodb.github.io/mongo-java-driver/5.1/apidocs/mongodb-driver-sync/com/mongodb/client/MongoCollection.html#drop()" target="_self"> <svg class="leafygreen-ui-x3zji3" fill="none" height="24" viewbox="0 0 30 41" width="24" xmlns="http://www.w3.org/2000/svg"> <path d="M10.0921 30.7949C10.0921 30.7949 8.57608 31.6793 11.166 31.9636C14.2929 32.311 15.9037 32.2794 19.3464 31.6161C19.3464 31.6161 20.2623 32.1846 21.5257 32.6901C13.7876 35.9748 4.02791 32.5005 10.0921 30.7949Z" fill="#0074BD"> </path> <path d="M9.14539 26.4678C9.14539 26.4678 7.43985 27.7312 10.0298 27.9838C13.3778 28.3312 15.9992 28.3628 20.579 27.4785C20.579 27.4785 21.2107 28.1101 22.1898 28.4576C12.8724 31.2054 2.44949 28.6787 9.14539 26.4678Z" fill="#0074BD"> </path> <path d="M17.1039 19.1398C18.9989 21.3191 16.5985 23.3089 16.5985 23.3089C16.5985 23.3089 21.431 20.8138 19.2201 17.6869C17.1355 14.7811 15.5563 13.3282 24.1788 8.33789C24.1473 8.33789 10.6607 11.6858 17.1039 19.1398Z" fill="#EA2D2E"> </path> <path d="M27.3377 33.9845C27.3377 33.9845 28.4431 34.9004 26.1059 35.6269C21.6525 36.985 7.53417 37.3957 3.61769 35.6901C2.19639 35.0899 4.84949 34.2372 5.67069 34.0477C6.52347 33.8582 7.02884 33.8898 7.02884 33.8898C5.44961 32.7843 -3.10981 36.0691 2.67016 36.9851C18.4308 39.5433 31.4121 35.8164 27.3377 33.9845Z" fill="#0074BD"> </path> <path d="M10.8194 21.983C10.8194 21.983 3.6497 23.6885 8.2926 24.3203C10.2509 24.5729 14.1357 24.5097 17.7995 24.2255C20.7685 23.9728 23.7375 23.4359 23.7375 23.4359C23.7375 23.4359 22.6951 23.8781 21.9372 24.415C14.6411 26.3416 0.585992 25.4257 4.62881 23.4675C8.00839 21.7935 10.8194 21.983 10.8194 21.983Z" fill="#0074BD"> </path> <path d="M23.6745 29.1846C31.0969 25.3313 27.6542 21.6359 25.2538 22.1413C24.6537 22.2676 24.401 22.3623 24.401 22.3623C24.401 22.3623 24.6221 22.0149 25.0327 21.8886C29.7703 20.2146 33.4025 26.7842 23.5166 29.4057C23.5482 29.3741 23.6429 29.2794 23.6745 29.1846Z" fill="#0074BD"> </path> <path d="M19.2206 0.25293C19.2206 0.25293 23.3266 4.35891 15.3357 10.6758C8.92404 15.7293 13.8828 18.6351 15.3357 21.9199C11.6087 18.5403 8.86088 15.5714 10.6928 12.792C13.3775 8.74919 20.863 6.79093 19.2206 0.25293Z" fill="#EA2D2E"> </path> <path d="M11.5455 39.6068C18.6521 40.049 29.5803 39.3541 29.833 35.9746C29.833 35.9746 29.3276 37.238 23.9583 38.2487C17.894 39.3858 10.4085 39.2594 5.95508 38.533C5.95508 38.5646 6.87103 39.3225 11.5455 39.6068Z" fill="#0074BD"> </path> </svg> <span> Java Sync </span> </a> <a class="leafygreen-ui-v22cck" href="https://mongodb.github.io/node-mongodb-native/3.6/api/Collection.html#drop" target="_self"> <svg class="leafygreen-ui-x3zji3" fill="none" height="24" viewbox="0 0 30 30" width="24" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:R2dttqcmqn9:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":R2dttqcmqn9:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":R2dttqcmqn9:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":R2dttqcmqn9:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <span> Node.js </span> </a> <a class="leafygreen-ui-v22cck" href="https://pymongo.readthedocs.io/en/stable/api/pymongo/collection.html#pymongo.collection.Collection.drop" target="_self"> <svg class="leafygreen-ui-x3zji3" height="24" viewbox="0 0 111.6 147" width="24" xmlns="http://www.w3.org/2000/svg"> <lineargradient gradienttransform="matrix(.5625 0 0 -.568 -160.323 -146.09)" gradientunits="userSpaceOnUse" id=":R2httqcmqn9:aa" x1="280.848" x2="389.865" y1="-268.463" y2="-362.257"> <stop offset="0" stop-color="#5a9fd4"> </stop> <stop offset="1" stop-color="#306998"> </stop> </lineargradient> <path d="M55.3 3.2c-4.6 0-9 .4-12.8 1.1-11.3 2-13.4 6.2-13.4 13.9v10.2h26.8v3.4H19c-7.8 0-14.6 4.7-16.8 13.6C-.3 55.6-.4 62 2.2 72.7c1.9 7.9 6.5 13.6 14.2 13.6h9.2V74c0-8.8 7.7-16.7 16.7-16.7h26.8c7.5 0 13.4-6.1 13.4-13.6V18.2c0-7.3-6.1-12.7-13.4-13.9-4.4-.8-9.2-1.1-13.8-1.1zm-14.5 8.2c2.8 0 5 2.3 5 5.1s-2.3 5.1-5 5.1c-2.8 0-5-2.3-5-5.1s2.2-5.1 5-5.1z" fill="url(#:R2httqcmqn9:aa)"> </path> <lineargradient gradienttransform="matrix(.5625 0 0 -.568 -160.323 -146.09)" gradientunits="userSpaceOnUse" id=":R2httqcmqn9:bb" x1="432.011" x2="393.081" y1="-419.025" y2="-363.946"> <stop offset="0" stop-color="#ffd43b"> </stop> <stop offset="1" stop-color="#ffe873"> </stop> </lineargradient> <path d="M86 31.8v11.9c0 9.2-7.8 17-16.8 17H42.5c-7.3 0-13.4 6.3-13.4 13.6v25.5c0 7.3 6.3 11.5 13.4 13.6 8.5 2.5 16.6 2.9 26.8 0 6.8-2 13.4-5.9 13.4-13.6V89.7H55.9v-3.4h40.2c7.8 0 10.7-5.4 13.4-13.6 2.8-8.4 2.7-16.5 0-27.3-1.9-7.8-5.6-13.6-13.4-13.6H86zM71 96.5c2.8 0 5 2.3 5 5.1s-2.3 5.1-5 5.1c-2.8 0-5-2.3-5-5.1-.1-2.8 2.2-5.1 5-5.1z" fill="url(#:R2httqcmqn9:bb)"> </path> <radialgradient cx="-2274.721" cy="144.526" gradienttransform="matrix(0 -.2399 -1.0547 0 208.637 -414.922)" gradientunits="userSpaceOnUse" id=":R2httqcmqn9:cc" r="29.037"> <stop offset="0" stop-color="#b8b8b8" stop-opacity=".498"> </stop> <stop offset="1" stop-color="#7f7f7f" stop-opacity="0"> </stop> </radialgradient> <path d="M92.1 130.9c0 3.8-16.1 7-35.9 7s-35.9-3.1-35.9-7c0-3.8 16.1-7 35.9-7s35.9 3.1 35.9 7z" fill="url(#:R2httqcmqn9:cc)" opacity=".444"> </path> </svg> <span> PyMongo </span> </a> <a class="leafygreen-ui-18cpm0b" href="https://mongoc.org/libmongoc/current/mongoc_collection_drop.html" target="_self"> <svg class="leafygreen-ui-x3zji3" fill="none" height="24" viewbox="0 0 28 29" width="24" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_1351_59955)"> <g clip-path="url(#clip1_1351_59955)"> <path clip-rule="evenodd" d="M13.118 1.49532C13.5403 1.25103 14.0559 1.25103 14.4783 1.49532C16.5652 2.70389 22.8385 6.34889 24.9193 7.55748C25.3416 7.80172 25.6025 8.25176 25.6025 8.74672C25.6025 11.1703 25.6025 18.4539 25.6025 20.8774C25.6025 21.366 25.3416 21.8224 24.9193 22.0667C22.8385 23.2753 16.5652 26.9203 14.4783 28.1289C14.0559 28.3732 13.5403 28.3732 13.118 28.1289C11.0373 26.9139 4.76398 23.2689 2.68323 22.0603C2.26087 21.816 2 21.366 2 20.871C2 18.4474 2 11.1639 2 8.7403C2 8.25176 2.26087 7.7953 2.68323 7.55106C4.76398 6.34889 11.0373 2.70389 13.118 1.49532Z" fill="#004482" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M2.18634 21.4946C2.01863 21.2632 2 21.051 2 20.7553C2 18.351 2 11.1061 2 8.70176C2 8.21317 2.26087 7.76319 2.67702 7.51889C4.75776 6.31675 11.0062 2.69104 13.0807 1.4889C13.5031 1.24461 14.0683 1.25104 14.4907 1.49533C16.5652 2.69747 22.795 6.29104 24.8696 7.49319C25.0373 7.58963 25.1677 7.70535 25.2795 7.86606L2.18634 21.4946Z" fill="#659AD2" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M13.8011 5.8089C18.6024 5.8089 22.4968 9.83964 22.4968 14.8089C22.4968 19.7782 18.6024 23.8089 13.8011 23.8089C8.99986 23.8089 5.10547 19.7782 5.10547 14.8089C5.10547 9.83964 8.99986 5.8089 13.8011 5.8089ZM13.8011 10.3089C16.1987 10.3089 18.1489 12.3275 18.1489 14.8089C18.1489 17.2903 16.1987 19.3089 13.8011 19.3089C11.4036 19.3089 9.4533 17.2903 9.4533 14.8089C9.4533 12.3275 11.4036 10.3089 13.8011 10.3089Z" fill="white" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M25.2857 7.87247C25.6087 8.18102 25.6025 8.65034 25.6025 9.01673C25.6025 11.4596 25.5839 18.396 25.6087 20.8325C25.6087 21.0896 25.528 21.3532 25.4099 21.5589L13.5466 14.8089L25.2857 7.87247Z" fill="#00599C" fill-rule="evenodd"> </path> </g> </g> <defs> <clippath id="clip0_1351_59955"> <rect fill="white" height="28" transform="translate(0 0.809265)" width="28"> </rect> </clippath> <clippath id="clip1_1351_59955"> <rect fill="white" height="27" transform="translate(2 1.30887)" width="24"> </rect> </clippath> </defs> </svg> <span> C </span> </a> <a class="leafygreen-ui-18cpm0b" href="https://mongocxx.org/api/mongocxx-3.0.2/classmongocxx_1_1collection.html#a2e6f9689b531a0be1e5b202177bb163d" target="_self"> <svg class="leafygreen-ui-x3zji3" fill="none" height="24" viewbox="0 0 28 29" width="24" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_1351_59959)"> <g clip-path="url(#clip1_1351_59959)"> <path d="M25.4013 21.5646C25.5872 21.2353 25.7034 20.8745 25.7034 20.5373V9.08012C25.7034 8.75078 25.5872 8.38217 25.4013 8.05283L13.8516 14.8127L25.4013 21.5646Z" fill="#00599C"> </path> <path d="M14.8738 28.0657L24.6729 22.3411C24.9517 22.1764 25.2151 21.8941 25.401 21.5647L13.8513 14.8127L2.30151 21.5647C2.48743 21.8941 2.74305 22.1764 3.02967 22.3411L12.8288 28.0657C13.3865 28.3951 14.316 28.3951 14.8738 28.0657Z" fill="#004482"> </path> <path d="M25.4011 8.06086C25.2152 7.73146 24.9596 7.44915 24.673 7.2845L14.8739 1.55983C14.3084 1.23046 13.3866 1.23046 12.8211 1.55983L3.02202 7.2845C2.46429 7.61385 1.99951 8.42158 1.99951 9.08033V20.5375C1.99951 20.8669 2.11571 21.2354 2.30162 21.5647L13.8514 14.8128L25.4011 8.06086Z" fill="#659AD2"> </path> <path d="M13.8512 22.8115C9.49778 22.8115 5.94995 19.2199 5.94995 14.8127C5.94995 10.4055 9.49778 6.81387 13.8512 6.81387C16.6631 6.81387 19.2813 8.34305 20.6912 10.8133L17.2751 12.813C16.5701 11.5818 15.261 10.8133 13.8512 10.8133C11.6745 10.8133 9.90055 12.6091 9.90055 14.8127C9.90055 17.0163 11.6745 18.8121 13.8512 18.8121C15.261 18.8121 16.5701 18.0436 17.2751 16.8124L20.6912 18.8121C19.2813 21.2745 16.6631 22.8115 13.8512 22.8115Z" fill="white"> </path> <path d="M21.7524 14.3657H20.8771V13.4796H19.994V14.3657H19.1187V15.2518H19.994V16.1458H20.8771V15.2518H21.7524V14.3657Z" fill="white"> </path> <path d="M25.0446 14.3657H24.1693V13.4796H23.2862V14.3657H22.4109V15.2518H23.2862V16.1458H24.1693V15.2518H25.0446V14.3657Z" fill="white"> </path> </g> </g> <defs> <clippath id="clip0_1351_59959"> <rect fill="white" height="28" transform="translate(0 0.809265)" width="28"> </rect> </clippath> <clippath id="clip1_1351_59959"> <rect fill="white" height="27" transform="translate(1.99951 1.30878)" width="24"> </rect> </clippath> </defs> </svg> <span> C++ </span> </a> <a class="leafygreen-ui-18cpm0b" href="https://www.mongodb.com/blog/post/quick-start-golang--mongodb--how-to-delete-documents" target="_self"> <svg class="leafygreen-ui-x3zji3" height="24" id="Layer_1" style="fill:#00ACD7" version="1.1" viewbox="0 0 205.4 76.7" width="24" x="0" xmlns="http://www.w3.org/2000/svg" y="0"> <path class="st00" d="M15.5 23.2c-.4 0-.5-.2-.3-.5l2.1-2.7c.2-.3.7-.5 1.1-.5h35.7c.4 0 .5.3.3.6l-1.7 2.6c-.2.3-.7.6-1 .6l-36.2-.1zM.4 32.4c-.4 0-.5-.2-.3-.5l2.1-2.7c.2-.3.7-.5 1.1-.5h45.6c.4 0 .6.3.5.6l-.8 2.4c-.1.4-.5.6-.9.6l-47.3.1zM24.6 41.6c-.4 0-.5-.3-.3-.6l1.4-2.5c.2-.3.6-.6 1-.6h20c.4 0 .6.3.6.7l-.2 2.4c0 .4-.4.7-.7.7l-21.8-.1z"> </path> <g id="CXHf1q_3_"> <path class="st00" d="M128.4 21.4c-6.3 1.6-10.6 2.8-16.8 4.4-1.5.4-1.6.5-2.9-1-1.5-1.7-2.6-2.8-4.7-3.8-6.3-3.1-12.4-2.2-18.1 1.5-6.8 4.4-10.3 10.9-10.2 19 .1 8 5.6 14.6 13.5 15.7 6.8.9 12.5-1.5 17-6.6.9-1.1 1.7-2.3 2.7-3.7H89.6c-2.1 0-2.6-1.3-1.9-3 1.3-3.1 3.7-8.3 5.1-10.9.3-.6 1-1.6 2.5-1.6h36.4c-.2 2.7-.2 5.4-.6 8.1-1.1 7.2-3.8 13.8-8.2 19.6-7.2 9.5-16.6 15.4-28.5 17-9.8 1.3-18.9-.6-26.9-6.6-7.4-5.6-11.6-13-12.7-22.2-1.3-10.9 1.9-20.7 8.5-29.3C70.4 8.7 79.8 2.8 91.3.7c9.4-1.7 18.4-.6 26.5 4.9 5.3 3.5 9.1 8.3 11.6 14.1.6.9.2 1.4-1 1.7z"> </path> <path class="st00" d="M161.5 76.7c-9.1-.2-17.4-2.8-24.4-8.8-5.9-5.1-9.6-11.6-10.8-19.3-1.8-11.3 1.3-21.3 8.1-30.2 7.3-9.6 16.1-14.6 28-16.7 10.2-1.8 19.8-.8 28.5 5.1 7.9 5.4 12.8 12.7 14.1 22.3 1.7 13.5-2.2 24.5-11.5 33.9-6.6 6.7-14.7 10.9-24 12.8-2.7.5-5.4.6-8 .9zm23.8-40.4c-.1-1.3-.1-2.3-.3-3.3-1.8-9.9-10.9-15.5-20.4-13.3-9.3 2.1-15.3 8-17.5 17.4-1.8 7.8 2 15.7 9.2 18.9 5.5 2.4 11 2.1 16.3-.6 7.9-4.1 12.2-10.5 12.7-19.1z"> </path> </g> </svg> <span> Go </span> </a> <a class="leafygreen-ui-18cpm0b" href="https://mongodb.github.io/mongo-java-driver/5.1/apidocs/mongodb-driver-reactivestreams/com/mongodb/reactivestreams/client/gridfs/GridFSBucket.html#drop()" target="_self"> <svg class="leafygreen-ui-x3zji3" fill="none" height="24" viewbox="0 0 30 41" width="24" xmlns="http://www.w3.org/2000/svg"> <path d="M10.0921 30.7949C10.0921 30.7949 8.57608 31.6793 11.166 31.9636C14.2929 32.311 15.9037 32.2794 19.3464 31.6161C19.3464 31.6161 20.2623 32.1846 21.5257 32.6901C13.7876 35.9748 4.02791 32.5005 10.0921 30.7949Z" fill="#0074BD"> </path> <path d="M9.14539 26.4678C9.14539 26.4678 7.43985 27.7312 10.0298 27.9838C13.3778 28.3312 15.9992 28.3628 20.579 27.4785C20.579 27.4785 21.2107 28.1101 22.1898 28.4576C12.8724 31.2054 2.44949 28.6787 9.14539 26.4678Z" fill="#0074BD"> </path> <path d="M17.1039 19.1398C18.9989 21.3191 16.5985 23.3089 16.5985 23.3089C16.5985 23.3089 21.431 20.8138 19.2201 17.6869C17.1355 14.7811 15.5563 13.3282 24.1788 8.33789C24.1473 8.33789 10.6607 11.6858 17.1039 19.1398Z" fill="#EA2D2E"> </path> <path d="M27.3377 33.9845C27.3377 33.9845 28.4431 34.9004 26.1059 35.6269C21.6525 36.985 7.53417 37.3957 3.61769 35.6901C2.19639 35.0899 4.84949 34.2372 5.67069 34.0477C6.52347 33.8582 7.02884 33.8898 7.02884 33.8898C5.44961 32.7843 -3.10981 36.0691 2.67016 36.9851C18.4308 39.5433 31.4121 35.8164 27.3377 33.9845Z" fill="#0074BD"> </path> <path d="M10.8194 21.983C10.8194 21.983 3.6497 23.6885 8.2926 24.3203C10.2509 24.5729 14.1357 24.5097 17.7995 24.2255C20.7685 23.9728 23.7375 23.4359 23.7375 23.4359C23.7375 23.4359 22.6951 23.8781 21.9372 24.415C14.6411 26.3416 0.585992 25.4257 4.62881 23.4675C8.00839 21.7935 10.8194 21.983 10.8194 21.983Z" fill="#0074BD"> </path> <path d="M23.6745 29.1846C31.0969 25.3313 27.6542 21.6359 25.2538 22.1413C24.6537 22.2676 24.401 22.3623 24.401 22.3623C24.401 22.3623 24.6221 22.0149 25.0327 21.8886C29.7703 20.2146 33.4025 26.7842 23.5166 29.4057C23.5482 29.3741 23.6429 29.2794 23.6745 29.1846Z" fill="#0074BD"> </path> <path d="M19.2206 0.25293C19.2206 0.25293 23.3266 4.35891 15.3357 10.6758C8.92404 15.7293 13.8828 18.6351 15.3357 21.9199C11.6087 18.5403 8.86088 15.5714 10.6928 12.792C13.3775 8.74919 20.863 6.79093 19.2206 0.25293Z" fill="#EA2D2E"> </path> <path d="M11.5455 39.6068C18.6521 40.049 29.5803 39.3541 29.833 35.9746C29.833 35.9746 29.3276 37.238 23.9583 38.2487C17.894 39.3858 10.4085 39.2594 5.95508 38.533C5.95508 38.5646 6.87103 39.3225 11.5455 39.6068Z" fill="#0074BD"> </path> </svg> <span> Java RS </span> </a> <a class="leafygreen-ui-18cpm0b" href="https://mongodb.github.io/mongo-java-driver/5.1/apidocs/mongodb-driver-kotlin-coroutine/mongodb-driver-kotlin-coroutine/com.mongodb.kotlin.client.coroutine/-mongo-collection/drop.html" target="_self"> <svg class="leafygreen-ui-x3zji3" fill="none" height="24" viewbox="0 0 28 29" width="24" xmlns="http://www.w3.org/2000/svg"> <path d="M28 29H0V1H28L14 15L28 29Z" fill="url(#:R35ttqcmqn9:paint0_linear_211_40588)"> </path> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":R35ttqcmqn9:paint0_linear_211_40588" x1="28" x2="8.34465e-07" y1="0.999999" y2="29"> <stop offset="0.00343514" stop-color="#E44857"> </stop> <stop offset="0.4689" stop-color="#C711E1"> </stop> <stop offset="1" stop-color="#7F52FF"> </stop> </lineargradient> </defs> </svg> <span> Kotlin Coroutine </span> </a> <a class="leafygreen-ui-18cpm0b" href="https://www.mongodb.com/docs/drivers/kotlin/coroutine/current/fundamentals/databases-collections/#drop-a-collection" target="_self"> <svg class="leafygreen-ui-x3zji3" fill="none" height="24" viewbox="0 0 28 29" width="24" xmlns="http://www.w3.org/2000/svg"> <path d="M28 29H0V1H28L14 15L28 29Z" fill="url(#:R39ttqcmqn9:paint0_linear_211_40588)"> </path> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":R39ttqcmqn9:paint0_linear_211_40588" x1="28" x2="8.34465e-07" y1="0.999999" y2="29"> <stop offset="0.00343514" stop-color="#E44857"> </stop> <stop offset="0.4689" stop-color="#C711E1"> </stop> <stop offset="1" stop-color="#7F52FF"> </stop> </lineargradient> </defs> </svg> <span> Kotlin Sync </span> </a> <a class="leafygreen-ui-18cpm0b" href="https://www.mongodb.com/docs/php-library/current/reference/method/MongoDBCollection-drop/" target="_self"> <svg class="leafygreen-ui-x3zji3" height="24" viewbox="0 0 700 301" width="24" x="0" xmlns="http://www.w3.org/2000/svg" y="0"> <defs> <clippath clippathunits="userSpaceOnUse" id="a"> <path d="M11.52 162C11.52 81.677 135.307 16.561 288 16.561S564.481 81.677 564.481 162c0 80.322-123.788 145.439-276.481 145.439-152.693 0-276.48-65.117-276.48-145.439"> </path> </clippath> <clippath clippathunits="userSpaceOnUse" id="c"> <path d="M0 324h576V0H0v324z"> </path> </clippath> <clippath clippathunits="userSpaceOnUse" id="d"> <path d="M0 324h576V0H0v324z"> </path> </clippath> <radialgradient cx="0" cy="0" fx="0" fy="0" gradienttransform="matrix(363.05789 0 0 -363.05789 177.52 256.307)" gradientunits="userSpaceOnUse" id="b" r="1" spreadmethod="pad"> <stop offset="0" stop-color="#aeb2d5"> </stop> <stop offset=".3" stop-color="#aeb2d5"> </stop> <stop offset=".75" stop-color="#484c89"> </stop> <stop offset="1" stop-color="#484c89"> </stop> </radialgradient> </defs> <g clip-path="url(#a)" transform="matrix(1.25 0 0 -1.25 -4.4 394.299)"> <path d="M11.52 162C11.52 81.677 135.307 16.561 288 16.561S564.481 81.677 564.481 162c0 80.322-123.788 145.439-276.481 145.439-152.693 0-276.48-65.117-276.48-145.439" fill="url(#b)"> </path> </g> <g clip-path="url(#c)" transform="matrix(1.25 0 0 -1.25 -4.4 394.299)"> <path d="M288 27.36c146.729 0 265.68 60.28 265.68 134.64 0 74.36-118.951 134.641-265.68 134.641S22.32 236.36 22.32 162.001C22.32 87.64 141.271 27.358 288 27.358" fill="#777bb3"> </path> </g> <g clip-path="url(#d)" transform="matrix(1.25 0 0 -1.25 -4.4 394.299)"> <path d="M161.734 145.307c12.065 0 21.072 2.225 26.771 6.61 5.638 4.342 9.532 11.863 11.573 22.354 1.903 9.806 1.178 16.653-2.154 20.348-3.407 3.774-10.773 5.688-21.893 5.688h-19.28l-10.69-55h15.673zm-63.063-67.75a2.998 2.998 0 00-2.944 3.572l28.328 145.75a3 3 0 002.945 2.428h61.054c19.188 0 33.47-5.21 42.447-15.487 9.025-10.331 11.812-24.772 8.283-42.921-1.436-7.394-3.906-14.261-7.34-20.41-3.44-6.154-7.985-11.85-13.512-16.93-6.616-6.191-14.104-10.681-22.236-13.323-8.003-2.607-18.28-3.93-30.548-3.93h-24.722l-7.06-36.321a3 3 0 00-2.944-2.428h-31.75z"> </path> <path d="M159.224 197.307h16.808c13.42 0 18.083-2.945 19.667-4.7 2.628-2.914 3.124-9.058 1.435-17.767-1.898-9.75-5.416-16.663-10.458-20.545-5.162-3.974-13.554-5.988-24.941-5.988H149.7l9.523 49zm28.83 35H127a6 6 0 01-5.89-4.855L92.784 81.702a6 6 0 015.889-7.144h31.75a6 6 0 015.89 4.854l6.588 33.895h22.249c12.582 0 23.174 1.372 31.479 4.077 8.54 2.775 16.399 7.48 23.354 13.984 5.752 5.292 10.49 11.232 14.08 17.657 3.59 6.427 6.17 13.594 7.668 21.302 3.715 19.104.697 34.402-8.97 45.466-9.571 10.958-24.613 16.514-44.705 16.514m-45.633-90h19.313c12.8 0 22.336 2.411 28.6 7.234 6.267 4.824 10.493 12.875 12.689 24.157 2.1 10.832 1.144 18.476-2.871 22.93-4.02 4.452-12.06 6.68-24.121 6.68h-21.754l-11.856-61m45.633 84c18.367 0 31.766-4.82 40.188-14.462 8.42-9.64 10.957-23.098 7.597-40.375-1.383-7.117-3.722-13.624-7.015-19.519-3.297-5.899-7.602-11.293-12.922-16.184-6.34-5.933-13.383-10.16-21.133-12.679-7.75-2.525-17.621-3.782-29.621-3.782h-27.196l-7.531-38.75h-31.75L127 226.307h61.055" fill="#fff"> </path> <path d="M311.583 116.307c-.896 0-1.745.4-2.314 1.092a2.994 2.994 0 00-.631 2.48l12.531 64.489c1.192 6.133.898 10.535-.827 12.395-1.056 1.137-4.228 3.044-13.607 3.044h-22.702l-15.755-81.072a3 3 0 00-2.945-2.428h-31.5a2.998 2.998 0 00-2.945 3.572l28.328 145.75a3 3 0 002.945 2.428h31.5a3 3 0 002.945-3.572l-6.836-35.178h24.422c18.605 0 31.221-3.28 38.569-10.028 7.49-6.884 9.827-17.891 6.947-32.72l-13.18-67.824a3 3 0 00-2.945-2.428h-32z"> </path> <path d="M293.661 271.057h-31.5a6 6 0 01-5.89-4.855l-28.328-145.75a5.998 5.998 0 015.89-7.145h31.5a6 6 0 015.89 4.855l15.283 78.645h20.23c9.362 0 11.327-2 11.406-2.086.568-.61 1.315-3.44.082-9.78l-12.53-64.49a5.998 5.998 0 015.89-7.144h32a6 6 0 015.89 4.855l13.178 67.825c3.093 15.921.447 27.864-7.86 35.5-7.929 7.281-21.209 10.82-40.6 10.82h-20.784l6.143 31.605a6.001 6.001 0 01-5.89 7.145m0-6l-7.53-38.75h28.061c17.657 0 29.836-3.082 36.54-9.238 6.702-6.16 8.71-16.14 6.031-29.938l-13.18-67.824h-32l12.531 64.488c1.426 7.336.902 12.34-1.574 15.008-2.477 2.668-7.746 4.004-15.805 4.004H281.56l-16.226-83.5h-31.5l28.328 145.75h31.5" fill="#fff"> </path> <path d="M409.55 145.307c12.065 0 21.072 2.225 26.77 6.61 5.639 4.34 9.533 11.862 11.575 22.354 1.903 9.806 1.178 16.653-2.155 20.348-3.407 3.774-10.773 5.688-21.893 5.688h-19.281l-10.69-55h15.674zm-63.062-67.75a2.999 2.999 0 00-2.945 3.572l28.328 145.75a3.002 3.002 0 002.946 2.428h61.053c19.189 0 33.47-5.21 42.448-15.487 9.025-10.33 11.81-24.771 8.283-42.921-1.438-7.394-3.907-14.261-7.342-20.41-3.44-6.154-7.984-11.85-13.511-16.93-6.616-6.191-14.104-10.681-22.236-13.323-8.003-2.607-18.281-3.93-30.548-3.93H388.24l-7.057-36.321a3.001 3.001 0 00-2.946-2.428h-31.75z"> </path> <path d="M407.04 197.307h16.807c13.421 0 18.083-2.945 19.667-4.7 2.63-2.914 3.125-9.058 1.435-17.766-1.898-9.75-5.417-16.664-10.458-20.546-5.162-3.974-13.554-5.988-24.94-5.988h-12.034l9.522 49zm28.83 35h-61.054a6 6 0 01-5.889-4.855L340.6 81.702a6 6 0 015.889-7.144h31.75a6 6 0 015.89 4.854l6.587 33.895h22.25c12.581 0 23.173 1.372 31.478 4.077 8.541 2.775 16.401 7.481 23.356 13.986 5.752 5.291 10.488 11.23 14.078 17.655 3.591 6.427 6.171 13.594 7.668 21.302 3.715 19.105.697 34.403-8.969 45.467-9.572 10.957-24.613 16.513-44.706 16.513m-45.632-90h19.312c12.801 0 22.336 2.411 28.601 7.234 6.267 4.824 10.492 12.875 12.688 24.157 2.102 10.832 1.145 18.476-2.87 22.93-4.02 4.452-12.06 6.68-24.122 6.68h-21.754l-11.855-61m45.632 84c18.367 0 31.766-4.82 40.188-14.462 8.422-9.64 10.957-23.098 7.597-40.375-1.383-7.117-3.722-13.624-7.015-19.519-3.297-5.899-7.602-11.293-12.922-16.184-6.34-5.933-13.383-10.16-21.133-12.679-7.75-2.525-17.62-3.782-29.62-3.782h-27.197l-7.53-38.75h-31.75l28.328 145.75h61.054" fill="#fff"> </path> </g> </svg> <span> PHP </span> </a> <a class="leafygreen-ui-18cpm0b" href="https://www.rubydoc.info/gems/mongoid/2.8.1/Mongoid/Collection#drop-instance_method" target="_self"> <svg class="leafygreen-ui-x3zji3" height="24" preserveaspectratio="xMidYMid" viewbox="0 0 300 240" width="24" xmlns="http://www.w3.org/2000/svg"> <defs> <lineargradient id=":R3httqcmqn9:a" x1="84.75%" x2="58.254%" y1="111.399%" y2="64.584%"> <stop offset="0%" stop-color="#FB7655"> </stop> <stop offset="0%" stop-color="#FB7655"> </stop> <stop offset="41%" stop-color="#E42B1E"> </stop> <stop offset="99%" stop-color="#900"> </stop> <stop offset="100%" stop-color="#900"> </stop> </lineargradient> <lineargradient id=":R3httqcmqn9:b" x1="116.651%" x2="1.746%" y1="60.89%" y2="19.288%"> <stop offset="0%" stop-color="#871101"> </stop> <stop offset="0%" stop-color="#871101"> </stop> <stop offset="99%" stop-color="#911209"> </stop> <stop offset="100%" stop-color="#911209"> </stop> </lineargradient> <lineargradient id=":R3httqcmqn9:c" x1="75.774%" x2="38.978%" y1="219.327%" y2="7.829%"> <stop offset="0%" stop-color="#871101"> </stop> <stop offset="0%" stop-color="#871101"> </stop> <stop offset="99%" stop-color="#911209"> </stop> <stop offset="100%" stop-color="#911209"> </stop> </lineargradient> <lineargradient id=":R3httqcmqn9:d" x1="50.012%" x2="66.483%" y1="7.234%" y2="79.135%"> <stop offset="0%" stop-color="#FFF"> </stop> <stop offset="0%" stop-color="#FFF"> </stop> <stop offset="23%" stop-color="#E57252"> </stop> <stop offset="46%" stop-color="#DE3B20"> </stop> <stop offset="99%" stop-color="#A60003"> </stop> <stop offset="100%" stop-color="#A60003"> </stop> </lineargradient> <lineargradient id=":R3httqcmqn9:e" x1="46.174%" x2="49.932%" y1="16.348%" y2="83.047%"> <stop offset="0%" stop-color="#FFF"> </stop> <stop offset="0%" stop-color="#FFF"> </stop> <stop offset="23%" stop-color="#E4714E"> </stop> <stop offset="56%" stop-color="#BE1A0D"> </stop> <stop offset="99%" stop-color="#A80D00"> </stop> <stop offset="100%" stop-color="#A80D00"> </stop> </lineargradient> <lineargradient id=":R3httqcmqn9:f" x1="36.965%" x2="49.528%" y1="15.594%" y2="92.478%"> <stop offset="0%" stop-color="#FFF"> </stop> <stop offset="0%" stop-color="#FFF"> </stop> <stop offset="18%" stop-color="#E46342"> </stop> <stop offset="40%" stop-color="#C82410"> </stop> <stop offset="99%" stop-color="#A80D00"> </stop> <stop offset="100%" stop-color="#A80D00"> </stop> </lineargradient> <lineargradient id=":R3httqcmqn9:g" x1="13.609%" x2="85.764%" y1="58.346%" y2="-46.717%"> <stop offset="0%" stop-color="#FFF"> </stop> <stop offset="0%" stop-color="#FFF"> </stop> <stop offset="54%" stop-color="#C81F11"> </stop> <stop offset="99%" stop-color="#BF0905"> </stop> <stop offset="100%" stop-color="#BF0905"> </stop> </lineargradient> <lineargradient id=":R3httqcmqn9:h" x1="27.624%" x2="50.745%" y1="21.135%" y2="79.056%"> <stop offset="0%" stop-color="#FFF"> </stop> <stop offset="0%" stop-color="#FFF"> </stop> <stop offset="31%" stop-color="#DE4024"> </stop> <stop offset="99%" stop-color="#BF190B"> </stop> <stop offset="100%" stop-color="#BF190B"> </stop> </lineargradient> <lineargradient id=":R3httqcmqn9:i" x1="-20.667%" x2="104.242%" y1="122.282%" y2="-6.342%"> <stop offset="0%" stop-color="#BD0012"> </stop> <stop offset="0%" stop-color="#BD0012"> </stop> <stop offset="7%" stop-color="#FFF"> </stop> <stop offset="17%" stop-color="#FFF"> </stop> <stop offset="27%" stop-color="#C82F1C"> </stop> <stop offset="33%" stop-color="#820C01"> </stop> <stop offset="46%" stop-color="#A31601"> </stop> <stop offset="72%" stop-color="#B31301"> </stop> <stop offset="99%" stop-color="#E82609"> </stop> <stop offset="100%" stop-color="#E82609"> </stop> </lineargradient> <lineargradient id=":R3httqcmqn9:j" x1="58.792%" x2="11.964%" y1="65.205%" y2="50.128%"> <stop offset="0%" stop-color="#8C0C01"> </stop> <stop offset="0%" stop-color="#8C0C01"> </stop> <stop offset="54%" stop-color="#990C00"> </stop> <stop offset="99%" stop-color="#A80D0E"> </stop> <stop offset="100%" stop-color="#A80D0E"> </stop> </lineargradient> <lineargradient id=":R3httqcmqn9:k" x1="79.319%" x2="23.088%" y1="62.754%" y2="17.888%"> <stop offset="0%" stop-color="#7E110B"> </stop> <stop offset="0%" stop-color="#7E110B"> </stop> <stop offset="99%" stop-color="#9E0C00"> </stop> <stop offset="100%" stop-color="#9E0C00"> </stop> </lineargradient> <lineargradient id=":R3httqcmqn9:l" x1="92.88%" x2="59.841%" y1="74.122%" y2="39.704%"> <stop offset="0%" stop-color="#79130D"> </stop> <stop offset="0%" stop-color="#79130D"> </stop> <stop offset="99%" stop-color="#9E120B"> </stop> <stop offset="100%" stop-color="#9E120B"> </stop> </lineargradient> <lineargradient id=":R3httqcmqn9:o" x1="56.57%" x2="3.105%" y1="101.717%" y2="11.993%"> <stop offset="0%" stop-color="#8B2114"> </stop> <stop offset="0%" stop-color="#8B2114"> </stop> <stop offset="43%" stop-color="#9E100A"> </stop> <stop offset="99%" stop-color="#B3100C"> </stop> <stop offset="100%" stop-color="#B3100C"> </stop> </lineargradient> <lineargradient id=":R3httqcmqn9:p" x1="30.87%" x2="92.471%" y1="35.599%" y2="100.694%"> <stop offset="0%" stop-color="#B31000"> </stop> <stop offset="0%" stop-color="#B31000"> </stop> <stop offset="44%" stop-color="#910F08"> </stop> <stop offset="99%" stop-color="#791C12"> </stop> <stop offset="100%" stop-color="#791C12"> </stop> </lineargradient> <radialgradient cx="32.001%" cy="40.21%" fx="32.001%" fy="40.21%" id=":R3httqcmqn9:m" r="69.573%"> <stop offset="0%" stop-color="#A80D00"> </stop> <stop offset="0%" stop-color="#A80D00"> </stop> <stop offset="99%" stop-color="#7E0E08"> </stop> <stop offset="100%" stop-color="#7E0E08"> </stop> </radialgradient> <radialgradient cx="13.549%" cy="40.86%" fx="13.549%" fy="40.86%" id=":R3httqcmqn9:n" r="88.386%"> <stop offset="0%" stop-color="#A30C00"> </stop> <stop offset="0%" stop-color="#A30C00"> </stop> <stop offset="99%" stop-color="#800E08"> </stop> <stop offset="100%" stop-color="#800E08"> </stop> </radialgradient> </defs> <path d="M197.467 167.764l-145.52 86.41 188.422-12.787L254.88 51.393l-57.414 116.37z" fill="url(#:R3httqcmqn9:a)"> </path> <path d="M240.677 241.257L224.482 129.48l-44.113 58.25 60.308 53.528z" fill="url(#:R3httqcmqn9:b)"> </path> <path d="M240.896 241.257l-118.646-9.313-69.674 21.986 188.32-12.673z" fill="url(#:R3httqcmqn9:c)"> </path> <path d="M52.744 253.955l29.64-97.1L17.16 170.8l35.583 83.154z" fill="url(#:R3httqcmqn9:d)"> </path> <path d="M180.358 188.05L153.085 81.226l-78.047 73.16 105.32 33.666z" fill="url(#:R3httqcmqn9:e)"> </path> <path d="M248.693 82.73l-73.777-60.256-20.544 66.418 94.321-6.162z" fill="url(#:R3httqcmqn9:f)"> </path> <path d="M214.191.99L170.8 24.97 143.424.669l70.767.322z" fill="url(#:R3httqcmqn9:g)"> </path> <path d="M0 203.372l18.177-33.151-14.704-39.494L0 203.372z" fill="url(#:R3httqcmqn9:h)"> </path> <path d="M2.496 129.48l14.794 41.963 64.283-14.422 73.39-68.207 20.712-65.787L143.063 0 87.618 20.75c-17.469 16.248-51.366 48.396-52.588 49-1.21.618-22.384 40.639-32.534 59.73z" fill="#FFF"> </path> <path d="M54.442 54.094c37.86-37.538 86.667-59.716 105.397-40.818 18.72 18.898-1.132 64.823-38.992 102.349-37.86 37.525-86.062 60.925-104.78 42.027-18.73-18.885.515-66.032 38.375-103.558z" fill="url(#:R3httqcmqn9:i)"> </path> <path d="M52.744 253.916l29.408-97.409 97.665 31.376c-35.312 33.113-74.587 61.106-127.073 66.033z" fill="url(#:R3httqcmqn9:j)"> </path> <path d="M155.092 88.622l25.073 99.313c29.498-31.016 55.972-64.36 68.938-105.603l-94.01 6.29z" fill="url(#:R3httqcmqn9:k)"> </path> <path d="M248.847 82.833c10.035-30.282 12.35-73.725-34.966-81.791l-38.825 21.445 73.791 60.346z" fill="url(#:R3httqcmqn9:l)"> </path> <path d="M0 202.935c1.39 49.979 37.448 50.724 52.808 51.162l-35.48-82.86L0 202.935z" fill="#9E1209"> </path> <path d="M155.232 88.777c22.667 13.932 68.35 41.912 69.276 42.426 1.44.81 19.695-30.784 23.838-48.64l-93.114 6.214z" fill="url(#:R3httqcmqn9:m)"> </path> <path d="M82.113 156.507l39.313 75.848c23.246-12.607 41.45-27.967 58.121-44.42l-97.434-31.428z" fill="url(#:R3httqcmqn9:n)"> </path> <path d="M17.174 171.34l-5.57 66.328c10.51 14.357 24.97 15.605 40.136 14.486-10.973-27.311-32.894-81.92-34.566-80.814z" fill="url(#:R3httqcmqn9:o)"> </path> <path d="M174.826 22.654l78.1 10.96c-4.169-17.662-16.969-29.06-38.787-32.623l-39.313 21.663z" fill="url(#:R3httqcmqn9:p)"> </path> </svg> <span> Mongoid </span> </a> <a class="leafygreen-ui-18cpm0b" href="https://www.mongodb.com/docs/drivers/rust/current/fundamentals/database-collection/#drop-a-database" target="_self"> <svg class="leafygreen-ui-x3zji3" height="24" viewbox="0 0 30 30" width="24" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_5454_14623)"> <path d="M15.2561 3.08398C8.56014 3.08398 3.11035 8.53634 3.11035 15.2297C3.11035 21.9231 8.56271 27.3755 15.2561 27.3755C21.9495 27.3755 27.4019 21.9231 27.4019 15.2297C27.4019 8.53634 21.9495 3.08398 15.2561 3.08398ZM15.2381 4.16315C15.4458 4.16853 15.6432 4.25509 15.7881 4.40437C15.9331 4.55365 16.0142 4.75384 16.0141 4.96225C16.0141 5.17418 15.9299 5.37744 15.7801 5.5273C15.6302 5.67715 15.4269 5.76134 15.215 5.76134C15.0031 5.76134 14.7998 5.67715 14.65 5.5273C14.5001 5.37744 14.4159 5.17418 14.4159 4.96225C14.4159 4.85533 14.4373 4.7495 14.4789 4.65101C14.5205 4.55252 14.5814 4.46338 14.6581 4.38887C14.7347 4.31435 14.8256 4.25598 14.9252 4.21721C15.0249 4.17844 15.1313 4.16006 15.2381 4.16315ZM17.0676 5.47871C18.4704 5.74146 19.7992 6.30644 20.9617 7.13439C22.1242 7.96235 23.0926 9.03345 23.7995 10.2733L22.8565 12.4008C22.6947 12.7682 22.8617 13.1999 23.2265 13.3643L25.0406 14.1686C25.0968 14.7356 25.1037 15.3065 25.0611 15.8747H24.0513C23.9511 15.8747 23.91 15.9415 23.91 16.0391V16.5016C23.91 17.5911 23.2959 17.83 22.7563 17.8891C22.2424 17.9482 21.6746 17.6733 21.6026 17.3598C21.2994 15.6563 20.7958 15.294 19.9993 14.6645C20.9885 14.0375 22.0163 13.11 22.0163 11.8715C22.0163 10.5328 21.099 9.69002 20.4747 9.27634C19.5959 8.69822 18.6247 8.5826 18.3626 8.5826H7.93063C9.37312 6.97114 11.3066 5.88021 13.4318 5.47871L14.6626 6.76857C14.9401 7.05891 15.4 7.07176 15.6903 6.79169L17.0676 5.47871ZM5.71063 11.3936C5.91853 11.3996 6.11589 11.4864 6.26079 11.6356C6.40568 11.7849 6.48669 11.9847 6.4866 12.1927C6.4866 12.4046 6.40241 12.6079 6.25255 12.7577C6.10269 12.9076 5.89944 12.9918 5.6875 12.9918C5.47557 12.9918 5.27232 12.9076 5.12246 12.7577C4.9726 12.6079 4.88841 12.4046 4.88841 12.1927C4.88836 12.0858 4.90977 11.9799 4.95137 11.8814C4.99297 11.7829 5.0539 11.6938 5.13057 11.6193C5.20724 11.5448 5.29809 11.4864 5.39772 11.4476C5.49736 11.4089 5.60376 11.3905 5.71063 11.3936ZM24.7631 11.4295C24.971 11.4356 25.1683 11.5224 25.3132 11.6716C25.4581 11.8208 25.5391 12.0206 25.539 12.2286C25.539 12.4406 25.4548 12.6438 25.305 12.7937C25.1551 12.9435 24.9519 13.0277 24.7399 13.0277C24.528 13.0277 24.3247 12.9435 24.1749 12.7937C24.025 12.6438 23.9408 12.4406 23.9408 12.2286C23.9408 12.1217 23.9622 12.0159 24.0038 11.9174C24.0454 11.8189 24.1063 11.7298 24.183 11.6553C24.2597 11.5807 24.3505 11.5224 24.4502 11.4836C24.5498 11.4448 24.6562 11.4264 24.7631 11.4295ZM7.21632 11.558H8.60896V17.8377H5.79799C5.45083 16.6186 5.34264 15.3439 5.47938 14.0838L7.20091 13.3181C7.56834 13.1536 7.73535 12.7245 7.57091 12.3571L7.21632 11.558ZM13.0284 11.6248H16.3456C16.5177 11.6248 17.5558 11.8227 17.5558 12.6012C17.5558 13.2461 16.7592 13.4774 16.104 13.4774H13.0258L13.0284 11.6248ZM13.0284 16.1368H15.5696C15.8008 16.1368 16.8106 16.2036 17.1318 17.4934C17.232 17.8891 17.4556 19.179 17.6072 19.5927C17.7588 20.0552 18.3729 20.9802 19.0281 20.9802H23.1751C22.8972 21.3524 22.5933 21.7044 22.2656 22.0336L20.5774 21.6713C20.1843 21.5866 19.7963 21.8384 19.7115 22.2315L19.3107 24.102C18.0217 24.6859 16.622 24.9848 15.2069 24.9781C13.7919 24.9714 12.395 24.6595 11.1116 24.0635L10.7108 22.1929C10.626 21.7998 10.2406 21.548 9.84743 21.6328L8.19528 21.9874C7.88869 21.6711 7.6037 21.3346 7.34223 20.9802H15.3769C15.4668 20.9802 15.5285 20.9647 15.5285 20.88V18.0381C15.5285 17.9559 15.4668 17.9379 15.3769 17.9379H13.0258L13.0284 16.1368ZM9.3207 22.6452C9.5286 22.6512 9.72596 22.738 9.87085 22.8872C10.0157 23.0364 10.0968 23.2363 10.0967 23.4443C10.0967 23.6562 10.0125 23.8594 9.86262 24.0093C9.71276 24.1592 9.50951 24.2434 9.29757 24.2434C9.08564 24.2434 8.88239 24.1592 8.73253 24.0093C8.58267 23.8594 8.49848 23.6562 8.49848 23.4443C8.49843 23.3373 8.51984 23.2315 8.56144 23.133C8.60303 23.0345 8.66397 22.9454 8.74064 22.8709C8.81731 22.7964 8.90815 22.738 9.00779 22.6992C9.10743 22.6605 9.21383 22.6421 9.3207 22.6452ZM21.153 22.6811C21.3609 22.6872 21.5583 22.774 21.7031 22.9232C21.848 23.0724 21.929 23.2722 21.929 23.4802C21.929 23.6922 21.8448 23.8954 21.6949 24.0453C21.5451 24.1951 21.3418 24.2793 21.1299 24.2793C20.9179 24.2793 20.7147 24.1951 20.5648 24.0453C20.415 23.8954 20.3308 23.6922 20.3308 23.4802C20.3307 23.3733 20.3521 23.2675 20.3937 23.169C20.4353 23.0705 20.4963 22.9814 20.5729 22.9068C20.6496 22.8323 20.7404 22.774 20.8401 22.7352C20.9397 22.6964 21.0461 22.678 21.153 22.6811Z" fill="black"> </path> <path clip-rule="evenodd" d="M26.7232 15.2304C26.7232 18.2717 25.515 21.1885 23.3645 23.3391C21.2139 25.4896 18.2971 26.6978 15.2558 26.6978C12.2144 26.6978 9.29761 25.4896 7.14705 23.3391C4.99649 21.1885 3.78832 18.2717 3.78832 15.2304C3.78832 12.189 4.99649 9.27222 7.14705 7.12166C9.29761 4.9711 12.2144 3.76293 15.2558 3.76293C18.2971 3.76293 21.2139 4.9711 23.3645 7.12166C25.515 9.27222 26.7232 12.189 26.7232 15.2304ZM26.5073 14.1229L28.2957 15.2304L26.5073 16.3378L28.0439 17.7741L26.0757 18.5115L27.3039 20.2202L25.2252 20.5594L26.0988 22.4762L23.9944 22.4017L24.4775 24.4521L22.4271 23.969L22.5016 26.0734L20.5848 25.1998L20.2456 27.2785L18.5369 26.0503L17.7995 28.0185L16.3632 26.482L15.2558 28.2703L14.1483 26.482L12.712 28.0185L11.9746 26.0503L10.2659 27.2785L9.92672 25.1998L8.00992 26.0734L8.08443 23.969L6.03401 24.4521L6.51707 22.4017L4.4127 22.4762L5.28631 20.5594L3.20763 20.2202L4.43582 18.5115L2.46763 17.7741L4.00415 16.3378L2.21582 15.2304L4.00415 14.1229L2.46763 12.6866L4.43582 11.9492L3.20763 10.2405L5.28631 9.90133L4.4127 7.98453L6.51707 8.05904L6.03401 6.00862L8.08443 6.49168L8.00992 4.3873L9.92672 5.26092L10.2659 3.18223L11.9746 4.41043L12.712 2.44224L14.1483 3.97876L15.2558 2.19043L16.3632 3.97876L17.7995 2.44224L18.5369 4.41043L20.2456 3.18223L20.5848 5.26092L22.5016 4.3873L22.4271 6.49168L24.4775 6.00862L23.9944 8.05904L26.0988 7.98453L25.2252 9.90133L27.3039 10.2405L26.0757 11.9492L28.0439 12.6866L26.5073 14.1229Z" fill="black" fill-rule="evenodd" stroke-linecap="round" stroke-linejoin="round"> </path> </g> <defs> <clippath id="clip0_5454_14623"> <rect fill="black" height="30" width="30"> </rect> </clippath> </defs> </svg> <span> Rust </span> </a> <a class="leafygreen-ui-18cpm0b" href="https://mongodb.github.io/mongo-scala-driver/2.0/scaladoc/org/mongodb/scala/SingleObservable.html" target="_self"> <svg class="leafygreen-ui-x3zji3" height="24" viewbox="0 0 70 70" width="24" xmlns="http://www.w3.org/2000/svg"> <defs> <lineargradient id=":R3pttqcmqn9:aaa" x1=".006%" x2="96.837%" y1="49.998%" y2="49.998%"> <stop offset="0%" stop-color="#CD413F"> </stop> <stop offset="75.091%" stop-color="#CD4543"> </stop> <stop offset="100%" stop-color="#D04543"> </stop> </lineargradient> </defs> <g fill="none" fill-rule="nonzero"> <path d="M13 39v5c0 .843 17.73 2.255 29.28 5 5.582-1.327 9.72-2.966 9.72-5v-5c0-2.034-4.138-3.673-9.72-5C30.73 36.745 13 38.157 13 39M13 20v5c0 .843 17.73 2.255 29.28 5 5.582-1.327 9.72-2.966 9.72-5v-5c0-2.034-4.138-3.673-9.72-5C30.73 17.745 13 19.157 13 20" fill="#731818"> </path> <g fill="url(#:R3pttqcmqn9:aaa)" transform="translate(13)"> <path d="M0 29.53v14.766c0-1.232 39-3.692 39-9.844V19.686c0 6.152-39 8.612-39 9.844M0 9.843V24.61c0-1.231 39-3.691 39-9.843V0C39 6.152 0 8.612 0 9.843M0 49.216v14.766c0-1.231 39-3.691 39-9.843V39.373c0 6.151-39 8.612-39 9.843"> </path> </g> </g> </svg> <span> Scala </span> </a> </div> <button class="leafygreen-ui-ki2t97"> Show all <svg aria-label="Chevron Down Icon" class="" fill="none" height="16" role="img" viewbox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M1.636 5.364a1 1 0 0 0 0 1.414l4.95 4.95.707.707a1 1 0 0 0 1.414 0l.707-.707 4.95-4.95a1 1 0 0 0 0-1.414l-.707-.707a1 1 0 0 0-1.414 0L8 8.899 3.757 4.657a1 1 0 0 0-1.414 0l-.707.707Z" fill="currentColor" fill-rule="evenodd"> </path> </svg> </button> </div> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Definition <a class="headerlink leafygreen-ui-1kepx47" href="#definition" 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="definition"> </div> </a> </h2> <dl class="method"> <dt> <code class="leafygreen-ui-1l06pbn"> db.collection.drop(&lt;options&gt;) </code> <a class="headerlink leafygreen-ui-1kepx47" href="#mongodb-method-db.collection.drop" title="Permalink to this definition"> <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="mongodb-method-db.collection.drop"> </div> </a> </dt> <dd> <p class="leafygreen-ui-1kp3ins"> Removes a collection or <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/views/#std-label-views-landing-page"> view </a> from the database. The method also removes any indexes associated with the dropped collection. The method provides a wrapper around the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/command/drop/#mongodb-dbcommand-dbcmd.drop"> <code class="leafygreen-ui-1l06pbn"> drop </code> </a> command. </p> <table class="css-11h39yh e1nex8bq0"> <colgroup> <col class="field-name"/> <col class="field-body"/> </colgroup> <tbody> <tr class="css-x8snli"> <th> Returns <!-- --> : </th> <td> <code class="leafygreen-ui-1l06pbn"> true </code> </td> </tr> </tbody> </table> </dd> </dl> <div class="leafygreen-ui-15mdk4" role="note"> <h2 class="leafygreen-ui-6n7b7d"> Note </h2> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> If the specified collection doesn't exist, <code class="leafygreen-ui-1l06pbn"> db.collection.drop() </code> still returns <code class="leafygreen-ui-1l06pbn"> true </code> . </p> </div> </div> </section> <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 <code class="leafygreen-ui-1l06pbn"> db.collection.drop() </code> 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"> Syntax <a class="headerlink leafygreen-ui-1kepx47" href="#syntax" 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="syntax"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> The <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-method-db.collection.drop" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> drop() </code> </span> </a> method has the following form: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.collection.drop( { writeConcern: &lt;document&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">drop</span>( <!-- -->{ <span class="lg-highlight-attr">writeConcern</span>: &lt;<span class="lg-highlight-variable lg-highlight-language">document</span>&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 <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-method-db.collection.drop" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> drop() </code> </span> </a> method takes an optional document with the following field: </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> Field </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> writeConcern </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <p class="leafygreen-ui-1kp3ins"> Optional. A document expressing the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/write-concern/"> write concern </a> of the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-method-db.collection.drop" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> db.collection.drop() </code> </span> </a> operation. Omit to use the default write concern. </p> <p class="leafygreen-ui-1kp3ins"> When issued on a sharded cluster, <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongos/#mongodb-binary-bin.mongos"> <code class="leafygreen-ui-1l06pbn"> mongos </code> </a> converts the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/write-concern/#std-label-write-concern"> write concern </a> of the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/command/drop/#mongodb-dbcommand-dbcmd.drop"> <code class="leafygreen-ui-1l06pbn"> drop </code> </a> command and its helper <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-method-db.collection.drop" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> db.collection.drop() </code> </span> </a> to <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/write-concern/#mongodb-writeconcern-writeconcern.-majority-"> <code class="leafygreen-ui-1l06pbn"> "majority" </code> . </a> </p> </div> </div> </td> </tr> </tbody> </table> </div> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Behavior <a class="headerlink leafygreen-ui-1kepx47" href="#behavior" 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="behavior"> </div> </a> </h2> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> The <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-method-db.collection.drop" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> db.collection.drop() </code> </span> </a> method and <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/command/drop/#mongodb-dbcommand-dbcmd.drop"> <code class="leafygreen-ui-1l06pbn"> drop </code> </a> command create an <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/change-events/invalidate/#std-label-change-event-invalidate"> invalidate </a> for any <a class="leafygreen-ui-tqgtui" href="/docs/manual/changeStreams/"> Change Streams </a> opened on dropped collection. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> The <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-method-db.collection.drop" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> db.collection.drop() </code> </span> </a> method and <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/command/drop/#mongodb-dbcommand-dbcmd.drop"> <code class="leafygreen-ui-1l06pbn"> drop </code> </a> command abort any in-progress index builds on the target collection before dropping the collection. </p> <p class="leafygreen-ui-1kp3ins"> For replica sets or shard replica sets, aborting an index on the primary does not simultaneously abort secondary index builds. MongoDB attempts to abort the in-progress builds for the specified indexes on the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-primary"> primary </a> and if successful creates an associated <code class="leafygreen-ui-1l06pbn"> abort </code> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-oplog"> oplog </a> entry. <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-secondary"> Secondary </a> members with replicated in-progress builds wait for a commit or abort oplog entry from the primary before either committing or aborting the index build. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Dropping a collection deletes its associated zone/tag ranges. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Starting in MongoDB 5.0, the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/command/drop/#mongodb-dbcommand-dbcmd.drop"> <code class="leafygreen-ui-1l06pbn"> drop </code> </a> command and the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-method-db.collection.drop" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> db.collection.drop() </code> </span> </a> method return an error if you try to drop a collection in the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-admin-database"> admin database </a> or the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-config-database"> config database </a> from a <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongos/#mongodb-binary-bin.mongos"> <code class="leafygreen-ui-1l06pbn"> mongos </code> </a> . To drop these collections, connect to the <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/sharded-cluster-config-servers/#std-label-sharded-cluster-config-server"> config server </a> and run the command there. </p> <div class="leafygreen-ui-1sjx7ru" role="note"> <h2 class="leafygreen-ui-29m78u"> Warning </h2> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> Dropping collections in the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-admin-database"> admin database </a> or the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-config-database"> config database </a> can leave your cluster in an unusable state. </p> </div> </div> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Starting in MongoDB 6.0, the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-method-db.collection.drop" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> db.collection.drop() </code> </span> </a> method drops the specified collection and any internal collections related to encrypted fields. </p> <div class="leafygreen-ui-1sjx7ru" role="note"> <h2 class="leafygreen-ui-29m78u"> Warning </h2> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> The <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-method-db.collection.drop" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> db.collection.drop() </code> </span> </a> method's behavior differs from the driver's <code class="leafygreen-ui-1l06pbn"> drop </code> method's behavior. The driver's connection must have automatic encryption enabled in order to drop both the specified collection and any internal collections related to encrypted fields. <code class="leafygreen-ui-1l06pbn"> mongosh </code> <em> always </em> drops the specified collection and any internal collections related to encrypted fields. </p> </div> </div> </li> </ul> <span class="leafygreen-ui-1qnjd6d" id="std-label-sharding-drop-collections-same-name"> </span> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Reusing Dropped Collection Names on Sharded Clusters <a class="headerlink leafygreen-ui-1kepx47" href="#reusing-dropped-collection-names-on-sharded-clusters" 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="reusing-dropped-collection-names-on-sharded-clusters"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> On a sharded cluster, if you create a collection that has the same name as a previously deleted collection prior to MongoDB 5.0, <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongos/#mongodb-binary-bin.mongos"> <code class="leafygreen-ui-1l06pbn"> mongos </code> </a> may forward operations to the wrong shard. To avoid this situation use the version-specific instructions below: </p> <p class="leafygreen-ui-1kp3ins"> For a sharded cluster running <strong> MongoDB 5.0 or later </strong> , no special action is required. Use the <code class="leafygreen-ui-1l06pbn"> drop() </code> method and then create a new collection with the same name. </p> <p class="leafygreen-ui-1kp3ins"> For a sharded cluster, if you use the <code class="leafygreen-ui-1l06pbn"> drop() </code> method and then create a new collection with the same name, you must either: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Flush the cached routing table on every <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongos/#mongodb-binary-bin.mongos"> <code class="leafygreen-ui-1l06pbn"> mongos </code> </a> using <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/command/flushRouterConfig/#mongodb-dbcommand-dbcmd.flushRouterConfig"> <code class="leafygreen-ui-1l06pbn"> flushRouterConfig </code> . </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Use <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/db.collection.remove/#mongodb-method-db.collection.remove"> <code class="leafygreen-ui-1l06pbn"> db.collection.remove() </code> </a> to remove the existing documents and reuse the collection. </p> </li> </ul> <p class="leafygreen-ui-1kp3ins"> Flushing the cached routing tables is the preferred procedure because it is faster than removing sharded collections with <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/db.collection.remove/#mongodb-method-db.collection.remove"> <code class="leafygreen-ui-1l06pbn"> db.collection.remove() </code> </a> . Only use the <code class="leafygreen-ui-1l06pbn"> remove() </code> approach if you want to avoid flushing the cache. </p> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Resource Locking <a class="headerlink leafygreen-ui-1kepx47" href="#resource-locking" 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="resource-locking"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-method-db.collection.drop" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> db.collection.drop() </code> </span> </a> obtains an exclusive lock on the specified collection for the duration of the operation. All subsequent operations on the collection must wait until <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-method-db.collection.drop" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> db.collection.drop() </code> </span> </a> releases the lock. </p> </section> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Example <a class="headerlink leafygreen-ui-1kepx47" href="#example" 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="example"> </div> </a> </h2> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Drop a Collection Using Default Write Concern <a class="headerlink leafygreen-ui-1kepx47" href="#drop-a-collection-using-default-write-concern" 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="drop-a-collection-using-default-write-concern"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> The following operation drops the <code class="leafygreen-ui-1l06pbn"> students </code> collection in the current database. </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.students.drop()","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">students</span>.<span class="lg-highlight-title lg-highlight-function">drop</span>(<!-- -->)</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> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Drop a Collection Using <code class="leafygreen-ui-1l06pbn"> w: 1 </code> Write Concern <a class="headerlink leafygreen-ui-1kepx47" href="#drop-a-collection-using-w--1-write-concern" 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="drop-a-collection-using-w--1-write-concern"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-method-db.collection.drop" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> db.collection.drop() </code> </span> </a> accepts an options document. </p> <p class="leafygreen-ui-1kp3ins"> The following operation drops the <code class="leafygreen-ui-1l06pbn"> students </code> collection in the current database. The operation uses the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/write-concern/#mongodb-writeconcern-writeconcern.-number-"> <code class="leafygreen-ui-1l06pbn"> 1 </code> </a> write concern: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.students.drop( { writeConcern: { w: 1 } } )","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">students</span>.<span class="lg-highlight-title lg-highlight-function">drop</span>( <!-- -->{ <span class="lg-highlight-attr">writeConcern</span>: <!-- -->{ <span class="lg-highlight-attr">w</span>: <span class="lg-highlight-number">1</span> } } )</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> </section> </section> </section>
https://www.mongodb.com/docs/manual/reference/operator/aggregation/regexFind/
<section> <h1 class="contains-headerlink leafygreen-ui-41fr9s" weight="medium"> $regexFind (aggregation) <a class="headerlink leafygreen-ui-1kepx47" href="#-regexfind--aggregation-" 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="-regexfind--aggregation-"> </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="#definition" target="_self"> <span> Definition </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#syntax" target="_self"> <span> Syntax </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#behavior" target="_self"> <span> Behavior </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#examples" target="_self"> <span> Examples </span> </a> </li> </ul> </div> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Definition <a class="headerlink leafygreen-ui-1kepx47" href="#definition" 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="definition"> </div> </a> </h2> <dl class="expression"> <dt> <code class="leafygreen-ui-1l06pbn"> $regexFind </code> <a class="headerlink leafygreen-ui-1kepx47" href="#mongodb-expression-exp.-regexFind" title="Permalink to this definition"> <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="mongodb-expression-exp.-regexFind"> </div> </a> </dt> <dd> <p class="leafygreen-ui-1kp3ins"> Provides regular expression (regex) pattern matching capability in aggregation expressions. If a match is found, returns a document that contains information on the <em> first </em> match. If a match is not found, returns null. </p> </dd> </dl> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Syntax <a class="headerlink leafygreen-ui-1kepx47" href="#syntax" 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="syntax"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> The <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-expression-exp.-regexFind" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $regexFind </code> </span> </a> operator has the following syntax: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ $regexFind: { input: &lt;expression&gt; , regex: &lt;expression&gt;, options: &lt;expression&gt; } }","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-1q4bxgx" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-attr">$regexFind</span>: <!-- -->{ <span class="lg-highlight-attr">input</span>: &lt;<!-- -->expression<!-- -->&gt; <!-- -->,<!-- --> <span class="lg-highlight-attr">regex</span>: &lt;<!-- -->expression<!-- -->&gt;<!-- -->,<!-- --> <span class="lg-highlight-attr">options</span>: &lt;<!-- -->expression<!-- -->&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> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Operator Fields <a class="headerlink leafygreen-ui-1kepx47" href="#operator-fields" 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="operator-fields"> </div> </a> </h3> <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> Field </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="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-regexFind-input" target="_self"> <span> input </span> </a> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <span class="leafygreen-ui-1qnjd6d" id="std-label-regexFind-input"> </span> <p class="leafygreen-ui-1kp3ins"> The string on which you wish to apply the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-regexFind-regex" target="_self"> <span> regex pattern </span> </a> . Can be a string or any valid <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/#std-label-aggregation-expressions"> expression </a> that resolves to a string. </p> </div> </div> </td> </tr> <tr class=""> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-regexFind-regex" target="_self"> <span> regex </span> </a> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <span class="leafygreen-ui-1qnjd6d" id="std-label-regexFind-regex"> </span> <p class="leafygreen-ui-1kp3ins"> The regex pattern to apply. Can be any valid <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/#std-label-aggregation-expressions"> expression </a> that resolves to either a string or regex pattern <code class="leafygreen-ui-1l06pbn"> /&lt;pattern&gt;/ </code> . When using the regex <code class="leafygreen-ui-1l06pbn"> /&lt;pattern&gt;/ </code> , you can also specify the regex options <code class="leafygreen-ui-1l06pbn"> i </code> and <code class="leafygreen-ui-1l06pbn"> m </code> (but not the <code class="leafygreen-ui-1l06pbn"> s </code> or <code class="leafygreen-ui-1l06pbn"> x </code> options): </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <code class="leafygreen-ui-1l06pbn"> "pattern" </code> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <code class="leafygreen-ui-1l06pbn"> /&lt;pattern&gt;/ </code> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <code class="leafygreen-ui-1l06pbn"> /&lt;pattern&gt;/&lt;options&gt; </code> </p> </li> </ul> <p class="leafygreen-ui-1kp3ins"> Alternatively, you can also specify the regex options with the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-regexFind-options" target="_self"> <span> options </span> </a> field. To specify the <code class="leafygreen-ui-1l06pbn"> s </code> or <code class="leafygreen-ui-1l06pbn"> x </code> options, you must use the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-regexFind-options" target="_self"> <span> options </span> </a> field. </p> <p class="leafygreen-ui-1kp3ins"> You cannot specify options in both the <code class="leafygreen-ui-1l06pbn"> regex </code> and the <code class="leafygreen-ui-1l06pbn"> options </code> field. </p> </div> </div> </td> </tr> <tr class=""> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-regexFind-options" target="_self"> <span> options </span> </a> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <span class="leafygreen-ui-1qnjd6d" id="std-label-regexFind-options"> </span> <p class="leafygreen-ui-1kp3ins"> <em> Optional </em> . The following <code class="leafygreen-ui-1l06pbn"> &lt;options&gt; </code> are available for use with regular expression. </p> <p class="leafygreen-ui-1kp3ins"> You cannot specify options in both the <code class="leafygreen-ui-1l06pbn"> regex </code> and the <code class="leafygreen-ui-1l06pbn"> options </code> field. </p> <div class="leafygreen-ui-skkc39" tabindex="0"> <table class="leafygreen-ui-hr8lsv"> <colgroup> <col style="width:10%"/> <col style="width:90%"/> </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> Option </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> <code class="leafygreen-ui-1l06pbn"> i </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Case insensitivity to match both upper and lower cases. You can specify the option in the <code class="leafygreen-ui-1l06pbn"> options </code> field or as part of the regex field. </div> </div> </td> </tr> <tr class=""> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> m </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <p class="leafygreen-ui-1kp3ins"> For patterns that include anchors (i.e. <code class="leafygreen-ui-1l06pbn"> ^ </code> for the start, <code class="leafygreen-ui-1l06pbn"> $ </code> for the end), match at the beginning or end of each line for strings with multiline values. Without this option, these anchors match at beginning or end of the string. </p> <p class="leafygreen-ui-1kp3ins"> If the pattern contains no anchors or if the string value has no newline characters (e.g. <code class="leafygreen-ui-1l06pbn"> \n </code> ), the <code class="leafygreen-ui-1l06pbn"> m </code> option has no effect. </p> </div> </div> </td> </tr> <tr class=""> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> x </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <p class="leafygreen-ui-1kp3ins"> "Extended" capability to ignore all white space characters in the pattern unless escaped or included in a character class. </p> <p class="leafygreen-ui-1kp3ins"> Additionally, it ignores characters in-between and including an un-escaped hash/pound ( <code class="leafygreen-ui-1l06pbn"> # </code> ) character and the next new line, so that you may include comments in complicated patterns. This only applies to data characters; white space characters may never appear within special character sequences in a pattern. </p> <p class="leafygreen-ui-1kp3ins"> The <code class="leafygreen-ui-1l06pbn"> x </code> option does not affect the handling of the VT character (i.e. code 11). </p> <p class="leafygreen-ui-1kp3ins"> You can specify the option only in the <code class="leafygreen-ui-1l06pbn"> options </code> field. </p> </div> </div> </td> </tr> <tr class=""> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> s </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <p class="leafygreen-ui-1kp3ins"> Allows the dot character (i.e. <code class="leafygreen-ui-1l06pbn"> . </code> ) to match all characters <em> including </em> newline characters. </p> <p class="leafygreen-ui-1kp3ins"> You can specify the option only in the <code class="leafygreen-ui-1l06pbn"> options </code> field. </p> </div> </div> </td> </tr> </tbody> </table> </div> </div> </div> </td> </tr> </tbody> </table> </div> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Returns <a class="headerlink leafygreen-ui-1kepx47" href="#returns" 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="returns"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> If the operator does not find a match, the result of the operator is a <code class="leafygreen-ui-1l06pbn"> null </code> . </p> <p class="leafygreen-ui-1kp3ins"> If the operator finds a match, the result of the operator is a document that contains: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> the <em> first </em> matching string in the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-regexFind-input" target="_self"> <span> input <!-- --> , </span> </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="http://www.unicode.org/glossary/#code_point" rel="noopener noreferrer"> <span> code point </span> <svg alt="" aria-hidden="true" class="leafygreen-ui-1ie5kuq" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M13.823 2.4491C13.8201 2.30008 13.6999 2.17994 13.5509 2.17704L9.5062 2.09836C9.25654 2.09351 9.12821 2.39519 9.30482 2.5718L10.3856 3.65257L7.93433 6.10383C7.87964 6.15852 7.83047 6.21665 7.78683 6.27752L5.99909 8.06525C5.46457 8.59977 5.46457 9.4664 5.99909 10.0009C6.53361 10.5354 7.40023 10.5354 7.93475 10.0009L9.72249 8.21317C9.78336 8.16953 9.84148 8.12037 9.89618 8.06567L12.3474 5.61441L13.4282 6.69518C13.6048 6.87179 13.9065 6.74347 13.9016 6.4938L13.823 2.4491Z" fill="currentColor"> </path> <path d="M7.25 3.12893C7.66421 3.12893 8 3.46472 8 3.87893C8 4.29315 7.66421 4.62893 7.25 4.62893H4C3.72386 4.62893 3.5 4.85279 3.5 5.12893V11.9929C3.5 12.2691 3.72386 12.4929 4 12.4929H10.864C11.1401 12.4929 11.364 12.2691 11.364 11.9929V8.75C11.364 8.33579 11.6998 8 12.114 8C12.5282 8 12.864 8.33579 12.864 8.75V11.9929C12.864 13.0975 11.9686 13.9929 10.864 13.9929H4C2.89543 13.9929 2 13.0975 2 11.9929V5.12893C2 4.02436 2.89543 3.12893 4 3.12893H7.25Z" fill="currentColor"> </path> </svg> </a> index (not byte index) of the matching string in the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-regexFind-input" target="_self"> <span> input </span> </a> , and </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> An array of the strings that corresponds to the groups captured by the matching string. Capturing groups are specified with unescaped parenthesis <code class="leafygreen-ui-1l06pbn"> () </code> in the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-regexFind-regex" target="_self"> <span> regex </span> </a> pattern. </p> </li> </ul> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ \"match\" : &lt;string&gt;, \"idx\" : &lt;num&gt;, \"captures\" : &lt;array&gt; }","programmingLanguage":"JavaScript"} </script> <div class="css-1lju8ps"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-tyg50d"> <pre class="leafygreen-ui-1agdxuk" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"match"</span> <!-- -->: &lt;<!-- -->string<!-- -->&gt;<!-- -->,<!-- --> <span class="lg-highlight-string">"idx"</span> <!-- -->: &lt;<!-- -->num<!-- -->&gt;<!-- -->,<!-- --> <span class="lg-highlight-string">"captures"</span> <!-- -->: <span class="lg-highlight-tag lg-highlight-xml">&lt;</span><span class="lg-highlight-name lg-highlight-tag lg-highlight-xml">array</span><span class="lg-highlight-tag lg-highlight-xml"> </span><span class="lg-highlight-attr lg-highlight-tag lg-highlight-xml">of</span><span class="lg-highlight-tag lg-highlight-xml"> </span><span class="lg-highlight-attr lg-highlight-tag lg-highlight-xml">strings</span><span class="lg-highlight-tag lg-highlight-xml">&gt;</span><span class="lg-highlight-xml"> }</span></td></tr></tbody></table></code></pre> </div> </div> </div> <div class="leafygreen-ui-13vw3ie" role="note"> <h2 class="leafygreen-ui-1fn4p2b"> Tip </h2> <h3 class="leafygreen-ui-144d5kf"> <strong> See also: </strong> </h3> <div class="leafygreen-ui-9mycqc"> <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/regexFindAll/#mongodb-expression-exp.-regexFindAll"> <code class="leafygreen-ui-1l06pbn"> $regexFindAll </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/regexMatch/#mongodb-expression-exp.-regexMatch"> <code class="leafygreen-ui-1l06pbn"> $regexMatch </code> </a> </p> </li> </ul> </div> </div> </section> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Behavior <a class="headerlink leafygreen-ui-1kepx47" href="#behavior" 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="behavior"> </div> </a> </h2> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> PCRE Library <a class="headerlink leafygreen-ui-1kepx47" href="#pcre-library" 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="pcre-library"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> Starting in version 6.1, MongoDB uses the PCRE2 (Perl Compatible Regular Expressions) library to implement regular expression pattern matching. To learn more about PCRE2, see the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.pcre.org/current/doc/html/" rel="noopener noreferrer"> <span> PCRE Documentation <!-- --> . </span> <svg alt="" aria-hidden="true" class="leafygreen-ui-1ie5kuq" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M13.823 2.4491C13.8201 2.30008 13.6999 2.17994 13.5509 2.17704L9.5062 2.09836C9.25654 2.09351 9.12821 2.39519 9.30482 2.5718L10.3856 3.65257L7.93433 6.10383C7.87964 6.15852 7.83047 6.21665 7.78683 6.27752L5.99909 8.06525C5.46457 8.59977 5.46457 9.4664 5.99909 10.0009C6.53361 10.5354 7.40023 10.5354 7.93475 10.0009L9.72249 8.21317C9.78336 8.16953 9.84148 8.12037 9.89618 8.06567L12.3474 5.61441L13.4282 6.69518C13.6048 6.87179 13.9065 6.74347 13.9016 6.4938L13.823 2.4491Z" fill="currentColor"> </path> <path d="M7.25 3.12893C7.66421 3.12893 8 3.46472 8 3.87893C8 4.29315 7.66421 4.62893 7.25 4.62893H4C3.72386 4.62893 3.5 4.85279 3.5 5.12893V11.9929C3.5 12.2691 3.72386 12.4929 4 12.4929H10.864C11.1401 12.4929 11.364 12.2691 11.364 11.9929V8.75C11.364 8.33579 11.6998 8 12.114 8C12.5282 8 12.864 8.33579 12.864 8.75V11.9929C12.864 13.0975 11.9686 13.9929 10.864 13.9929H4C2.89543 13.9929 2 13.0975 2 11.9929V5.12893C2 4.02436 2.89543 3.12893 4 3.12893H7.25Z" fill="currentColor"> </path> </svg> </a> </p> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> <code class="leafygreen-ui-1l06pbn"> $regexFind </code> and Collation <a class="headerlink leafygreen-ui-1kepx47" href="#-regexfind-and-collation" 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="-regexfind-and-collation"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-expression-exp.-regexFind" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $regexFind </code> </span> </a> ignores the collation specified for the collection, <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> , and the index, if used. </p> <p class="leafygreen-ui-1kp3ins"> For example, the create a sample collection with collation strength <code class="leafygreen-ui-1l06pbn"> 1 </code> (i.e. compare base character only and ignore other differences such as case and diacritics): </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.createCollection( \"myColl\", { collation: { locale: \"fr\", strength: 1 } } )","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-1q4bxgx" tabindex="0"><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">createCollection</span>( <span class="lg-highlight-string">"myColl"</span>, <!-- -->{ <span class="lg-highlight-attr">collation</span>: <!-- -->{ <span class="lg-highlight-attr">locale</span>: <span class="lg-highlight-string">"fr"</span>, <span class="lg-highlight-attr">strength</span>: <span class="lg-highlight-number">1</span> } } )</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"> Insert the following documents: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.myColl.insertMany([\n { _id: 1, category: \"café\" },\n { _id: 2, category: \"cafe\" },\n { _id: 3, category: \"cafE\" }\n])","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">myColl</span>.<span class="lg-highlight-title lg-highlight-function">insertMany</span>(<!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">1</span>, <span class="lg-highlight-attr">category</span>: <span class="lg-highlight-string">"café"</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">2</span>, <span class="lg-highlight-attr">category</span>: <span class="lg-highlight-string">"cafe"</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">3</span>, <span class="lg-highlight-attr">category</span>: <span class="lg-highlight-string">"cafE"</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">])</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"> Using the collection's collation, the following operation performs a case-insensitive and diacritic-insensitive match: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.myColl.aggregate( [ { $match: { category: \"cafe\" } } ] )","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-1q4bxgx" tabindex="0"><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">myColl</span>.<span class="lg-highlight-title lg-highlight-function">aggregate</span>( <!-- -->[ <!-- -->{ <span class="lg-highlight-attr">$match</span>: <!-- -->{ <span class="lg-highlight-attr">category</span>: <span class="lg-highlight-string">"cafe"</span> } } ] )</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 operation returns the following 3 documents: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ \"_id\" : 1, \"category\" : \"café\" }\n{ \"_id\" : 2, \"category\" : \"cafe\" }\n{ \"_id\" : 3, \"category\" : \"cafE\" }","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">1</span>, <span class="lg-highlight-string">"category"</span> <!-- -->: <span class="lg-highlight-string">"café"</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">2</span>, <span class="lg-highlight-string">"category"</span> <!-- -->: <span class="lg-highlight-string">"cafe"</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">3</span>, <span class="lg-highlight-string">"category"</span> <!-- -->: <span class="lg-highlight-string">"cafE"</span> }</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"> However, the aggregation expression <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-expression-exp.-regexFind" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $regexFind </code> </span> </a> ignores collation; that is, the following regular expression pattern matching examples are case-sensitive and diacritic sensitive: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.myColl.aggregate( [ { $addFields: { resultObject: { $regexFind: { input: \"$category\", regex: /cafe/ } } } } ] )\ndb.myColl.aggregate(\n [ { $addFields: { resultObject: { $regexFind: { input: \"$category\", regex: /cafe/ } } } } ],\n { collation: { locale: \"fr\", strength: 1 } } // Ignored in the $regexFind\n)","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><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">myColl</span>.<span class="lg-highlight-title lg-highlight-function">aggregate</span>( <!-- -->[ <!-- -->{ <span class="lg-highlight-attr">$addFields</span>: <!-- -->{ <span class="lg-highlight-attr">resultObject</span>: <!-- -->{ <span class="lg-highlight-attr">$regexFind</span>: <!-- -->{ <span class="lg-highlight-attr">input</span>: <span class="lg-highlight-string">"$category"</span>, <span class="lg-highlight-attr">regex</span>: <span class="lg-highlight-regexp">/cafe/</span> <!-- -->} } } } ] )</td></tr><tr class=""><td class="leafygreen-ui-7razhx">db.<span class="lg-highlight-property">myColl</span>.<span class="lg-highlight-title lg-highlight-function">aggregate</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->[ <!-- -->{ <span class="lg-highlight-attr">$addFields</span>: <!-- -->{ <span class="lg-highlight-attr">resultObject</span>: <!-- -->{ <span class="lg-highlight-attr">$regexFind</span>: <!-- -->{ <span class="lg-highlight-attr">input</span>: <span class="lg-highlight-string">"$category"</span>, <span class="lg-highlight-attr">regex</span>: <span class="lg-highlight-regexp">/cafe/</span> <!-- -->} } } } ]<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">collation</span>: <!-- -->{ <span class="lg-highlight-attr">locale</span>: <span class="lg-highlight-string">"fr"</span>, <span class="lg-highlight-attr">strength</span>: <span class="lg-highlight-number">1</span> } } <span class="lg-highlight-comment">//</span><span class="lg-highlight-comment"> Ignored in the </span><span class="lg-highlight-comment">$regexFind</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx">)</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"> Both operations return the following: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ \"_id\" : 1, \"category\" : \"café\", \"resultObject\" : null }\n{ \"_id\" : 2, \"category\" : \"cafe\", \"resultObject\" : { \"match\" : \"cafe\", \"idx\" : 0, \"captures\" : [ ] } }\n{ \"_id\" : 3, \"category\" : \"cafE\", \"resultObject\" : null }","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">1</span>, <span class="lg-highlight-string">"category"</span> <!-- -->: <span class="lg-highlight-string">"café"</span>, <span class="lg-highlight-string">"resultObject"</span> <!-- -->: <span class="lg-highlight-literal">null</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">2</span>, <span class="lg-highlight-string">"category"</span> <!-- -->: <span class="lg-highlight-string">"cafe"</span>, <span class="lg-highlight-string">"resultObject"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-string">"match"</span> <!-- -->: <span class="lg-highlight-string">"cafe"</span>, <span class="lg-highlight-string">"idx"</span> <!-- -->: <span class="lg-highlight-number">0</span>, <span class="lg-highlight-string">"captures"</span> <!-- -->: <!-- -->[ <!-- -->] } }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">3</span>, <span class="lg-highlight-string">"category"</span> <!-- -->: <span class="lg-highlight-string">"cafE"</span>, <span class="lg-highlight-string">"resultObject"</span> <!-- -->: <span class="lg-highlight-literal">null</span> }</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"> To perform a case-insensitive regex pattern matching, use the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-regexFind-example-i-options" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> i </code> Option </span> </a> instead. See <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-regexFind-example-i-options" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> i </code> Option </span> </a> for an example. </p> <span class="leafygreen-ui-1qnjd6d" id="std-label-regexFind-captures-behavior"> </span> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> <code class="leafygreen-ui-1l06pbn"> captures </code> Output Behavior <a class="headerlink leafygreen-ui-1kepx47" href="#captures-output-behavior" 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="captures-output-behavior"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> If your <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-regexFind-regex" target="_self"> <span> regex </span> </a> pattern contains capture groups and the pattern finds a match in the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-regexFind-input" target="_self"> <span> input </span> </a> , the <code class="leafygreen-ui-1l06pbn"> captures </code> array in the results corresponds to the groups captured by the matching string. Capture groups are specified with unescaped parentheses <code class="leafygreen-ui-1l06pbn"> () </code> in the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-regexFind-regex" target="_self"> <span> regex </span> </a> pattern. The length of the <code class="leafygreen-ui-1l06pbn"> captures </code> array equals the number of capture groups in the pattern and the order of the array matches the order in which the capture groups appear. </p> <p class="leafygreen-ui-1kp3ins"> Create a sample collection named <code class="leafygreen-ui-1l06pbn"> contacts </code> with the following documents: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.contacts.insertMany([\n { \"_id\": 1, \"fname\": \"Carol\", \"lname\": \"Smith\", \"phone\": \"718-555-0113\" },\n { \"_id\": 2, \"fname\": \"Daryl\", \"lname\": \"Doe\", \"phone\": \"212-555-8832\" },\n { \"_id\": 3, \"fname\": \"Polly\", \"lname\": \"Andrews\", \"phone\": \"208-555-1932\" },\n { \"_id\": 4, \"fname\": \"Colleen\", \"lname\": \"Duncan\", \"phone\": \"775-555-0187\" },\n { \"_id\": 5, \"fname\": \"Luna\", \"lname\": \"Clarke\", \"phone\": \"917-555-4414\" }\n])","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><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">contacts</span>.<span class="lg-highlight-title lg-highlight-function">insertMany</span>(<!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"_id"</span>: <span class="lg-highlight-number">1</span>, <span class="lg-highlight-string">"fname"</span>: <span class="lg-highlight-string">"Carol"</span>, <span class="lg-highlight-string">"lname"</span>: <span class="lg-highlight-string">"Smith"</span>, <span class="lg-highlight-string">"phone"</span>: <span class="lg-highlight-string">"718-555-0113"</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"_id"</span>: <span class="lg-highlight-number">2</span>, <span class="lg-highlight-string">"fname"</span>: <span class="lg-highlight-string">"Daryl"</span>, <span class="lg-highlight-string">"lname"</span>: <span class="lg-highlight-string">"Doe"</span>, <span class="lg-highlight-string">"phone"</span>: <span class="lg-highlight-string">"212-555-8832"</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"_id"</span>: <span class="lg-highlight-number">3</span>, <span class="lg-highlight-string">"fname"</span>: <span class="lg-highlight-string">"Polly"</span>, <span class="lg-highlight-string">"lname"</span>: <span class="lg-highlight-string">"Andrews"</span>, <span class="lg-highlight-string">"phone"</span>: <span class="lg-highlight-string">"208-555-1932"</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"_id"</span>: <span class="lg-highlight-number">4</span>, <span class="lg-highlight-string">"fname"</span>: <span class="lg-highlight-string">"Colleen"</span>, <span class="lg-highlight-string">"lname"</span>: <span class="lg-highlight-string">"Duncan"</span>, <span class="lg-highlight-string">"phone"</span>: <span class="lg-highlight-string">"775-555-0187"</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"_id"</span>: <span class="lg-highlight-number">5</span>, <span class="lg-highlight-string">"fname"</span>: <span class="lg-highlight-string">"Luna"</span>, <span class="lg-highlight-string">"lname"</span>: <span class="lg-highlight-string">"Clarke"</span>, <span class="lg-highlight-string">"phone"</span>: <span class="lg-highlight-string">"917-555-4414"</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">])</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 pipeline applies the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-regexFind-regex" target="_self"> <span> regex </span> </a> pattern <code class="leafygreen-ui-1l06pbn"> /(C(ar)*)ol/ </code> to the <code class="leafygreen-ui-1l06pbn"> fname </code> field: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.contacts.aggregate([\n {\n $project: {\n returnObject: {\n $regexFind: { input: \"$fname\", regex: /(C(ar)*)ol/ }\n }\n }\n }\n])","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><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">contacts</span>.<span class="lg-highlight-title lg-highlight-function">aggregate</span>(<!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">$project</span>: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">returnObject</span>: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">$regexFind</span>: <!-- -->{ <span class="lg-highlight-attr">input</span>: <span class="lg-highlight-string">"$fname"</span>, <span class="lg-highlight-attr">regex</span>: <span class="lg-highlight-regexp">/(C(ar)*)ol/</span> <!-- -->}</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">])</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 <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-regexFind-regex" target="_self"> <span> regex </span> </a> pattern finds a match with <code class="leafygreen-ui-1l06pbn"> fname </code> values <code class="leafygreen-ui-1l06pbn"> Carol </code> and <code class="leafygreen-ui-1l06pbn"> Colleen </code> : </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ \"_id\" : 1, \"returnObject\" : { \"match\" : \"Carol\", \"idx\" : 0, \"captures\" : [ \"Car\", \"ar\" ] } }\n{ \"_id\" : 2, \"returnObject\" : null }\n{ \"_id\" : 3, \"returnObject\" : null }\n{ \"_id\" : 4, \"returnObject\" : { \"match\" : \"Col\", \"idx\" : 0, \"captures\" : [ \"C\", null ] } }\n{ \"_id\" : 5, \"returnObject\" : null }","programmingLanguage":"JavaScript"} </script> <div class="css-1lju8ps"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-tyg50d"> <pre class="leafygreen-ui-1453az5" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class="leafygreen-ui-1wr1lm6"><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">1</span>, <span class="lg-highlight-string">"returnObject"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-string">"match"</span> <!-- -->: <span class="lg-highlight-string">"Carol"</span>, <span class="lg-highlight-string">"idx"</span> <!-- -->: <span class="lg-highlight-number">0</span>, <span class="lg-highlight-string">"captures"</span> <!-- -->: <!-- -->[ <span class="lg-highlight-string">"Car"</span>, <span class="lg-highlight-string">"ar"</span> ] } }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">2</span>, <span class="lg-highlight-string">"returnObject"</span> <!-- -->: <span class="lg-highlight-literal">null</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">3</span>, <span class="lg-highlight-string">"returnObject"</span> <!-- -->: <span class="lg-highlight-literal">null</span> }</td></tr><tr class="leafygreen-ui-1wr1lm6"><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">4</span>, <span class="lg-highlight-string">"returnObject"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-string">"match"</span> <!-- -->: <span class="lg-highlight-string">"Col"</span>, <span class="lg-highlight-string">"idx"</span> <!-- -->: <span class="lg-highlight-number">0</span>, <span class="lg-highlight-string">"captures"</span> <!-- -->: <!-- -->[ <span class="lg-highlight-string">"C"</span>, <span class="lg-highlight-literal">null</span> ] } }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">5</span>, <span class="lg-highlight-string">"returnObject"</span> <!-- -->: <span class="lg-highlight-literal">null</span> }</td></tr></tbody></table></code></pre> </div> </div> </div> <p class="leafygreen-ui-1kp3ins"> The pattern contains the capture group <code class="leafygreen-ui-1l06pbn"> (C(ar)*) </code> which contains the nested group <code class="leafygreen-ui-1l06pbn"> (ar) </code> . The elements in the <code class="leafygreen-ui-1l06pbn"> captures </code> array correspond to the two capture groups. If a matching document is not captured by a group (e.g. <code class="leafygreen-ui-1l06pbn"> Colleen </code> and the group <code class="leafygreen-ui-1l06pbn"> (ar) </code> ), <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-expression-exp.-regexFind" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $regexFind </code> </span> </a> replaces the group with a null placeholder. </p> <p class="leafygreen-ui-1kp3ins"> As shown in the previous example, the <code class="leafygreen-ui-1l06pbn"> captures </code> array contains an element for each capture group (using <code class="leafygreen-ui-1l06pbn"> null </code> for non-captures). Consider the following example which searches for phone numbers with New York City area codes by applying a logical <code class="leafygreen-ui-1l06pbn"> or </code> of capture groups to the <code class="leafygreen-ui-1l06pbn"> phone </code> field. Each group represents a New York City area code: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.contacts.aggregate([\n {\n $project: {\n nycContacts: {\n $regexFind: { input: \"$phone\", regex: /^(718).*|^(212).*|^(917).*/ }\n }\n }\n }\n])","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><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">contacts</span>.<span class="lg-highlight-title lg-highlight-function">aggregate</span>(<!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">$project</span>: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">nycContacts</span>: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">$regexFind</span>: <!-- -->{ <span class="lg-highlight-attr">input</span>: <span class="lg-highlight-string">"$phone"</span>, <span class="lg-highlight-attr">regex</span>: <span class="lg-highlight-regexp">/^(718).*|^(212).*|^(917).*/</span> <!-- -->}</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">])</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"> For documents which are matched by the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-regexFind-regex" target="_self"> <span> regex </span> </a> pattern, the <code class="leafygreen-ui-1l06pbn"> captures </code> array includes the matching capture group and replaces any non-capturing groups with <code class="leafygreen-ui-1l06pbn"> null </code> : </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ \"_id\" : 1, \"nycContacts\" : { \"match\" : \"718-555-0113\", \"idx\" : 0, \"captures\" : [ \"718\", null, null ] } }\n{ \"_id\" : 2, \"nycContacts\" : { \"match\" : \"212-555-8832\", \"idx\" : 0, \"captures\" : [ null, \"212\", null ] } }\n{ \"_id\" : 3, \"nycContacts\" : null }\n{ \"_id\" : 4, \"nycContacts\" : null }\n{ \"_id\" : 5, \"nycContacts\" : { \"match\" : \"917-555-4414\", \"idx\" : 0, \"captures\" : [ null, null, \"917\" ] } }","programmingLanguage":"JavaScript"} </script> <div class="css-1lju8ps"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-tyg50d"> <pre class="leafygreen-ui-1453az5" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">1</span>, <span class="lg-highlight-string">"nycContacts"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-string">"match"</span> <!-- -->: <span class="lg-highlight-string">"718-555-0113"</span>, <span class="lg-highlight-string">"idx"</span> <!-- -->: <span class="lg-highlight-number">0</span>, <span class="lg-highlight-string">"captures"</span> <!-- -->: <!-- -->[ <span class="lg-highlight-string">"718"</span>, <span class="lg-highlight-literal">null</span>, <span class="lg-highlight-literal">null</span> ] } }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">2</span>, <span class="lg-highlight-string">"nycContacts"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-string">"match"</span> <!-- -->: <span class="lg-highlight-string">"212-555-8832"</span>, <span class="lg-highlight-string">"idx"</span> <!-- -->: <span class="lg-highlight-number">0</span>, <span class="lg-highlight-string">"captures"</span> <!-- -->: <!-- -->[ <span class="lg-highlight-literal">null</span>, <span class="lg-highlight-string">"212"</span>, <span class="lg-highlight-literal">null</span> ] } }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">3</span>, <span class="lg-highlight-string">"nycContacts"</span> <!-- -->: <span class="lg-highlight-literal">null</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">4</span>, <span class="lg-highlight-string">"nycContacts"</span> <!-- -->: <span class="lg-highlight-literal">null</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">5</span>, <span class="lg-highlight-string">"nycContacts"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-string">"match"</span> <!-- -->: <span class="lg-highlight-string">"917-555-4414"</span>, <span class="lg-highlight-string">"idx"</span> <!-- -->: <span class="lg-highlight-number">0</span>, <span class="lg-highlight-string">"captures"</span> <!-- -->: <!-- -->[ <span class="lg-highlight-literal">null</span>, <span class="lg-highlight-literal">null</span>, <span class="lg-highlight-string">"917"</span> ] } }</td></tr></tbody></table></code></pre> </div> </div> </div> </section> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Examples <a class="headerlink leafygreen-ui-1kepx47" href="#examples" 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="examples"> </div> </a> </h2> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> <code class="leafygreen-ui-1l06pbn"> $regexFind </code> and Its Options <a class="headerlink leafygreen-ui-1kepx47" href="#-regexfind-and-its-options" 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="-regexfind-and-its-options"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> To illustrate the behavior of the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-expression-exp.-regexFind" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $regexFind </code> </span> </a> operator as discussed in this example, create a sample collection <code class="leafygreen-ui-1l06pbn"> products </code> with the following documents: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.products.insertMany([\n { _id: 1, description: \"Single LINE description.\" },\n { _id: 2, description: \"First lines\\nsecond line\" },\n { _id: 3, description: \"Many spaces before line\" },\n { _id: 4, description: \"Multiple\\nline descriptions\" },\n { _id: 5, description: \"anchors, links and hyperlinks\" },\n { _id: 6, description: \"métier work vocation\" }\n])","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><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">products</span>.<span class="lg-highlight-title lg-highlight-function">insertMany</span>(<!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">1</span>, <span class="lg-highlight-attr">description</span>: <span class="lg-highlight-string">"Single LINE description."</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">2</span>, <span class="lg-highlight-attr">description</span>: <span class="lg-highlight-string">"First lines</span><span class="lg-highlight-string">\n</span><span class="lg-highlight-string">second line"</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">3</span>, <span class="lg-highlight-attr">description</span>: <span class="lg-highlight-string">"Many spaces before line"</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">4</span>, <span class="lg-highlight-attr">description</span>: <span class="lg-highlight-string">"Multiple</span><span class="lg-highlight-string">\n</span><span class="lg-highlight-string">line descriptions"</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">5</span>, <span class="lg-highlight-attr">description</span>: <span class="lg-highlight-string">"anchors, links and hyperlinks"</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">6</span>, <span class="lg-highlight-attr">description</span>: <span class="lg-highlight-string">"métier work vocation"</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">])</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"> By default, <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-expression-exp.-regexFind" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $regexFind </code> </span> </a> performs a case-sensitive match. For example, the following aggregation performs a case- <em> sensitive </em> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-expression-exp.-regexFind" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $regexFind </code> </span> </a> on the <code class="leafygreen-ui-1l06pbn"> description </code> field. The regex pattern <code class="leafygreen-ui-1l06pbn"> /line/ </code> does not specify any grouping: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.products.aggregate([\n { $addFields: { returnObject: { $regexFind: { input: \"$description\", regex: /line/ } } } }\n])","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><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">products</span>.<span class="lg-highlight-title lg-highlight-function">aggregate</span>(<!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">$addFields</span>: <!-- -->{ <span class="lg-highlight-attr">returnObject</span>: <!-- -->{ <span class="lg-highlight-attr">$regexFind</span>: <!-- -->{ <span class="lg-highlight-attr">input</span>: <span class="lg-highlight-string">"$description"</span>, <span class="lg-highlight-attr">regex</span>: <span class="lg-highlight-regexp">/line/</span> <!-- -->} } } }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">])</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 operation returns the following: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ \"_id\" : 1, \"description\" : \"Single LINE description.\", \"returnObject\" : null }\n{ \"_id\" : 2, \"description\" : \"First lines\\nsecond line\", \"returnObject\" : { \"match\" : \"line\", \"idx\" : 6, \"captures\" : [ ] } }\n{ \"_id\" : 3, \"description\" : \"Many spaces before line\", \"returnObject\" : { \"match\" : \"line\", \"idx\" : 23, \"captures\" : [ ] } }\n{ \"_id\" : 4, \"description\" : \"Multiple\\nline descriptions\", \"returnObject\" : { \"match\" : \"line\", \"idx\" : 9, \"captures\" : [ ] } }\n{ \"_id\" : 5, \"description\" : \"anchors, links and hyperlinks\", \"returnObject\" : null }\n{ \"_id\" : 6, \"description\" : \"métier work vocation\", \"returnObject\" : null }","programmingLanguage":"JavaScript"} </script> <div class="css-1lju8ps"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-tyg50d"> <pre class="leafygreen-ui-1453az5" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">1</span>, <span class="lg-highlight-string">"description"</span> <!-- -->: <span class="lg-highlight-string">"Single LINE description."</span>, <span class="lg-highlight-string">"returnObject"</span> <!-- -->: <span class="lg-highlight-literal">null</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">2</span>, <span class="lg-highlight-string">"description"</span> <!-- -->: <span class="lg-highlight-string">"First lines</span><span class="lg-highlight-string">\n</span><span class="lg-highlight-string">second line"</span>, <span class="lg-highlight-string">"returnObject"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-string">"match"</span> <!-- -->: <span class="lg-highlight-string">"line"</span>, <span class="lg-highlight-string">"idx"</span> <!-- -->: <span class="lg-highlight-number">6</span>, <span class="lg-highlight-string">"captures"</span> <!-- -->: <!-- -->[ <!-- -->] } }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">3</span>, <span class="lg-highlight-string">"description"</span> <!-- -->: <span class="lg-highlight-string">"Many spaces before line"</span>, <span class="lg-highlight-string">"returnObject"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-string">"match"</span> <!-- -->: <span class="lg-highlight-string">"line"</span>, <span class="lg-highlight-string">"idx"</span> <!-- -->: <span class="lg-highlight-number">23</span>, <span class="lg-highlight-string">"captures"</span> <!-- -->: <!-- -->[ <!-- -->] } }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">4</span>, <span class="lg-highlight-string">"description"</span> <!-- -->: <span class="lg-highlight-string">"Multiple</span><span class="lg-highlight-string">\n</span><span class="lg-highlight-string">line descriptions"</span>, <span class="lg-highlight-string">"returnObject"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-string">"match"</span> <!-- -->: <span class="lg-highlight-string">"line"</span>, <span class="lg-highlight-string">"idx"</span> <!-- -->: <span class="lg-highlight-number">9</span>, <span class="lg-highlight-string">"captures"</span> <!-- -->: <!-- -->[ <!-- -->] } }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">5</span>, <span class="lg-highlight-string">"description"</span> <!-- -->: <span class="lg-highlight-string">"anchors, links and hyperlinks"</span>, <span class="lg-highlight-string">"returnObject"</span> <!-- -->: <span class="lg-highlight-literal">null</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">6</span>, <span class="lg-highlight-string">"description"</span> <!-- -->: <span class="lg-highlight-string">"métier work vocation"</span>, <span class="lg-highlight-string">"returnObject"</span> <!-- -->: <span class="lg-highlight-literal">null</span> }</td></tr></tbody></table></code></pre> </div> </div> </div> <p class="leafygreen-ui-1kp3ins"> The following regex pattern <code class="leafygreen-ui-1l06pbn"> /lin(e|k)/ </code> specifies a grouping <code class="leafygreen-ui-1l06pbn"> (e|k) </code> in the pattern: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.products.aggregate([\n { $addFields: { returnObject: { $regexFind: { input: \"$description\", regex: /lin(e|k)/ } } } }\n])","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><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">products</span>.<span class="lg-highlight-title lg-highlight-function">aggregate</span>(<!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">$addFields</span>: <!-- -->{ <span class="lg-highlight-attr">returnObject</span>: <!-- -->{ <span class="lg-highlight-attr">$regexFind</span>: <!-- -->{ <span class="lg-highlight-attr">input</span>: <span class="lg-highlight-string">"$description"</span>, <span class="lg-highlight-attr">regex</span>: <span class="lg-highlight-regexp">/lin(e|k)/</span> <!-- -->} } } }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">])</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 operation returns the following: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ \"_id\" : 1, \"description\" : \"Single LINE description.\", \"returnObject\" : null }\n{ \"_id\" : 2, \"description\" : \"First lines\\nsecond line\", \"returnObject\" : { \"match\" : \"line\", \"idx\" : 6, \"captures\" : [ \"e\" ] } }\n{ \"_id\" : 3, \"description\" : \"Many spaces before line\", \"returnObject\" : { \"match\" : \"line\", \"idx\" : 23, \"captures\" : [ \"e\" ] } }\n{ \"_id\" : 4, \"description\" : \"Multiple\\nline descriptions\", \"returnObject\" : { \"match\" : \"line\", \"idx\" : 9, \"captures\" : [ \"e\" ] } }\n{ \"_id\" : 5, \"description\" : \"anchors, links and hyperlinks\", \"returnObject\" : { \"match\" : \"link\", \"idx\" : 9, \"captures\" : [ \"k\" ] } }\n{ \"_id\" : 6, \"description\" : \"métier work vocation\", \"returnObject\" : null }","programmingLanguage":"JavaScript"} </script> <div class="css-1lju8ps"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-tyg50d"> <pre class="leafygreen-ui-1453az5" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">1</span>, <span class="lg-highlight-string">"description"</span> <!-- -->: <span class="lg-highlight-string">"Single LINE description."</span>, <span class="lg-highlight-string">"returnObject"</span> <!-- -->: <span class="lg-highlight-literal">null</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">2</span>, <span class="lg-highlight-string">"description"</span> <!-- -->: <span class="lg-highlight-string">"First lines</span><span class="lg-highlight-string">\n</span><span class="lg-highlight-string">second line"</span>, <span class="lg-highlight-string">"returnObject"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-string">"match"</span> <!-- -->: <span class="lg-highlight-string">"line"</span>, <span class="lg-highlight-string">"idx"</span> <!-- -->: <span class="lg-highlight-number">6</span>, <span class="lg-highlight-string">"captures"</span> <!-- -->: <!-- -->[ <span class="lg-highlight-string">"e"</span> ] } }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">3</span>, <span class="lg-highlight-string">"description"</span> <!-- -->: <span class="lg-highlight-string">"Many spaces before line"</span>, <span class="lg-highlight-string">"returnObject"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-string">"match"</span> <!-- -->: <span class="lg-highlight-string">"line"</span>, <span class="lg-highlight-string">"idx"</span> <!-- -->: <span class="lg-highlight-number">23</span>, <span class="lg-highlight-string">"captures"</span> <!-- -->: <!-- -->[ <span class="lg-highlight-string">"e"</span> ] } }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">4</span>, <span class="lg-highlight-string">"description"</span> <!-- -->: <span class="lg-highlight-string">"Multiple</span><span class="lg-highlight-string">\n</span><span class="lg-highlight-string">line descriptions"</span>, <span class="lg-highlight-string">"returnObject"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-string">"match"</span> <!-- -->: <span class="lg-highlight-string">"line"</span>, <span class="lg-highlight-string">"idx"</span> <!-- -->: <span class="lg-highlight-number">9</span>, <span class="lg-highlight-string">"captures"</span> <!-- -->: <!-- -->[ <span class="lg-highlight-string">"e"</span> ] } }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">5</span>, <span class="lg-highlight-string">"description"</span> <!-- -->: <span class="lg-highlight-string">"anchors, links and hyperlinks"</span>, <span class="lg-highlight-string">"returnObject"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-string">"match"</span> <!-- -->: <span class="lg-highlight-string">"link"</span>, <span class="lg-highlight-string">"idx"</span> <!-- -->: <span class="lg-highlight-number">9</span>, <span class="lg-highlight-string">"captures"</span> <!-- -->: <!-- -->[ <span class="lg-highlight-string">"k"</span> ] } }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">6</span>, <span class="lg-highlight-string">"description"</span> <!-- -->: <span class="lg-highlight-string">"métier work vocation"</span>, <span class="lg-highlight-string">"returnObject"</span> <!-- -->: <span class="lg-highlight-literal">null</span> }</td></tr></tbody></table></code></pre> </div> </div> </div> <p class="leafygreen-ui-1kp3ins"> In the return option, the <code class="leafygreen-ui-1l06pbn"> idx </code> field is the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="http://www.unicode.org/glossary/#code_point" rel="noopener noreferrer"> <span> code point </span> <svg alt="" aria-hidden="true" class="leafygreen-ui-1ie5kuq" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M13.823 2.4491C13.8201 2.30008 13.6999 2.17994 13.5509 2.17704L9.5062 2.09836C9.25654 2.09351 9.12821 2.39519 9.30482 2.5718L10.3856 3.65257L7.93433 6.10383C7.87964 6.15852 7.83047 6.21665 7.78683 6.27752L5.99909 8.06525C5.46457 8.59977 5.46457 9.4664 5.99909 10.0009C6.53361 10.5354 7.40023 10.5354 7.93475 10.0009L9.72249 8.21317C9.78336 8.16953 9.84148 8.12037 9.89618 8.06567L12.3474 5.61441L13.4282 6.69518C13.6048 6.87179 13.9065 6.74347 13.9016 6.4938L13.823 2.4491Z" fill="currentColor"> </path> <path d="M7.25 3.12893C7.66421 3.12893 8 3.46472 8 3.87893C8 4.29315 7.66421 4.62893 7.25 4.62893H4C3.72386 4.62893 3.5 4.85279 3.5 5.12893V11.9929C3.5 12.2691 3.72386 12.4929 4 12.4929H10.864C11.1401 12.4929 11.364 12.2691 11.364 11.9929V8.75C11.364 8.33579 11.6998 8 12.114 8C12.5282 8 12.864 8.33579 12.864 8.75V11.9929C12.864 13.0975 11.9686 13.9929 10.864 13.9929H4C2.89543 13.9929 2 13.0975 2 11.9929V5.12893C2 4.02436 2.89543 3.12893 4 3.12893H7.25Z" fill="currentColor"> </path> </svg> </a> index and not the byte index. To illustrate, consider the following example that uses the regex pattern <code class="leafygreen-ui-1l06pbn"> /tier/ </code> : </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.products.aggregate([\n { $addFields: { returnObject: { $regexFind: { input: \"$description\", regex: /tier/ } } } }\n])","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><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">products</span>.<span class="lg-highlight-title lg-highlight-function">aggregate</span>(<!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">$addFields</span>: <!-- -->{ <span class="lg-highlight-attr">returnObject</span>: <!-- -->{ <span class="lg-highlight-attr">$regexFind</span>: <!-- -->{ <span class="lg-highlight-attr">input</span>: <span class="lg-highlight-string">"$description"</span>, <span class="lg-highlight-attr">regex</span>: <span class="lg-highlight-regexp">/tier/</span> <!-- -->} } } }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">])</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 operation returns the following where only the last record matches the pattern and the returned <code class="leafygreen-ui-1l06pbn"> idx </code> is <code class="leafygreen-ui-1l06pbn"> 2 </code> (instead of 3 if using a byte index) </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ \"_id\" : 1, \"description\" : \"Single LINE description.\", \"returnObject\" : null }\n{ \"_id\" : 2, \"description\" : \"First lines\\nsecond line\", \"returnObject\" : null }\n{ \"_id\" : 3, \"description\" : \"Many spaces before line\", \"returnObject\" : null }\n{ \"_id\" : 4, \"description\" : \"Multiple\\nline descriptions\", \"returnObject\" : null }\n{ \"_id\" : 5, \"description\" : \"anchors, links and hyperlinks\", \"returnObject\" : null }\n{ \"_id\" : 6, \"description\" : \"métier work vocation\",\n \"returnObject\" : { \"match\" : \"tier\", \"idx\" : 2, \"captures\" : [ ] } }","programmingLanguage":"JavaScript"} </script> <div class="css-1lju8ps"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-tyg50d"> <pre class="leafygreen-ui-1453az5" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">1</span>, <span class="lg-highlight-string">"description"</span> <!-- -->: <span class="lg-highlight-string">"Single LINE description."</span>, <span class="lg-highlight-string">"returnObject"</span> <!-- -->: <span class="lg-highlight-literal">null</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">2</span>, <span class="lg-highlight-string">"description"</span> <!-- -->: <span class="lg-highlight-string">"First lines</span><span class="lg-highlight-string">\n</span><span class="lg-highlight-string">second line"</span>, <span class="lg-highlight-string">"returnObject"</span> <!-- -->: <span class="lg-highlight-literal">null</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">3</span>, <span class="lg-highlight-string">"description"</span> <!-- -->: <span class="lg-highlight-string">"Many spaces before line"</span>, <span class="lg-highlight-string">"returnObject"</span> <!-- -->: <span class="lg-highlight-literal">null</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">4</span>, <span class="lg-highlight-string">"description"</span> <!-- -->: <span class="lg-highlight-string">"Multiple</span><span class="lg-highlight-string">\n</span><span class="lg-highlight-string">line descriptions"</span>, <span class="lg-highlight-string">"returnObject"</span> <!-- -->: <span class="lg-highlight-literal">null</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">5</span>, <span class="lg-highlight-string">"description"</span> <!-- -->: <span class="lg-highlight-string">"anchors, links and hyperlinks"</span>, <span class="lg-highlight-string">"returnObject"</span> <!-- -->: <span class="lg-highlight-literal">null</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">6</span>, <span class="lg-highlight-string">"description"</span> <!-- -->: <span class="lg-highlight-string">"métier work vocation"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"returnObject"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-string">"match"</span> <!-- -->: <span class="lg-highlight-string">"tier"</span>, <span class="lg-highlight-string">"idx"</span> <!-- -->: <span class="lg-highlight-number">2</span>, <span class="lg-highlight-string">"captures"</span> <!-- -->: <!-- -->[ <!-- -->] } }</td></tr></tbody></table></code></pre> </div> </div> </div> <span class="leafygreen-ui-1qnjd6d" id="std-label-regexFind-example-i-options"> </span> <section> <h4 class="contains-headerlink leafygreen-ui-1vzlt5f"> <code class="leafygreen-ui-1l06pbn"> i </code> Option <a class="headerlink leafygreen-ui-1kepx47" href="#i-option" 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="i-option"> </div> </a> </h4> <div class="leafygreen-ui-15mdk4" role="note"> <h2 class="leafygreen-ui-6n7b7d"> Note </h2> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> You cannot specify options in both the <code class="leafygreen-ui-1l06pbn"> regex </code> and the <code class="leafygreen-ui-1l06pbn"> options </code> field. </p> </div> </div> <p class="leafygreen-ui-1kp3ins"> To perform case- <em> insensitive </em> pattern matching, include the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-regexFind-options" target="_self"> <span> i </span> </a> option as part of the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-regexFind-regex" target="_self"> <span> regex </span> </a> field or in the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-regexFind-options" target="_self"> <span> options </span> </a> field: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"// Specify i as part of the regex field\n{ $regexFind: { input: \"$description\", regex: /line/i } }\n\n// Specify i in the options field\n{ $regexFind: { input: \"$description\", regex: /line/, options: \"i\" } }\n{ $regexFind: { input: \"$description\", regex: \"line\", options: \"i\" } }"} </script> <div class="css-1lju8ps"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-tyg50d"> <pre class="leafygreen-ui-1453az5" tabindex="0"><code class="lg-highlight-hljs-light none leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">// Specify i as part of the regex field</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ $regexFind: { input: "$description", regex: /line/i } }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><div class="leafygreen-ui-ihxujy"></div></td></tr><tr class=""><td class="leafygreen-ui-7razhx">// Specify i in the options field</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ $regexFind: { input: "$description", regex: /line/, options: "i" } }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ $regexFind: { input: "$description", regex: "line", options: "i" } }</td></tr></tbody></table></code></pre> </div> </div> </div> <p class="leafygreen-ui-1kp3ins"> For example, the following aggregation performs a case- <em> insensitive </em> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-expression-exp.-regexFind" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $regexFind </code> </span> </a> on the <code class="leafygreen-ui-1l06pbn"> description </code> field. The regex pattern <code class="leafygreen-ui-1l06pbn"> /line/ </code> does not specify any grouping: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.products.aggregate([\n { $addFields: { returnObject: { $regexFind: { input: \"$description\", regex: /line/i } } } }\n])","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><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">products</span>.<span class="lg-highlight-title lg-highlight-function">aggregate</span>(<!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">$addFields</span>: <!-- -->{ <span class="lg-highlight-attr">returnObject</span>: <!-- -->{ <span class="lg-highlight-attr">$regexFind</span>: <!-- -->{ <span class="lg-highlight-attr">input</span>: <span class="lg-highlight-string">"$description"</span>, <span class="lg-highlight-attr">regex</span>: <span class="lg-highlight-regexp">/line/i</span> <!-- -->} } } }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">])</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 operation returns the following documents: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ \"_id\" : 1, \"description\" : \"Single LINE description.\", \"returnObject\" : { \"match\" : \"LINE\", \"idx\" : 7, \"captures\" : [ ] } }\n{ \"_id\" : 2, \"description\" : \"First lines\\nsecond line\", \"returnObject\" : { \"match\" : \"line\", \"idx\" : 6, \"captures\" : [ ] } }\n{ \"_id\" : 3, \"description\" : \"Many spaces before line\", \"returnObject\" : { \"match\" : \"line\", \"idx\" : 23, \"captures\" : [ ] } }\n{ \"_id\" : 4, \"description\" : \"Multiple\\nline descriptions\", \"returnObject\" : { \"match\" : \"line\", \"idx\" : 9, \"captures\" : [ ] } }\n{ \"_id\" : 5, \"description\" : \"anchors, links and hyperlinks\", \"returnObject\" : null }\n{ \"_id\" : 6, \"description\" : \"métier work vocation\", \"returnObject\" : null }","programmingLanguage":"JavaScript"} </script> <div class="css-1lju8ps"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-tyg50d"> <pre class="leafygreen-ui-1453az5" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">1</span>, <span class="lg-highlight-string">"description"</span> <!-- -->: <span class="lg-highlight-string">"Single LINE description."</span>, <span class="lg-highlight-string">"returnObject"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-string">"match"</span> <!-- -->: <span class="lg-highlight-string">"LINE"</span>, <span class="lg-highlight-string">"idx"</span> <!-- -->: <span class="lg-highlight-number">7</span>, <span class="lg-highlight-string">"captures"</span> <!-- -->: <!-- -->[ <!-- -->] } }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">2</span>, <span class="lg-highlight-string">"description"</span> <!-- -->: <span class="lg-highlight-string">"First lines</span><span class="lg-highlight-string">\n</span><span class="lg-highlight-string">second line"</span>, <span class="lg-highlight-string">"returnObject"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-string">"match"</span> <!-- -->: <span class="lg-highlight-string">"line"</span>, <span class="lg-highlight-string">"idx"</span> <!-- -->: <span class="lg-highlight-number">6</span>, <span class="lg-highlight-string">"captures"</span> <!-- -->: <!-- -->[ <!-- -->] } }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">3</span>, <span class="lg-highlight-string">"description"</span> <!-- -->: <span class="lg-highlight-string">"Many spaces before line"</span>, <span class="lg-highlight-string">"returnObject"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-string">"match"</span> <!-- -->: <span class="lg-highlight-string">"line"</span>, <span class="lg-highlight-string">"idx"</span> <!-- -->: <span class="lg-highlight-number">23</span>, <span class="lg-highlight-string">"captures"</span> <!-- -->: <!-- -->[ <!-- -->] } }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">4</span>, <span class="lg-highlight-string">"description"</span> <!-- -->: <span class="lg-highlight-string">"Multiple</span><span class="lg-highlight-string">\n</span><span class="lg-highlight-string">line descriptions"</span>, <span class="lg-highlight-string">"returnObject"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-string">"match"</span> <!-- -->: <span class="lg-highlight-string">"line"</span>, <span class="lg-highlight-string">"idx"</span> <!-- -->: <span class="lg-highlight-number">9</span>, <span class="lg-highlight-string">"captures"</span> <!-- -->: <!-- -->[ <!-- -->] } }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">5</span>, <span class="lg-highlight-string">"description"</span> <!-- -->: <span class="lg-highlight-string">"anchors, links and hyperlinks"</span>, <span class="lg-highlight-string">"returnObject"</span> <!-- -->: <span class="lg-highlight-literal">null</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">6</span>, <span class="lg-highlight-string">"description"</span> <!-- -->: <span class="lg-highlight-string">"métier work vocation"</span>, <span class="lg-highlight-string">"returnObject"</span> <!-- -->: <span class="lg-highlight-literal">null</span> }</td></tr></tbody></table></code></pre> </div> </div> </div> </section> <section> <h4 class="contains-headerlink leafygreen-ui-1vzlt5f"> <code class="leafygreen-ui-1l06pbn"> m </code> Option <a class="headerlink leafygreen-ui-1kepx47" href="#m-option" 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="m-option"> </div> </a> </h4> <div class="leafygreen-ui-15mdk4" role="note"> <h2 class="leafygreen-ui-6n7b7d"> Note </h2> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> You cannot specify options in both the <code class="leafygreen-ui-1l06pbn"> regex </code> and the <code class="leafygreen-ui-1l06pbn"> options </code> field. </p> </div> </div> <p class="leafygreen-ui-1kp3ins"> To match the specified anchors (e.g. <code class="leafygreen-ui-1l06pbn"> ^ </code> , <code class="leafygreen-ui-1l06pbn"> $ </code> ) for each line of a multiline string, include the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-regexFind-options" target="_self"> <span> m </span> </a> option as part of the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-regexFind-regex" target="_self"> <span> regex </span> </a> field or in the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-regexFind-options" target="_self"> <span> options </span> </a> field: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"// Specify m as part of the regex field\n{ $regexFind: { input: \"$description\", regex: /line/m } }\n\n// Specify m in the options field\n{ $regexFind: { input: \"$description\", regex: /line/, options: \"m\" } }\n{ $regexFind: { input: \"$description\", regex: \"line\", options: \"m\" } }"} </script> <div class="css-1lju8ps"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-tyg50d"> <pre class="leafygreen-ui-1453az5" tabindex="0"><code class="lg-highlight-hljs-light none leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">// Specify m as part of the regex field</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ $regexFind: { input: "$description", regex: /line/m } }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><div class="leafygreen-ui-ihxujy"></div></td></tr><tr class=""><td class="leafygreen-ui-7razhx">// Specify m in the options field</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ $regexFind: { input: "$description", regex: /line/, options: "m" } }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ $regexFind: { input: "$description", regex: "line", options: "m" } }</td></tr></tbody></table></code></pre> </div> </div> </div> <p class="leafygreen-ui-1kp3ins"> The following example includes both the <code class="leafygreen-ui-1l06pbn"> i </code> and the <code class="leafygreen-ui-1l06pbn"> m </code> options to match lines starting with either the letter <code class="leafygreen-ui-1l06pbn"> s </code> or <code class="leafygreen-ui-1l06pbn"> S </code> for multiline strings: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.products.aggregate([\n { $addFields: { returnObject: { $regexFind: { input: \"$description\", regex: /^s/im } } } }\n])","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><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">products</span>.<span class="lg-highlight-title lg-highlight-function">aggregate</span>(<!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">$addFields</span>: <!-- -->{ <span class="lg-highlight-attr">returnObject</span>: <!-- -->{ <span class="lg-highlight-attr">$regexFind</span>: <!-- -->{ <span class="lg-highlight-attr">input</span>: <span class="lg-highlight-string">"$description"</span>, <span class="lg-highlight-attr">regex</span>: <span class="lg-highlight-regexp">/^s/im</span> <!-- -->} } } }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">])</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 operation returns the following: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ \"_id\" : 1, \"description\" : \"Single LINE description.\", \"returnObject\" : { \"match\" : \"S\", \"idx\" : 0, \"captures\" : [ ] } }\n{ \"_id\" : 2, \"description\" : \"First lines\\nsecond line\", \"returnObject\" : { \"match\" : \"s\", \"idx\" : 12, \"captures\" : [ ] } }\n{ \"_id\" : 3, \"description\" : \"Many spaces before line\", \"returnObject\" : null }\n{ \"_id\" : 4, \"description\" : \"Multiple\\nline descriptions\", \"returnObject\" : null }\n{ \"_id\" : 5, \"description\" : \"anchors, links and hyperlinks\", \"returnObject\" : null }\n{ \"_id\" : 6, \"description\" : \"métier work vocation\", \"returnObject\" : null }","programmingLanguage":"JavaScript"} </script> <div class="css-1lju8ps"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-tyg50d"> <pre class="leafygreen-ui-1453az5" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">1</span>, <span class="lg-highlight-string">"description"</span> <!-- -->: <span class="lg-highlight-string">"Single LINE description."</span>, <span class="lg-highlight-string">"returnObject"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-string">"match"</span> <!-- -->: <span class="lg-highlight-string">"S"</span>, <span class="lg-highlight-string">"idx"</span> <!-- -->: <span class="lg-highlight-number">0</span>, <span class="lg-highlight-string">"captures"</span> <!-- -->: <!-- -->[ <!-- -->] } }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">2</span>, <span class="lg-highlight-string">"description"</span> <!-- -->: <span class="lg-highlight-string">"First lines</span><span class="lg-highlight-string">\n</span><span class="lg-highlight-string">second line"</span>, <span class="lg-highlight-string">"returnObject"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-string">"match"</span> <!-- -->: <span class="lg-highlight-string">"s"</span>, <span class="lg-highlight-string">"idx"</span> <!-- -->: <span class="lg-highlight-number">12</span>, <span class="lg-highlight-string">"captures"</span> <!-- -->: <!-- -->[ <!-- -->] } }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">3</span>, <span class="lg-highlight-string">"description"</span> <!-- -->: <span class="lg-highlight-string">"Many spaces before line"</span>, <span class="lg-highlight-string">"returnObject"</span> <!-- -->: <span class="lg-highlight-literal">null</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">4</span>, <span class="lg-highlight-string">"description"</span> <!-- -->: <span class="lg-highlight-string">"Multiple</span><span class="lg-highlight-string">\n</span><span class="lg-highlight-string">line descriptions"</span>, <span class="lg-highlight-string">"returnObject"</span> <!-- -->: <span class="lg-highlight-literal">null</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">5</span>, <span class="lg-highlight-string">"description"</span> <!-- -->: <span class="lg-highlight-string">"anchors, links and hyperlinks"</span>, <span class="lg-highlight-string">"returnObject"</span> <!-- -->: <span class="lg-highlight-literal">null</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">6</span>, <span class="lg-highlight-string">"description"</span> <!-- -->: <span class="lg-highlight-string">"métier work vocation"</span>, <span class="lg-highlight-string">"returnObject"</span> <!-- -->: <span class="lg-highlight-literal">null</span> }</td></tr></tbody></table></code></pre> </div> </div> </div> </section> <section> <h4 class="contains-headerlink leafygreen-ui-1vzlt5f"> <code class="leafygreen-ui-1l06pbn"> x </code> Option <a class="headerlink leafygreen-ui-1kepx47" href="#x-option" 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="x-option"> </div> </a> </h4> <div class="leafygreen-ui-15mdk4" role="note"> <h2 class="leafygreen-ui-6n7b7d"> Note </h2> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> You cannot specify options in both the <code class="leafygreen-ui-1l06pbn"> regex </code> and the <code class="leafygreen-ui-1l06pbn"> options </code> field. </p> </div> </div> <p class="leafygreen-ui-1kp3ins"> To ignore all unescaped white space characters and comments (denoted by the un-escaped hash <code class="leafygreen-ui-1l06pbn"> # </code> character and the next new-line character) in the pattern, include the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-regexFind-options" target="_self"> <span> s </span> </a> option in the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-regexFind-options" target="_self"> <span> options </span> </a> field: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"// Specify x in the options field\n{ $regexFind: { input: \"$description\", regex: /line/, options: \"x\" } }\n{ $regexFind: { input: \"$description\", regex: \"line\", options: \"x\" } }"} </script> <div class="css-1lju8ps"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-tyg50d"> <pre class="leafygreen-ui-1453az5" tabindex="0"><code class="lg-highlight-hljs-light none leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">// Specify x in the options field</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ $regexFind: { input: "$description", regex: /line/, options: "x" } }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ $regexFind: { input: "$description", regex: "line", options: "x" } }</td></tr></tbody></table></code></pre> </div> </div> </div> <p class="leafygreen-ui-1kp3ins"> The following example includes the <code class="leafygreen-ui-1l06pbn"> x </code> option to skip unescaped white spaces and comments: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.products.aggregate([\n { $addFields: { returnObject: { $regexFind: { input: \"$description\", regex: /lin(e|k) # matches line or link/, options:\"x\" } } } }\n])","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><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">products</span>.<span class="lg-highlight-title lg-highlight-function">aggregate</span>(<!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">$addFields</span>: <!-- -->{ <span class="lg-highlight-attr">returnObject</span>: <!-- -->{ <span class="lg-highlight-attr">$regexFind</span>: <!-- -->{ <span class="lg-highlight-attr">input</span>: <span class="lg-highlight-string">"$description"</span>, <span class="lg-highlight-attr">regex</span>: <span class="lg-highlight-regexp">/lin(e|k) # matches line or link/</span>,<!-- --> <span class="lg-highlight-attr">options</span>:<span class="lg-highlight-string">"x"</span> } } } }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">])</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 operation returns the following: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ \"_id\" : 1, \"description\" : \"Single LINE description.\", \"returnObject\" : null }\n{ \"_id\" : 2, \"description\" : \"First lines\\nsecond line\", \"returnObject\" : { \"match\" : \"line\", \"idx\" : 6, \"captures\" : [ \"e\" ] } }\n{ \"_id\" : 3, \"description\" : \"Many spaces before line\", \"returnObject\" : { \"match\" : \"line\", \"idx\" : 23, \"captures\" : [ \"e\" ] } }\n{ \"_id\" : 4, \"description\" : \"Multiple\\nline descriptions\", \"returnObject\" : { \"match\" : \"line\", \"idx\" : 9, \"captures\" : [ \"e\" ] } }\n{ \"_id\" : 5, \"description\" : \"anchors, links and hyperlinks\", \"returnObject\" : { \"match\" : \"link\", \"idx\" : 9, \"captures\" : [ \"k\" ] } }\n{ \"_id\" : 6, \"description\" : \"métier work vocation\", \"returnObject\" : null }","programmingLanguage":"JavaScript"} </script> <div class="css-1lju8ps"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-tyg50d"> <pre class="leafygreen-ui-1453az5" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">1</span>, <span class="lg-highlight-string">"description"</span> <!-- -->: <span class="lg-highlight-string">"Single LINE description."</span>, <span class="lg-highlight-string">"returnObject"</span> <!-- -->: <span class="lg-highlight-literal">null</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">2</span>, <span class="lg-highlight-string">"description"</span> <!-- -->: <span class="lg-highlight-string">"First lines</span><span class="lg-highlight-string">\n</span><span class="lg-highlight-string">second line"</span>, <span class="lg-highlight-string">"returnObject"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-string">"match"</span> <!-- -->: <span class="lg-highlight-string">"line"</span>, <span class="lg-highlight-string">"idx"</span> <!-- -->: <span class="lg-highlight-number">6</span>, <span class="lg-highlight-string">"captures"</span> <!-- -->: <!-- -->[ <span class="lg-highlight-string">"e"</span> ] } }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">3</span>, <span class="lg-highlight-string">"description"</span> <!-- -->: <span class="lg-highlight-string">"Many spaces before line"</span>, <span class="lg-highlight-string">"returnObject"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-string">"match"</span> <!-- -->: <span class="lg-highlight-string">"line"</span>, <span class="lg-highlight-string">"idx"</span> <!-- -->: <span class="lg-highlight-number">23</span>, <span class="lg-highlight-string">"captures"</span> <!-- -->: <!-- -->[ <span class="lg-highlight-string">"e"</span> ] } }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">4</span>, <span class="lg-highlight-string">"description"</span> <!-- -->: <span class="lg-highlight-string">"Multiple</span><span class="lg-highlight-string">\n</span><span class="lg-highlight-string">line descriptions"</span>, <span class="lg-highlight-string">"returnObject"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-string">"match"</span> <!-- -->: <span class="lg-highlight-string">"line"</span>, <span class="lg-highlight-string">"idx"</span> <!-- -->: <span class="lg-highlight-number">9</span>, <span class="lg-highlight-string">"captures"</span> <!-- -->: <!-- -->[ <span class="lg-highlight-string">"e"</span> ] } }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">5</span>, <span class="lg-highlight-string">"description"</span> <!-- -->: <span class="lg-highlight-string">"anchors, links and hyperlinks"</span>, <span class="lg-highlight-string">"returnObject"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-string">"match"</span> <!-- -->: <span class="lg-highlight-string">"link"</span>, <span class="lg-highlight-string">"idx"</span> <!-- -->: <span class="lg-highlight-number">9</span>, <span class="lg-highlight-string">"captures"</span> <!-- -->: <!-- -->[ <span class="lg-highlight-string">"k"</span> ] } }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">6</span>, <span class="lg-highlight-string">"description"</span> <!-- -->: <span class="lg-highlight-string">"métier work vocation"</span>, <span class="lg-highlight-string">"returnObject"</span> <!-- -->: <span class="lg-highlight-literal">null</span> }</td></tr></tbody></table></code></pre> </div> </div> </div> </section> <section> <h4 class="contains-headerlink leafygreen-ui-1vzlt5f"> <code class="leafygreen-ui-1l06pbn"> s </code> Option <a class="headerlink leafygreen-ui-1kepx47" href="#s-option" 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="s-option"> </div> </a> </h4> <div class="leafygreen-ui-15mdk4" role="note"> <h2 class="leafygreen-ui-6n7b7d"> Note </h2> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> You cannot specify options in both the <code class="leafygreen-ui-1l06pbn"> regex </code> and the <code class="leafygreen-ui-1l06pbn"> options </code> field. </p> </div> </div> <p class="leafygreen-ui-1kp3ins"> To allow the dot character (i.e. <code class="leafygreen-ui-1l06pbn"> . </code> ) in the pattern to match all characters including the new line character, include the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-regexFind-options" target="_self"> <span> s </span> </a> option in the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-regexFind-options" target="_self"> <span> options </span> </a> field: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"// Specify s in the options field\n{ $regexFind: { input: \"$description\", regex: /m.*line/, options: \"s\" } }\n{ $regexFind: { input: \"$description\", regex: \"m.*line\", options: \"s\" } }"} </script> <div class="css-1lju8ps"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-tyg50d"> <pre class="leafygreen-ui-1453az5" tabindex="0"><code class="lg-highlight-hljs-light none leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">// Specify s in the options field</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ $regexFind: { input: "$description", regex: /m.*line/, options: "s" } }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ $regexFind: { input: "$description", regex: "m.*line", options: "s" } }</td></tr></tbody></table></code></pre> </div> </div> </div> <p class="leafygreen-ui-1kp3ins"> The following example includes the <code class="leafygreen-ui-1l06pbn"> s </code> option to allow the dot character (i.e. .) to match all characters including new line as well as the <code class="leafygreen-ui-1l06pbn"> i </code> option to perform a case-insensitive match: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.products.aggregate([\n { $addFields: { returnObject: { $regexFind: { input: \"$description\", regex:/m.*line/, options: \"si\" } } } }\n])","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><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">products</span>.<span class="lg-highlight-title lg-highlight-function">aggregate</span>(<!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">$addFields</span>: <!-- -->{ <span class="lg-highlight-attr">returnObject</span>: <!-- -->{ <span class="lg-highlight-attr">$regexFind</span>: <!-- -->{ <span class="lg-highlight-attr">input</span>: <span class="lg-highlight-string">"$description"</span>, <span class="lg-highlight-attr">regex</span>:<span class="lg-highlight-regexp">/m.*line/</span>,<!-- --> <span class="lg-highlight-attr">options</span>: <span class="lg-highlight-string">"si"</span> } } } }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">])</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 operation returns the following: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ \"_id\" : 1, \"description\" : \"Single LINE description.\", \"returnObject\" : null }\n{ \"_id\" : 2, \"description\" : \"First lines\\nsecond line\", \"returnObject\" : null }\n{ \"_id\" : 3, \"description\" : \"Many spaces before line\", \"returnObject\" : { \"match\" : \"Many spaces before line\", \"idx\" : 0, \"captures\" : [ ] } }\n{ \"_id\" : 4, \"description\" : \"Multiple\\nline descriptions\", \"returnObject\" : { \"match\" : \"Multiple\\nline\", \"idx\" : 0, \"captures\" : [ ] } }\n{ \"_id\" : 5, \"description\" : \"anchors, links and hyperlinks\", \"returnObject\" : null }\n{ \"_id\" : 6, \"description\" : \"métier work vocation\", \"returnObject\" : null }","programmingLanguage":"JavaScript"} </script> <div class="css-1lju8ps"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-tyg50d"> <pre class="leafygreen-ui-1453az5" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">1</span>, <span class="lg-highlight-string">"description"</span> <!-- -->: <span class="lg-highlight-string">"Single LINE description."</span>, <span class="lg-highlight-string">"returnObject"</span> <!-- -->: <span class="lg-highlight-literal">null</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">2</span>, <span class="lg-highlight-string">"description"</span> <!-- -->: <span class="lg-highlight-string">"First lines</span><span class="lg-highlight-string">\n</span><span class="lg-highlight-string">second line"</span>, <span class="lg-highlight-string">"returnObject"</span> <!-- -->: <span class="lg-highlight-literal">null</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">3</span>, <span class="lg-highlight-string">"description"</span> <!-- -->: <span class="lg-highlight-string">"Many spaces before line"</span>, <span class="lg-highlight-string">"returnObject"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-string">"match"</span> <!-- -->: <span class="lg-highlight-string">"Many spaces before line"</span>, <span class="lg-highlight-string">"idx"</span> <!-- -->: <span class="lg-highlight-number">0</span>, <span class="lg-highlight-string">"captures"</span> <!-- -->: <!-- -->[ <!-- -->] } }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">4</span>, <span class="lg-highlight-string">"description"</span> <!-- -->: <span class="lg-highlight-string">"Multiple</span><span class="lg-highlight-string">\n</span><span class="lg-highlight-string">line descriptions"</span>, <span class="lg-highlight-string">"returnObject"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-string">"match"</span> <!-- -->: <span class="lg-highlight-string">"Multiple</span><span class="lg-highlight-string">\n</span><span class="lg-highlight-string">line"</span>, <span class="lg-highlight-string">"idx"</span> <!-- -->: <span class="lg-highlight-number">0</span>, <span class="lg-highlight-string">"captures"</span> <!-- -->: <!-- -->[ <!-- -->] } }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">5</span>, <span class="lg-highlight-string">"description"</span> <!-- -->: <span class="lg-highlight-string">"anchors, links and hyperlinks"</span>, <span class="lg-highlight-string">"returnObject"</span> <!-- -->: <span class="lg-highlight-literal">null</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">6</span>, <span class="lg-highlight-string">"description"</span> <!-- -->: <span class="lg-highlight-string">"métier work vocation"</span>, <span class="lg-highlight-string">"returnObject"</span> <!-- -->: <span class="lg-highlight-literal">null</span> }</td></tr></tbody></table></code></pre> </div> </div> </div> </section> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Use <code class="leafygreen-ui-1l06pbn"> $regexFind </code> to Parse Email from String <a class="headerlink leafygreen-ui-1kepx47" href="#use--regexfind-to-parse-email-from-string" 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="use--regexfind-to-parse-email-from-string"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> Create a sample collection <code class="leafygreen-ui-1l06pbn"> feedback </code> with the following documents: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.feedback.insertMany([\n { \"_id\" : 1, comment: \"Hi, I'm just reading about MongoDB -- [email protected]\" },\n { \"_id\" : 2, comment: \"I wanted to concatenate a string\" },\n { \"_id\" : 3, comment: \"How do I convert a date to string? [email protected]\" },\n { \"_id\" : 4, comment: \"It's just me. I'm testing. [email protected]\" }\n])","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><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">feedback</span>.<span class="lg-highlight-title lg-highlight-function">insertMany</span>(<!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">1</span>, <span class="lg-highlight-attr">comment</span>: <span class="lg-highlight-string">"Hi, I'm just reading about MongoDB -- [email protected]"</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">2</span>, <span class="lg-highlight-attr">comment</span>: <span class="lg-highlight-string">"I wanted to concatenate a string"</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">3</span>, <span class="lg-highlight-attr">comment</span>: <span class="lg-highlight-string">"How do I convert a date to string? [email protected]"</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">4</span>, <span class="lg-highlight-attr">comment</span>: <span class="lg-highlight-string">"It's just me. I'm testing. [email protected]"</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">])</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 aggregation uses the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-expression-exp.-regexFind" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $regexFind </code> </span> </a> to extract the email from the <code class="leafygreen-ui-1l06pbn"> comment </code> field (case insensitive). </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.feedback.aggregate( [\n { $addFields: {\n \"email\": { $regexFind: { input: \"$comment\", regex: /[a-z0-9_.+-]+@[a-z0-9_.+-]+\\.[a-z0-9_.+-]+/i } }\n } },\n { $set: { email: \"$email.match\"} }\n] )","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><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">feedback</span>.<span class="lg-highlight-title lg-highlight-function">aggregate</span>( <!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">$addFields</span>: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"email"</span>: <!-- -->{ <span class="lg-highlight-attr">$regexFind</span>: <!-- -->{ <span class="lg-highlight-attr">input</span>: <span class="lg-highlight-string">"$comment"</span>, <span class="lg-highlight-attr">regex</span>: <span class="lg-highlight-regexp">/</span><span class="lg-highlight-regexp">[a-z0-9_.+-]</span><span class="lg-highlight-regexp">+@</span><span class="lg-highlight-regexp">[a-z0-9_.+-]</span><span class="lg-highlight-regexp">+</span><span class="lg-highlight-regexp">\.</span><span class="lg-highlight-regexp">[a-z0-9_.+-]</span><span class="lg-highlight-regexp">+/i</span> <!-- -->} }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> } }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">$set</span>: <!-- -->{ <span class="lg-highlight-attr">email</span>: <span class="lg-highlight-string">"$email.match"</span>} }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">] )</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> <dl> <dt> First Stage </dt> <dd class="css-1ufxuu7"> <p class="leafygreen-ui-1kp3ins"> The stage uses the <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 to add a new field <code class="leafygreen-ui-1l06pbn"> email </code> to the document. The new field contains the result of performing the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-expression-exp.-regexFind" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $regexFind </code> </span> </a> on the <code class="leafygreen-ui-1l06pbn"> comment </code> field: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ \"_id\" : 1, \"comment\" : \"Hi, I'm just reading about MongoDB -- [email protected]\", \"email\" : { \"match\" : \"[email protected]\", \"idx\" : 38, \"captures\" : [ ] } }\n{ \"_id\" : 2, \"comment\" : \"I wanted to concatenate a string\", \"email\" : null }\n{ \"_id\" : 3, \"comment\" : \"I can't find how to convert a date to string. [email protected]\", \"email\" : { \"match\" : \"[email protected]\", \"idx\" : 46, \"captures\" : [ ] } }\n{ \"_id\" : 4, \"comment\" : \"It's just me. I'm testing. [email protected]\", \"email\" : { \"match\" : \"[email protected]\", \"idx\" : 28, \"captures\" : [ ] } }","programmingLanguage":"JavaScript"} </script> <div class="css-1lju8ps"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-tyg50d"> <pre class="leafygreen-ui-1453az5" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">1</span>, <span class="lg-highlight-string">"comment"</span> <!-- -->: <span class="lg-highlight-string">"Hi, I'm just reading about MongoDB -- [email protected]"</span>, <span class="lg-highlight-string">"email"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-string">"match"</span> <!-- -->: <span class="lg-highlight-string">"[email protected]"</span>, <span class="lg-highlight-string">"idx"</span> <!-- -->: <span class="lg-highlight-number">38</span>, <span class="lg-highlight-string">"captures"</span> <!-- -->: <!-- -->[ <!-- -->] } }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">2</span>, <span class="lg-highlight-string">"comment"</span> <!-- -->: <span class="lg-highlight-string">"I wanted to concatenate a string"</span>, <span class="lg-highlight-string">"email"</span> <!-- -->: <span class="lg-highlight-literal">null</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">3</span>, <span class="lg-highlight-string">"comment"</span> <!-- -->: <span class="lg-highlight-string">"I can't find how to convert a date to string. [email protected]"</span>, <span class="lg-highlight-string">"email"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-string">"match"</span> <!-- -->: <span class="lg-highlight-string">"[email protected]"</span>, <span class="lg-highlight-string">"idx"</span> <!-- -->: <span class="lg-highlight-number">46</span>, <span class="lg-highlight-string">"captures"</span> <!-- -->: <!-- -->[ <!-- -->] } }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">4</span>, <span class="lg-highlight-string">"comment"</span> <!-- -->: <span class="lg-highlight-string">"It's just me. I'm testing. [email protected]"</span>, <span class="lg-highlight-string">"email"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-string">"match"</span> <!-- -->: <span class="lg-highlight-string">"[email protected]"</span>, <span class="lg-highlight-string">"idx"</span> <!-- -->: <span class="lg-highlight-number">28</span>, <span class="lg-highlight-string">"captures"</span> <!-- -->: <!-- -->[ <!-- -->] } }</td></tr></tbody></table></code></pre> </div> </div> </div> </dd> <dt> Second Stage </dt> <dd class="css-1ufxuu7"> <p class="leafygreen-ui-1kp3ins"> The stage use the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/set/#mongodb-pipeline-pipe.-set"> <code class="leafygreen-ui-1l06pbn"> $set </code> </a> stage to reset the <code class="leafygreen-ui-1l06pbn"> email </code> to the current <code class="leafygreen-ui-1l06pbn"> "$email.match" </code> value. If the current value of <code class="leafygreen-ui-1l06pbn"> email </code> is null, the new value of <code class="leafygreen-ui-1l06pbn"> email </code> is set to null. </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ \"_id\" : 1, \"comment\" : \"Hi, I'm just reading about MongoDB -- [email protected]\", \"email\" : \"[email protected]\" }\n{ \"_id\" : 2, \"comment\" : \"I wanted to concatenate a string\" }\n{ \"_id\" : 3, \"comment\" : \"I can't find how to convert a date to string. [email protected]\", \"email\" : \"[email protected]\" }\n{ \"_id\" : 4, \"comment\" : \"It's just me. I'm testing. [email protected]\", \"email\" : \"[email protected]\" }","programmingLanguage":"JavaScript"} </script> <div class="css-1lju8ps"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-tyg50d"> <pre class="leafygreen-ui-1453az5" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">1</span>, <span class="lg-highlight-string">"comment"</span> <!-- -->: <span class="lg-highlight-string">"Hi, I'm just reading about MongoDB -- [email protected]"</span>, <span class="lg-highlight-string">"email"</span> <!-- -->: <span class="lg-highlight-string">"[email protected]"</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">2</span>, <span class="lg-highlight-string">"comment"</span> <!-- -->: <span class="lg-highlight-string">"I wanted to concatenate a string"</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">3</span>, <span class="lg-highlight-string">"comment"</span> <!-- -->: <span class="lg-highlight-string">"I can't find how to convert a date to string. [email protected]"</span>, <span class="lg-highlight-string">"email"</span> <!-- -->: <span class="lg-highlight-string">"[email protected]"</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">4</span>, <span class="lg-highlight-string">"comment"</span> <!-- -->: <span class="lg-highlight-string">"It's just me. I'm testing. [email protected]"</span>, <span class="lg-highlight-string">"email"</span> <!-- -->: <span class="lg-highlight-string">"[email protected]"</span> }</td></tr></tbody></table></code></pre> </div> </div> </div> </dd> </dl> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Apply <code class="leafygreen-ui-1l06pbn"> $regexFind </code> to String Elements of an Array <a class="headerlink leafygreen-ui-1kepx47" href="#apply--regexfind-to-string-elements-of-an-array" 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="apply--regexfind-to-string-elements-of-an-array"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> Create a sample collection <code class="leafygreen-ui-1l06pbn"> contacts </code> with the following documents: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.contacts.insertMany([\n { \"_id\" : 1, name: \"Aunt Arc Tikka\", details: [ \"+672-19-9999\", \"[email protected]\" ] },\n { \"_id\" : 2, name: \"Belle Gium\", details: [ \"+32-2-111-11-11\", \"[email protected]\" ] },\n { \"_id\" : 3, name: \"Cam Bo Dia\", details: [ \"+855-012-000-0000\", \"[email protected]\" ] },\n { \"_id\" : 4, name: \"Fred\", details: [ \"+1-111-222-3333\" ] }\n])","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><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">contacts</span>.<span class="lg-highlight-title lg-highlight-function">insertMany</span>(<!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">1</span>, <span class="lg-highlight-attr">name</span>: <span class="lg-highlight-string">"Aunt Arc Tikka"</span>, <span class="lg-highlight-attr">details</span>: <!-- -->[ <span class="lg-highlight-string">"+672-19-9999"</span>, <span class="lg-highlight-string">"[email protected]"</span> ] }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">2</span>, <span class="lg-highlight-attr">name</span>: <span class="lg-highlight-string">"Belle Gium"</span>, <span class="lg-highlight-attr">details</span>: <!-- -->[ <span class="lg-highlight-string">"+32-2-111-11-11"</span>, <span class="lg-highlight-string">"[email protected]"</span> ] }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">3</span>, <span class="lg-highlight-attr">name</span>: <span class="lg-highlight-string">"Cam Bo Dia"</span>, <span class="lg-highlight-attr">details</span>: <!-- -->[ <span class="lg-highlight-string">"+855-012-000-0000"</span>, <span class="lg-highlight-string">"[email protected]"</span> ] }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">4</span>, <span class="lg-highlight-attr">name</span>: <span class="lg-highlight-string">"Fred"</span>, <span class="lg-highlight-attr">details</span>: <!-- -->[ <span class="lg-highlight-string">"+1-111-222-3333"</span> ] }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">])</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 aggregation uses the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-expression-exp.-regexFind" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $regexFind </code> </span> </a> to convert the <code class="leafygreen-ui-1l06pbn"> details </code> array into an embedded document with an <code class="leafygreen-ui-1l06pbn"> email </code> and <code class="leafygreen-ui-1l06pbn"> phone </code> fields: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.contacts.aggregate( [\n { $unwind: \"$details\" },\n { $addFields: {\n \"regexemail\": { $regexFind: { input: \"$details\", regex: /^[a-z0-9_.+-]+@[a-z0-9_.+-]+\\.[a-z0-9_.+-]+$/, options: \"i\" } },\n \"regexphone\": { $regexFind: { input: \"$details\", regex: /^[+]{0,1}[0-9]*\\-?[0-9_\\-]+$/ } }\n } },\n { $project: { _id: 1, name: 1, details: { email: \"$regexemail.match\", phone: \"$regexphone.match\" } } },\n { $group: { _id: \"$_id\", name: { $first: \"$name\" }, details: { $mergeObjects: \"$details\"} } },\n { $sort: { _id: 1 } }\n])","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><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">contacts</span>.<span class="lg-highlight-title lg-highlight-function">aggregate</span>( <!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">$unwind</span>: <span class="lg-highlight-string">"$details"</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">$addFields</span>: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"regexemail"</span>: <!-- -->{ <span class="lg-highlight-attr">$regexFind</span>: <!-- -->{ <span class="lg-highlight-attr">input</span>: <span class="lg-highlight-string">"$details"</span>, <span class="lg-highlight-attr">regex</span>: <span class="lg-highlight-regexp">/^</span><span class="lg-highlight-regexp">[a-z0-9_.+-]</span><span class="lg-highlight-regexp">+@</span><span class="lg-highlight-regexp">[a-z0-9_.+-]</span><span class="lg-highlight-regexp">+</span><span class="lg-highlight-regexp">\.</span><span class="lg-highlight-regexp">[a-z0-9_.+-]</span><span class="lg-highlight-regexp">+$/</span>,<!-- --> <span class="lg-highlight-attr">options</span>: <span class="lg-highlight-string">"i"</span> } }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"regexphone"</span>: <!-- -->{ <span class="lg-highlight-attr">$regexFind</span>: <!-- -->{ <span class="lg-highlight-attr">input</span>: <span class="lg-highlight-string">"$details"</span>, <span class="lg-highlight-attr">regex</span>: <span class="lg-highlight-regexp">/^</span><span class="lg-highlight-regexp">[+]</span><span class="lg-highlight-regexp">{0,1}</span><span class="lg-highlight-regexp">[0-9]</span><span class="lg-highlight-regexp">*</span><span class="lg-highlight-regexp">\-</span><span class="lg-highlight-regexp">?</span><span class="lg-highlight-regexp">[0-9_</span><span class="lg-highlight-regexp">\-</span><span class="lg-highlight-regexp">]</span><span class="lg-highlight-regexp">+$/</span> <!-- -->} }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> } }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">$project</span>: <!-- -->{ <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">1</span>, <span class="lg-highlight-attr">name</span>: <span class="lg-highlight-number">1</span>, <span class="lg-highlight-attr">details</span>: <!-- -->{ <span class="lg-highlight-attr">email</span>: <span class="lg-highlight-string">"$regexemail.match"</span>, <span class="lg-highlight-attr">phone</span>: <span class="lg-highlight-string">"$regexphone.match"</span> } } }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">$group</span>: <!-- -->{ <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-string">"$_id"</span>, <span class="lg-highlight-attr">name</span>: <!-- -->{ <span class="lg-highlight-attr">$first</span>: <span class="lg-highlight-string">"$name"</span> }<!-- -->, <span class="lg-highlight-attr">details</span>: <!-- -->{ <span class="lg-highlight-attr">$mergeObjects</span>: <span class="lg-highlight-string">"$details"</span>} } }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">$sort</span>: <!-- -->{ <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">1</span> } }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">])</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> <dl> <dt> First Stage </dt> <dd class="css-1ufxuu7"> <p class="leafygreen-ui-1kp3ins"> The stage <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/unwind/#mongodb-pipeline-pipe.-unwind"> <code class="leafygreen-ui-1l06pbn"> $unwinds </code> </a> the array into separate documents: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ \"_id\" : 1, \"name\" : \"Aunt Arc Tikka\", \"details\" : \"+672-19-9999\" }\n{ \"_id\" : 1, \"name\" : \"Aunt Arc Tikka\", \"details\" : \"[email protected]\" }\n{ \"_id\" : 2, \"name\" : \"Belle Gium\", \"details\" : \"+32-2-111-11-11\" }\n{ \"_id\" : 2, \"name\" : \"Belle Gium\", \"details\" : \"[email protected]\" }\n{ \"_id\" : 3, \"name\" : \"Cam Bo Dia\", \"details\" : \"+855-012-000-0000\" }\n{ \"_id\" : 3, \"name\" : \"Cam Bo Dia\", \"details\" : \"[email protected]\" }\n{ \"_id\" : 4, \"name\" : \"Fred\", \"details\" : \"+1-111-222-3333\" }","programmingLanguage":"JavaScript"} </script> <div class="css-1lju8ps"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-tyg50d"> <pre class="leafygreen-ui-1453az5" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">1</span>, <span class="lg-highlight-string">"name"</span> <!-- -->: <span class="lg-highlight-string">"Aunt Arc Tikka"</span>, <span class="lg-highlight-string">"details"</span> <!-- -->: <span class="lg-highlight-string">"+672-19-9999"</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">1</span>, <span class="lg-highlight-string">"name"</span> <!-- -->: <span class="lg-highlight-string">"Aunt Arc Tikka"</span>, <span class="lg-highlight-string">"details"</span> <!-- -->: <span class="lg-highlight-string">"[email protected]"</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">2</span>, <span class="lg-highlight-string">"name"</span> <!-- -->: <span class="lg-highlight-string">"Belle Gium"</span>, <span class="lg-highlight-string">"details"</span> <!-- -->: <span class="lg-highlight-string">"+32-2-111-11-11"</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">2</span>, <span class="lg-highlight-string">"name"</span> <!-- -->: <span class="lg-highlight-string">"Belle Gium"</span>, <span class="lg-highlight-string">"details"</span> <!-- -->: <span class="lg-highlight-string">"[email protected]"</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">3</span>, <span class="lg-highlight-string">"name"</span> <!-- -->: <span class="lg-highlight-string">"Cam Bo Dia"</span>, <span class="lg-highlight-string">"details"</span> <!-- -->: <span class="lg-highlight-string">"+855-012-000-0000"</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">3</span>, <span class="lg-highlight-string">"name"</span> <!-- -->: <span class="lg-highlight-string">"Cam Bo Dia"</span>, <span class="lg-highlight-string">"details"</span> <!-- -->: <span class="lg-highlight-string">"[email protected]"</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">4</span>, <span class="lg-highlight-string">"name"</span> <!-- -->: <span class="lg-highlight-string">"Fred"</span>, <span class="lg-highlight-string">"details"</span> <!-- -->: <span class="lg-highlight-string">"+1-111-222-3333"</span> }</td></tr></tbody></table></code></pre> </div> </div> </div> </dd> <dt> Second Stage </dt> <dd class="css-1ufxuu7"> <p class="leafygreen-ui-1kp3ins"> The stage uses the <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 to add new fields to the document that contains the result of the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-expression-exp.-regexFind" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $regexFind </code> </span> </a> for phone number and email: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ \"_id\" : 1, \"name\" : \"Aunt Arc Tikka\", \"details\" : \"+672-19-9999\", \"regexemail\" : null, \"regexphone\" : { \"match\" : \"+672-19-9999\", \"idx\" : 0, \"captures\" : [ ] } }\n{ \"_id\" : 1, \"name\" : \"Aunt Arc Tikka\", \"details\" : \"[email protected]\", \"regexemail\" : { \"match\" : \"[email protected]\", \"idx\" : 0, \"captures\" : [ ] }, \"regexphone\" : null }\n{ \"_id\" : 2, \"name\" : \"Belle Gium\", \"details\" : \"+32-2-111-11-11\", \"regexemail\" : null, \"regexphone\" : { \"match\" : \"+32-2-111-11-11\", \"idx\" : 0, \"captures\" : [ ] } }\n{ \"_id\" : 2, \"name\" : \"Belle Gium\", \"details\" : \"[email protected]\", \"regexemail\" : { \"match\" : \"[email protected]\", \"idx\" : 0, \"captures\" : [ ] }, \"regexphone\" : null }\n{ \"_id\" : 3, \"name\" : \"Cam Bo Dia\", \"details\" : \"+855-012-000-0000\", \"regexemail\" : null, \"regexphone\" : { \"match\" : \"+855-012-000-0000\", \"idx\" : 0, \"captures\" : [ ] } }\n{ \"_id\" : 3, \"name\" : \"Cam Bo Dia\", \"details\" : \"[email protected]\", \"regexemail\" : { \"match\" : \"[email protected]\", \"idx\" : 0, \"captures\" : [ ] }, \"regexphone\" : null }\n{ \"_id\" : 4, \"name\" : \"Fred\", \"details\" : \"+1-111-222-3333\", \"regexemail\" : null, \"regexphone\" : { \"match\" : \"+1-111-222-3333\", \"idx\" : 0, \"captures\" : [ ] } }","programmingLanguage":"JavaScript"} </script> <div class="css-1lju8ps"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-tyg50d"> <pre class="leafygreen-ui-1453az5" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">1</span>, <span class="lg-highlight-string">"name"</span> <!-- -->: <span class="lg-highlight-string">"Aunt Arc Tikka"</span>, <span class="lg-highlight-string">"details"</span> <!-- -->: <span class="lg-highlight-string">"+672-19-9999"</span>, <span class="lg-highlight-string">"regexemail"</span> <!-- -->: <span class="lg-highlight-literal">null</span>, <span class="lg-highlight-string">"regexphone"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-string">"match"</span> <!-- -->: <span class="lg-highlight-string">"+672-19-9999"</span>, <span class="lg-highlight-string">"idx"</span> <!-- -->: <span class="lg-highlight-number">0</span>, <span class="lg-highlight-string">"captures"</span> <!-- -->: <!-- -->[ <!-- -->] } }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">1</span>, <span class="lg-highlight-string">"name"</span> <!-- -->: <span class="lg-highlight-string">"Aunt Arc Tikka"</span>, <span class="lg-highlight-string">"details"</span> <!-- -->: <span class="lg-highlight-string">"[email protected]"</span>, <span class="lg-highlight-string">"regexemail"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-string">"match"</span> <!-- -->: <span class="lg-highlight-string">"[email protected]"</span>, <span class="lg-highlight-string">"idx"</span> <!-- -->: <span class="lg-highlight-number">0</span>, <span class="lg-highlight-string">"captures"</span> <!-- -->: <!-- -->[ <!-- -->] }<!-- -->, <span class="lg-highlight-string">"regexphone"</span> <!-- -->: <span class="lg-highlight-literal">null</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">2</span>, <span class="lg-highlight-string">"name"</span> <!-- -->: <span class="lg-highlight-string">"Belle Gium"</span>, <span class="lg-highlight-string">"details"</span> <!-- -->: <span class="lg-highlight-string">"+32-2-111-11-11"</span>, <span class="lg-highlight-string">"regexemail"</span> <!-- -->: <span class="lg-highlight-literal">null</span>, <span class="lg-highlight-string">"regexphone"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-string">"match"</span> <!-- -->: <span class="lg-highlight-string">"+32-2-111-11-11"</span>, <span class="lg-highlight-string">"idx"</span> <!-- -->: <span class="lg-highlight-number">0</span>, <span class="lg-highlight-string">"captures"</span> <!-- -->: <!-- -->[ <!-- -->] } }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">2</span>, <span class="lg-highlight-string">"name"</span> <!-- -->: <span class="lg-highlight-string">"Belle Gium"</span>, <span class="lg-highlight-string">"details"</span> <!-- -->: <span class="lg-highlight-string">"[email protected]"</span>, <span class="lg-highlight-string">"regexemail"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-string">"match"</span> <!-- -->: <span class="lg-highlight-string">"[email protected]"</span>, <span class="lg-highlight-string">"idx"</span> <!-- -->: <span class="lg-highlight-number">0</span>, <span class="lg-highlight-string">"captures"</span> <!-- -->: <!-- -->[ <!-- -->] }<!-- -->, <span class="lg-highlight-string">"regexphone"</span> <!-- -->: <span class="lg-highlight-literal">null</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">3</span>, <span class="lg-highlight-string">"name"</span> <!-- -->: <span class="lg-highlight-string">"Cam Bo Dia"</span>, <span class="lg-highlight-string">"details"</span> <!-- -->: <span class="lg-highlight-string">"+855-012-000-0000"</span>, <span class="lg-highlight-string">"regexemail"</span> <!-- -->: <span class="lg-highlight-literal">null</span>, <span class="lg-highlight-string">"regexphone"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-string">"match"</span> <!-- -->: <span class="lg-highlight-string">"+855-012-000-0000"</span>, <span class="lg-highlight-string">"idx"</span> <!-- -->: <span class="lg-highlight-number">0</span>, <span class="lg-highlight-string">"captures"</span> <!-- -->: <!-- -->[ <!-- -->] } }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">3</span>, <span class="lg-highlight-string">"name"</span> <!-- -->: <span class="lg-highlight-string">"Cam Bo Dia"</span>, <span class="lg-highlight-string">"details"</span> <!-- -->: <span class="lg-highlight-string">"[email protected]"</span>, <span class="lg-highlight-string">"regexemail"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-string">"match"</span> <!-- -->: <span class="lg-highlight-string">"[email protected]"</span>, <span class="lg-highlight-string">"idx"</span> <!-- -->: <span class="lg-highlight-number">0</span>, <span class="lg-highlight-string">"captures"</span> <!-- -->: <!-- -->[ <!-- -->] }<!-- -->, <span class="lg-highlight-string">"regexphone"</span> <!-- -->: <span class="lg-highlight-literal">null</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">4</span>, <span class="lg-highlight-string">"name"</span> <!-- -->: <span class="lg-highlight-string">"Fred"</span>, <span class="lg-highlight-string">"details"</span> <!-- -->: <span class="lg-highlight-string">"+1-111-222-3333"</span>, <span class="lg-highlight-string">"regexemail"</span> <!-- -->: <span class="lg-highlight-literal">null</span>, <span class="lg-highlight-string">"regexphone"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-string">"match"</span> <!-- -->: <span class="lg-highlight-string">"+1-111-222-3333"</span>, <span class="lg-highlight-string">"idx"</span> <!-- -->: <span class="lg-highlight-number">0</span>, <span class="lg-highlight-string">"captures"</span> <!-- -->: <!-- -->[ <!-- -->] } }</td></tr></tbody></table></code></pre> </div> </div> </div> </dd> <dt> Third Stage </dt> <dd class="css-1ufxuu7"> <p class="leafygreen-ui-1kp3ins"> The stage use the <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 to output documents with the <code class="leafygreen-ui-1l06pbn"> _id </code> field, the <code class="leafygreen-ui-1l06pbn"> name </code> field and the <code class="leafygreen-ui-1l06pbn"> details </code> field. The <code class="leafygreen-ui-1l06pbn"> details </code> field is set to a document with <code class="leafygreen-ui-1l06pbn"> email </code> and <code class="leafygreen-ui-1l06pbn"> phone </code> fields, whose values are determined from the <code class="leafygreen-ui-1l06pbn"> regexemail </code> and <code class="leafygreen-ui-1l06pbn"> regexphone </code> fields, respectively. </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ \"_id\" : 1, \"name\" : \"Aunt Arc Tikka\", \"details\" : { \"phone\" : \"+672-19-9999\" } }\n{ \"_id\" : 1, \"name\" : \"Aunt Arc Tikka\", \"details\" : { \"email\" : \"[email protected]\" } }\n{ \"_id\" : 2, \"name\" : \"Belle Gium\", \"details\" : { \"phone\" : \"+32-2-111-11-11\" } }\n{ \"_id\" : 2, \"name\" : \"Belle Gium\", \"details\" : { \"email\" : \"[email protected]\" } }\n{ \"_id\" : 3, \"name\" : \"Cam Bo Dia\", \"details\" : { \"phone\" : \"+855-012-000-0000\" } }\n{ \"_id\" : 3, \"name\" : \"Cam Bo Dia\", \"details\" : { \"email\" : \"[email protected]\" } }\n{ \"_id\" : 4, \"name\" : \"Fred\", \"details\" : { \"phone\" : \"+1-111-222-3333\" } }","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">1</span>, <span class="lg-highlight-string">"name"</span> <!-- -->: <span class="lg-highlight-string">"Aunt Arc Tikka"</span>, <span class="lg-highlight-string">"details"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-string">"phone"</span> <!-- -->: <span class="lg-highlight-string">"+672-19-9999"</span> } }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">1</span>, <span class="lg-highlight-string">"name"</span> <!-- -->: <span class="lg-highlight-string">"Aunt Arc Tikka"</span>, <span class="lg-highlight-string">"details"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-string">"email"</span> <!-- -->: <span class="lg-highlight-string">"[email protected]"</span> } }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">2</span>, <span class="lg-highlight-string">"name"</span> <!-- -->: <span class="lg-highlight-string">"Belle Gium"</span>, <span class="lg-highlight-string">"details"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-string">"phone"</span> <!-- -->: <span class="lg-highlight-string">"+32-2-111-11-11"</span> } }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">2</span>, <span class="lg-highlight-string">"name"</span> <!-- -->: <span class="lg-highlight-string">"Belle Gium"</span>, <span class="lg-highlight-string">"details"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-string">"email"</span> <!-- -->: <span class="lg-highlight-string">"[email protected]"</span> } }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">3</span>, <span class="lg-highlight-string">"name"</span> <!-- -->: <span class="lg-highlight-string">"Cam Bo Dia"</span>, <span class="lg-highlight-string">"details"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-string">"phone"</span> <!-- -->: <span class="lg-highlight-string">"+855-012-000-0000"</span> } }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">3</span>, <span class="lg-highlight-string">"name"</span> <!-- -->: <span class="lg-highlight-string">"Cam Bo Dia"</span>, <span class="lg-highlight-string">"details"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-string">"email"</span> <!-- -->: <span class="lg-highlight-string">"[email protected]"</span> } }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">4</span>, <span class="lg-highlight-string">"name"</span> <!-- -->: <span class="lg-highlight-string">"Fred"</span>, <span class="lg-highlight-string">"details"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-string">"phone"</span> <!-- -->: <span class="lg-highlight-string">"+1-111-222-3333"</span> } }</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> </dd> <dt> Fourth Stage </dt> <dd class="css-1ufxuu7"> <p class="leafygreen-ui-1kp3ins"> The stage uses the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/group/#mongodb-pipeline-pipe.-group"> <code class="leafygreen-ui-1l06pbn"> $group </code> </a> stage to groups the input documents by their <code class="leafygreen-ui-1l06pbn"> _id </code> value. The stage uses the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/mergeObjects/#mongodb-expression-exp.-mergeObjects"> <code class="leafygreen-ui-1l06pbn"> $mergeObjects </code> </a> expression to merge the <code class="leafygreen-ui-1l06pbn"> details </code> documents. </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ \"_id\" : 3, \"name\" : \"Cam Bo Dia\", \"details\" : { \"phone\" : \"+855-012-000-0000\", \"email\" : \"[email protected]\" } }\n{ \"_id\" : 4, \"name\" : \"Fred\", \"details\" : { \"phone\" : \"+1-111-222-3333\" } }\n{ \"_id\" : 1, \"name\" : \"Aunt Arc Tikka\", \"details\" : { \"phone\" : \"+672-19-9999\", \"email\" : \"[email protected]\" } }\n{ \"_id\" : 2, \"name\" : \"Belle Gium\", \"details\" : { \"phone\" : \"+32-2-111-11-11\", \"email\" : \"[email protected]\" } }","programmingLanguage":"JavaScript"} </script> <div class="css-1lju8ps"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-tyg50d"> <pre class="leafygreen-ui-1453az5" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">3</span>, <span class="lg-highlight-string">"name"</span> <!-- -->: <span class="lg-highlight-string">"Cam Bo Dia"</span>, <span class="lg-highlight-string">"details"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-string">"phone"</span> <!-- -->: <span class="lg-highlight-string">"+855-012-000-0000"</span>, <span class="lg-highlight-string">"email"</span> <!-- -->: <span class="lg-highlight-string">"[email protected]"</span> } }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">4</span>, <span class="lg-highlight-string">"name"</span> <!-- -->: <span class="lg-highlight-string">"Fred"</span>, <span class="lg-highlight-string">"details"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-string">"phone"</span> <!-- -->: <span class="lg-highlight-string">"+1-111-222-3333"</span> } }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">1</span>, <span class="lg-highlight-string">"name"</span> <!-- -->: <span class="lg-highlight-string">"Aunt Arc Tikka"</span>, <span class="lg-highlight-string">"details"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-string">"phone"</span> <!-- -->: <span class="lg-highlight-string">"+672-19-9999"</span>, <span class="lg-highlight-string">"email"</span> <!-- -->: <span class="lg-highlight-string">"[email protected]"</span> } }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">2</span>, <span class="lg-highlight-string">"name"</span> <!-- -->: <span class="lg-highlight-string">"Belle Gium"</span>, <span class="lg-highlight-string">"details"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-string">"phone"</span> <!-- -->: <span class="lg-highlight-string">"+32-2-111-11-11"</span>, <span class="lg-highlight-string">"email"</span> <!-- -->: <span class="lg-highlight-string">"[email protected]"</span> } }</td></tr></tbody></table></code></pre> </div> </div> </div> </dd> <dt> Fifth Stage </dt> <dd class="css-1ufxuu7"> <p class="leafygreen-ui-1kp3ins"> The stage uses the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/sort/#mongodb-pipeline-pipe.-sort"> <code class="leafygreen-ui-1l06pbn"> $sort </code> </a> stage to sort the documents by the <code class="leafygreen-ui-1l06pbn"> _id </code> field. </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ \"_id\" : 1, \"name\" : \"Aunt Arc Tikka\", \"details\" : { \"phone\" : \"+672-19-9999\", \"email\" : \"[email protected]\" } }\n{ \"_id\" : 2, \"name\" : \"Belle Gium\", \"details\" : { \"phone\" : \"+32-2-111-11-11\", \"email\" : \"[email protected]\" } }\n{ \"_id\" : 3, \"name\" : \"Cam Bo Dia\", \"details\" : { \"phone\" : \"+855-012-000-0000\", \"email\" : \"[email protected]\" } }\n{ \"_id\" : 4, \"name\" : \"Fred\", \"details\" : { \"phone\" : \"+1-111-222-3333\" } }","programmingLanguage":"JavaScript"} </script> <div class="css-1lju8ps"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-tyg50d"> <pre class="leafygreen-ui-1453az5" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">1</span>, <span class="lg-highlight-string">"name"</span> <!-- -->: <span class="lg-highlight-string">"Aunt Arc Tikka"</span>, <span class="lg-highlight-string">"details"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-string">"phone"</span> <!-- -->: <span class="lg-highlight-string">"+672-19-9999"</span>, <span class="lg-highlight-string">"email"</span> <!-- -->: <span class="lg-highlight-string">"[email protected]"</span> } }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">2</span>, <span class="lg-highlight-string">"name"</span> <!-- -->: <span class="lg-highlight-string">"Belle Gium"</span>, <span class="lg-highlight-string">"details"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-string">"phone"</span> <!-- -->: <span class="lg-highlight-string">"+32-2-111-11-11"</span>, <span class="lg-highlight-string">"email"</span> <!-- -->: <span class="lg-highlight-string">"[email protected]"</span> } }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">3</span>, <span class="lg-highlight-string">"name"</span> <!-- -->: <span class="lg-highlight-string">"Cam Bo Dia"</span>, <span class="lg-highlight-string">"details"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-string">"phone"</span> <!-- -->: <span class="lg-highlight-string">"+855-012-000-0000"</span>, <span class="lg-highlight-string">"email"</span> <!-- -->: <span class="lg-highlight-string">"[email protected]"</span> } }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">4</span>, <span class="lg-highlight-string">"name"</span> <!-- -->: <span class="lg-highlight-string">"Fred"</span>, <span class="lg-highlight-string">"details"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-string">"phone"</span> <!-- -->: <span class="lg-highlight-string">"+1-111-222-3333"</span> } }</td></tr></tbody></table></code></pre> </div> </div> </div> </dd> </dl> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Use Captured Groupings to Parse User Name <a class="headerlink leafygreen-ui-1kepx47" href="#use-captured-groupings-to-parse-user-name" 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="use-captured-groupings-to-parse-user-name"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> Create a sample collection <code class="leafygreen-ui-1l06pbn"> employees </code> with the following documents: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.employees.insertMany([\n { \"_id\" : 1, name: \"Aunt Arc Tikka\", \"email\" : \"[email protected]\" },\n { \"_id\" : 2, name: \"Belle Gium\", \"email\" : \"[email protected]\" },\n { \"_id\" : 3, name: \"Cam Bo Dia\", \"email\" : \"[email protected]\" },\n { \"_id\" : 4, name: \"Fred\" }\n])","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><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">employees</span>.<span class="lg-highlight-title lg-highlight-function">insertMany</span>(<!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">1</span>, <span class="lg-highlight-attr">name</span>: <span class="lg-highlight-string">"Aunt Arc Tikka"</span>, <span class="lg-highlight-string">"email"</span> <!-- -->: <span class="lg-highlight-string">"[email protected]"</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">2</span>, <span class="lg-highlight-attr">name</span>: <span class="lg-highlight-string">"Belle Gium"</span>, <span class="lg-highlight-string">"email"</span> <!-- -->: <span class="lg-highlight-string">"[email protected]"</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">3</span>, <span class="lg-highlight-attr">name</span>: <span class="lg-highlight-string">"Cam Bo Dia"</span>, <span class="lg-highlight-string">"email"</span> <!-- -->: <span class="lg-highlight-string">"[email protected]"</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">4</span>, <span class="lg-highlight-attr">name</span>: <span class="lg-highlight-string">"Fred"</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">])</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 employee email has the format <code class="leafygreen-ui-1l06pbn"> &lt;firstname&gt;.&lt;lastname&gt;@example.com </code> . Using the <code class="leafygreen-ui-1l06pbn"> captured </code> field returned in the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-expression-exp.-regexFind" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $regexFind </code> </span> </a> results, you can parse out user names for employees. </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.employees.aggregate( [\n { $addFields: {\n \"username\": { $regexFind: { input: \"$email\", regex: /^([a-z0-9_.+-]+)@[a-z0-9_.+-]+\\.[a-z0-9_.+-]+$/, options: \"i\" } },\n } },\n { $set: { username: { $arrayElemAt: [ \"$username.captures\", 0 ] } } }\n] )","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><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">employees</span>.<span class="lg-highlight-title lg-highlight-function">aggregate</span>( <!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">$addFields</span>: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"username"</span>: <!-- -->{ <span class="lg-highlight-attr">$regexFind</span>: <!-- -->{ <span class="lg-highlight-attr">input</span>: <span class="lg-highlight-string">"$email"</span>, <span class="lg-highlight-attr">regex</span>: <span class="lg-highlight-regexp">/^(</span><span class="lg-highlight-regexp">[a-z0-9_.+-]</span><span class="lg-highlight-regexp">+)@</span><span class="lg-highlight-regexp">[a-z0-9_.+-]</span><span class="lg-highlight-regexp">+</span><span class="lg-highlight-regexp">\.</span><span class="lg-highlight-regexp">[a-z0-9_.+-]</span><span class="lg-highlight-regexp">+$/</span>,<!-- --> <span class="lg-highlight-attr">options</span>: <span class="lg-highlight-string">"i"</span> } }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->} }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">$set</span>: <!-- -->{ <span class="lg-highlight-attr">username</span>: <!-- -->{ <span class="lg-highlight-attr">$arrayElemAt</span>: <!-- -->[ <span class="lg-highlight-string">"$username.captures"</span>, <span class="lg-highlight-number">0</span> ] } } }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">] )</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> <dl> <dt> First Stage </dt> <dd class="css-1ufxuu7"> <p class="leafygreen-ui-1kp3ins"> The stage uses the <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 to add a new field <code class="leafygreen-ui-1l06pbn"> username </code> to the document. The new field contains the result of performing the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-expression-exp.-regexFind" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $regexFind </code> </span> </a> on the <code class="leafygreen-ui-1l06pbn"> email </code> field: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ \"_id\" : 1, \"name\" : \"Aunt Arc Tikka\", \"email\" : \"[email protected]\", \"username\" : { \"match\" : \"[email protected]\", \"idx\" : 0, \"captures\" : [ \"aunt.tica\" ] } }\n{ \"_id\" : 2, \"name\" : \"Belle Gium\", \"email\" : \"[email protected]\", \"username\" : { \"match\" : \"[email protected]\", \"idx\" : 0, \"captures\" : [ \"belle.gium\" ] } }\n{ \"_id\" : 3, \"name\" : \"Cam Bo Dia\", \"email\" : \"[email protected]\", \"username\" : { \"match\" : \"[email protected]\", \"idx\" : 0, \"captures\" : [ \"cam.dia\" ] } }\n{ \"_id\" : 4, \"name\" : \"Fred\", \"username\" : null }","programmingLanguage":"JavaScript"} </script> <div class="css-1lju8ps"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-tyg50d"> <pre class="leafygreen-ui-1453az5" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">1</span>, <span class="lg-highlight-string">"name"</span> <!-- -->: <span class="lg-highlight-string">"Aunt Arc Tikka"</span>, <span class="lg-highlight-string">"email"</span> <!-- -->: <span class="lg-highlight-string">"[email protected]"</span>, <span class="lg-highlight-string">"username"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-string">"match"</span> <!-- -->: <span class="lg-highlight-string">"[email protected]"</span>, <span class="lg-highlight-string">"idx"</span> <!-- -->: <span class="lg-highlight-number">0</span>, <span class="lg-highlight-string">"captures"</span> <!-- -->: <!-- -->[ <span class="lg-highlight-string">"aunt.tica"</span> ] } }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">2</span>, <span class="lg-highlight-string">"name"</span> <!-- -->: <span class="lg-highlight-string">"Belle Gium"</span>, <span class="lg-highlight-string">"email"</span> <!-- -->: <span class="lg-highlight-string">"[email protected]"</span>, <span class="lg-highlight-string">"username"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-string">"match"</span> <!-- -->: <span class="lg-highlight-string">"[email protected]"</span>, <span class="lg-highlight-string">"idx"</span> <!-- -->: <span class="lg-highlight-number">0</span>, <span class="lg-highlight-string">"captures"</span> <!-- -->: <!-- -->[ <span class="lg-highlight-string">"belle.gium"</span> ] } }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">3</span>, <span class="lg-highlight-string">"name"</span> <!-- -->: <span class="lg-highlight-string">"Cam Bo Dia"</span>, <span class="lg-highlight-string">"email"</span> <!-- -->: <span class="lg-highlight-string">"[email protected]"</span>, <span class="lg-highlight-string">"username"</span> <!-- -->: <!-- -->{ <span class="lg-highlight-string">"match"</span> <!-- -->: <span class="lg-highlight-string">"[email protected]"</span>, <span class="lg-highlight-string">"idx"</span> <!-- -->: <span class="lg-highlight-number">0</span>, <span class="lg-highlight-string">"captures"</span> <!-- -->: <!-- -->[ <span class="lg-highlight-string">"cam.dia"</span> ] } }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">4</span>, <span class="lg-highlight-string">"name"</span> <!-- -->: <span class="lg-highlight-string">"Fred"</span>, <span class="lg-highlight-string">"username"</span> <!-- -->: <span class="lg-highlight-literal">null</span> }</td></tr></tbody></table></code></pre> </div> </div> </div> </dd> <dt> Second Stage </dt> <dd class="css-1ufxuu7"> <p class="leafygreen-ui-1kp3ins"> The stage use the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/set/#mongodb-pipeline-pipe.-set"> <code class="leafygreen-ui-1l06pbn"> $set </code> </a> stage to reset the <code class="leafygreen-ui-1l06pbn"> username </code> to the zero-th element of the <code class="leafygreen-ui-1l06pbn"> "$username.captures" </code> array. If the current value of <code class="leafygreen-ui-1l06pbn"> username </code> is null, the new value of <code class="leafygreen-ui-1l06pbn"> username </code> is set to null. </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ \"_id\" : 1, \"name\" : \"Aunt Arc Tikka\", \"email\" : \"[email protected]\", \"username\" : \"aunt.tica\" }\n{ \"_id\" : 2, \"name\" : \"Belle Gium\", \"email\" : \"[email protected]\", \"username\" : \"belle.gium\" }\n{ \"_id\" : 3, \"name\" : \"Cam Bo Dia\", \"email\" : \"[email protected]\", \"username\" : \"cam.dia\" }\n{ \"_id\" : 4, \"name\" : \"Fred\", \"username\" : null }","programmingLanguage":"JavaScript"} </script> <div class="css-1lju8ps"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-tyg50d"> <pre class="leafygreen-ui-1453az5" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">1</span>, <span class="lg-highlight-string">"name"</span> <!-- -->: <span class="lg-highlight-string">"Aunt Arc Tikka"</span>, <span class="lg-highlight-string">"email"</span> <!-- -->: <span class="lg-highlight-string">"[email protected]"</span>, <span class="lg-highlight-string">"username"</span> <!-- -->: <span class="lg-highlight-string">"aunt.tica"</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">2</span>, <span class="lg-highlight-string">"name"</span> <!-- -->: <span class="lg-highlight-string">"Belle Gium"</span>, <span class="lg-highlight-string">"email"</span> <!-- -->: <span class="lg-highlight-string">"[email protected]"</span>, <span class="lg-highlight-string">"username"</span> <!-- -->: <span class="lg-highlight-string">"belle.gium"</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">3</span>, <span class="lg-highlight-string">"name"</span> <!-- -->: <span class="lg-highlight-string">"Cam Bo Dia"</span>, <span class="lg-highlight-string">"email"</span> <!-- -->: <span class="lg-highlight-string">"[email protected]"</span>, <span class="lg-highlight-string">"username"</span> <!-- -->: <span class="lg-highlight-string">"cam.dia"</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">4</span>, <span class="lg-highlight-string">"name"</span> <!-- -->: <span class="lg-highlight-string">"Fred"</span>, <span class="lg-highlight-string">"username"</span> <!-- -->: <span class="lg-highlight-literal">null</span> }</td></tr></tbody></table></code></pre> </div> </div> </div> </dd> </dl> <div class="leafygreen-ui-13vw3ie" role="note"> <h2 class="leafygreen-ui-1fn4p2b"> Tip </h2> <h3 class="leafygreen-ui-144d5kf"> <strong> See also: </strong> </h3> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> For more information on the behavior of the <code class="leafygreen-ui-1l06pbn"> captures </code> array and additional examples, see <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-regexFind-captures-behavior" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> captures </code> Output Behavior <!-- --> . </span> </a> </p> </div> </div> </section> </section> </section>
https://www.mongodb.com/docs/manual/reference/method/db.collection.countDocuments/
<section> <h1 class="contains-headerlink leafygreen-ui-41fr9s" weight="medium"> db.collection.countDocuments() <a class="headerlink leafygreen-ui-1kepx47" href="#db.collection.countdocuments--" 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.countdocuments--"> </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="#definition" target="_self"> <span> Definition </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#compatibility" target="_self"> <span> Compatibility </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#syntax" target="_self"> <span> Syntax </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#behavior" target="_self"> <span> Behavior </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#examples" target="_self"> <span> Examples </span> </a> </li> </ul> </div> <div class="leafygreen-ui-147elvs"> <p class="leafygreen-ui-1ronz74"> MongoDB with drivers </p> <div class="leafygreen-ui-18k5rfm"> <p class="leafygreen-ui-1kp3ins"> This page documents a <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/mongodb-shell/#mongodb-binary-bin.mongosh" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongosh </code> </span> </a> method. To see the equivalent method in a MongoDB driver, see the corresponding page for your programming language: </p> </div> <div class="leafygreen-ui-zgrwqu notranslate"> <a class="leafygreen-ui-v22cck" href="https://www.mongodb.com/docs/drivers/csharp/current/fundamentals/crud/read-operations/count/" target="_self"> <svg class="leafygreen-ui-x3zji3" fill="none" height="24" viewbox="0 0 28 29" width="24" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_1351_59964)"> <g clip-path="url(#clip1_1351_59964)"> <path d="M25.7709 9.2495C25.7709 8.79827 25.678 8.39408 25.4827 8.04627C25.2874 7.70785 25.0084 7.42586 24.627 7.20025C21.465 5.35781 18.2937 3.51538 15.1317 1.67295C14.2761 1.17474 13.4484 1.19354 12.6021 1.70115C11.3466 2.45316 5.04112 6.10042 3.15321 7.20025C2.3813 7.65142 2 8.34705 2 9.24005C2 12.9531 2 16.6568 2 20.3698C2 20.8117 2.093 21.2064 2.279 21.5449C2.4743 21.8927 2.7626 22.1841 3.15321 22.4191C5.03182 23.5189 11.3373 27.1662 12.6021 27.9182C13.4484 28.4258 14.2761 28.4446 15.1317 27.9463C18.2937 26.1039 21.465 24.2615 24.627 22.4191C25.0177 22.1935 25.306 21.9021 25.5012 21.5449C25.6873 21.2064 25.7803 20.8117 25.7803 20.3698C25.7709 20.3698 25.7709 12.9531 25.7709 9.2495Z" fill="#A179DC"> </path> <path d="M13.9227 14.7673L2.27905 21.5449C2.47435 21.8927 2.76265 22.1841 3.15326 22.4191C5.03187 23.5189 11.3373 27.1662 12.6021 27.9182C13.4484 28.4258 14.2762 28.4445 15.1317 27.9463C18.2938 26.1039 21.4651 24.2615 24.6271 22.4191C25.0177 22.1935 25.306 21.9021 25.5013 21.5449L13.9227 14.7673Z" fill="#280068"> </path> <path d="M25.7711 9.24949C25.7711 8.79827 25.6781 8.39408 25.4828 8.04626L13.9229 14.7768L25.4921 21.5543C25.6781 21.2159 25.7711 20.8211 25.7711 20.3793C25.7711 20.3699 25.7711 12.9531 25.7711 9.24949Z" fill="#390091"> </path> <path d="M20.7771 12.2387V13.5078H22.0325V12.2387H22.6557V13.5078H23.9111V14.1376H22.6557V15.4066H23.9111V16.0364H22.6557V17.3054H22.0325V16.0364H20.7771V17.3054H20.1539V16.0364H18.8984V15.4066H20.1539V14.1376H18.8984V13.5078H20.1539V12.2387H20.7771ZM22.0325 14.1376H20.7771V15.4066H22.0325V14.1376Z" fill="white"> </path> <path d="M13.9508 5.87482C17.2151 5.87482 20.0702 7.67022 21.6047 10.3399L21.5861 10.3117L17.7452 12.5489C16.9919 11.2517 15.5969 10.3775 14.0066 10.3587H13.9601C11.5328 10.3587 9.56116 12.3515 9.56116 14.805C9.56116 15.604 9.77503 16.3654 10.1377 17.014C10.9004 18.3488 12.3232 19.2512 13.9601 19.2512C15.6062 19.2512 17.0384 18.3394 17.7917 16.9858L17.7731 17.014L21.614 19.2606C20.0981 21.9021 17.2895 23.6975 14.0531 23.7257H13.9508C10.6679 23.7257 7.81274 21.9209 6.28753 19.2418C5.54353 17.9352 5.11572 16.4124 5.11572 14.7956C5.11572 9.87931 9.06825 5.87482 13.9508 5.87482Z" fill="white"> </path> </g> </g> <defs> <clippath id="clip0_1351_59964"> <rect fill="white" height="28" transform="translate(0 0.809265)" width="28"> </rect> </clippath> <clippath id="clip1_1351_59964"> <rect fill="white" height="27" transform="translate(2 1.30966)" width="24"> </rect> </clippath> </defs> </svg> <span> C# </span> </a> <a class="leafygreen-ui-v22cck" href="https://www.mongodb.com/docs/drivers/java/sync/current/usage-examples/count/" target="_self"> <svg class="leafygreen-ui-x3zji3" fill="none" height="24" viewbox="0 0 30 41" width="24" xmlns="http://www.w3.org/2000/svg"> <path d="M10.0921 30.7949C10.0921 30.7949 8.57608 31.6793 11.166 31.9636C14.2929 32.311 15.9037 32.2794 19.3464 31.6161C19.3464 31.6161 20.2623 32.1846 21.5257 32.6901C13.7876 35.9748 4.02791 32.5005 10.0921 30.7949Z" fill="#0074BD"> </path> <path d="M9.14539 26.4678C9.14539 26.4678 7.43985 27.7312 10.0298 27.9838C13.3778 28.3312 15.9992 28.3628 20.579 27.4785C20.579 27.4785 21.2107 28.1101 22.1898 28.4576C12.8724 31.2054 2.44949 28.6787 9.14539 26.4678Z" fill="#0074BD"> </path> <path d="M17.1039 19.1398C18.9989 21.3191 16.5985 23.3089 16.5985 23.3089C16.5985 23.3089 21.431 20.8138 19.2201 17.6869C17.1355 14.7811 15.5563 13.3282 24.1788 8.33789C24.1473 8.33789 10.6607 11.6858 17.1039 19.1398Z" fill="#EA2D2E"> </path> <path d="M27.3377 33.9845C27.3377 33.9845 28.4431 34.9004 26.1059 35.6269C21.6525 36.985 7.53417 37.3957 3.61769 35.6901C2.19639 35.0899 4.84949 34.2372 5.67069 34.0477C6.52347 33.8582 7.02884 33.8898 7.02884 33.8898C5.44961 32.7843 -3.10981 36.0691 2.67016 36.9851C18.4308 39.5433 31.4121 35.8164 27.3377 33.9845Z" fill="#0074BD"> </path> <path d="M10.8194 21.983C10.8194 21.983 3.6497 23.6885 8.2926 24.3203C10.2509 24.5729 14.1357 24.5097 17.7995 24.2255C20.7685 23.9728 23.7375 23.4359 23.7375 23.4359C23.7375 23.4359 22.6951 23.8781 21.9372 24.415C14.6411 26.3416 0.585992 25.4257 4.62881 23.4675C8.00839 21.7935 10.8194 21.983 10.8194 21.983Z" fill="#0074BD"> </path> <path d="M23.6745 29.1846C31.0969 25.3313 27.6542 21.6359 25.2538 22.1413C24.6537 22.2676 24.401 22.3623 24.401 22.3623C24.401 22.3623 24.6221 22.0149 25.0327 21.8886C29.7703 20.2146 33.4025 26.7842 23.5166 29.4057C23.5482 29.3741 23.6429 29.2794 23.6745 29.1846Z" fill="#0074BD"> </path> <path d="M19.2206 0.25293C19.2206 0.25293 23.3266 4.35891 15.3357 10.6758C8.92404 15.7293 13.8828 18.6351 15.3357 21.9199C11.6087 18.5403 8.86088 15.5714 10.6928 12.792C13.3775 8.74919 20.863 6.79093 19.2206 0.25293Z" fill="#EA2D2E"> </path> <path d="M11.5455 39.6068C18.6521 40.049 29.5803 39.3541 29.833 35.9746C29.833 35.9746 29.3276 37.238 23.9583 38.2487C17.894 39.3858 10.4085 39.2594 5.95508 38.533C5.95508 38.5646 6.87103 39.3225 11.5455 39.6068Z" fill="#0074BD"> </path> </svg> <span> Java Sync </span> </a> <a class="leafygreen-ui-v22cck" href="https://www.mongodb.com/docs/drivers/node/current/usage-examples/count/" target="_self"> <svg class="leafygreen-ui-x3zji3" fill="none" height="24" viewbox="0 0 30 30" width="24" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:R2dtlqcmqn9:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":R2dtlqcmqn9:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":R2dtlqcmqn9:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":R2dtlqcmqn9:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <span> Node.js </span> </a> <a class="leafygreen-ui-v22cck" href="https://www.mongodb.com/docs/languages/python/pymongo-driver/current/read/count/" target="_self"> <svg class="leafygreen-ui-x3zji3" height="24" viewbox="0 0 111.6 147" width="24" xmlns="http://www.w3.org/2000/svg"> <lineargradient gradienttransform="matrix(.5625 0 0 -.568 -160.323 -146.09)" gradientunits="userSpaceOnUse" id=":R2htlqcmqn9:aa" x1="280.848" x2="389.865" y1="-268.463" y2="-362.257"> <stop offset="0" stop-color="#5a9fd4"> </stop> <stop offset="1" stop-color="#306998"> </stop> </lineargradient> <path d="M55.3 3.2c-4.6 0-9 .4-12.8 1.1-11.3 2-13.4 6.2-13.4 13.9v10.2h26.8v3.4H19c-7.8 0-14.6 4.7-16.8 13.6C-.3 55.6-.4 62 2.2 72.7c1.9 7.9 6.5 13.6 14.2 13.6h9.2V74c0-8.8 7.7-16.7 16.7-16.7h26.8c7.5 0 13.4-6.1 13.4-13.6V18.2c0-7.3-6.1-12.7-13.4-13.9-4.4-.8-9.2-1.1-13.8-1.1zm-14.5 8.2c2.8 0 5 2.3 5 5.1s-2.3 5.1-5 5.1c-2.8 0-5-2.3-5-5.1s2.2-5.1 5-5.1z" fill="url(#:R2htlqcmqn9:aa)"> </path> <lineargradient gradienttransform="matrix(.5625 0 0 -.568 -160.323 -146.09)" gradientunits="userSpaceOnUse" id=":R2htlqcmqn9:bb" x1="432.011" x2="393.081" y1="-419.025" y2="-363.946"> <stop offset="0" stop-color="#ffd43b"> </stop> <stop offset="1" stop-color="#ffe873"> </stop> </lineargradient> <path d="M86 31.8v11.9c0 9.2-7.8 17-16.8 17H42.5c-7.3 0-13.4 6.3-13.4 13.6v25.5c0 7.3 6.3 11.5 13.4 13.6 8.5 2.5 16.6 2.9 26.8 0 6.8-2 13.4-5.9 13.4-13.6V89.7H55.9v-3.4h40.2c7.8 0 10.7-5.4 13.4-13.6 2.8-8.4 2.7-16.5 0-27.3-1.9-7.8-5.6-13.6-13.4-13.6H86zM71 96.5c2.8 0 5 2.3 5 5.1s-2.3 5.1-5 5.1c-2.8 0-5-2.3-5-5.1-.1-2.8 2.2-5.1 5-5.1z" fill="url(#:R2htlqcmqn9:bb)"> </path> <radialgradient cx="-2274.721" cy="144.526" gradienttransform="matrix(0 -.2399 -1.0547 0 208.637 -414.922)" gradientunits="userSpaceOnUse" id=":R2htlqcmqn9:cc" r="29.037"> <stop offset="0" stop-color="#b8b8b8" stop-opacity=".498"> </stop> <stop offset="1" stop-color="#7f7f7f" stop-opacity="0"> </stop> </radialgradient> <path d="M92.1 130.9c0 3.8-16.1 7-35.9 7s-35.9-3.1-35.9-7c0-3.8 16.1-7 35.9-7s35.9 3.1 35.9 7z" fill="url(#:R2htlqcmqn9:cc)" opacity=".444"> </path> </svg> <span> PyMongo </span> </a> <a class="leafygreen-ui-18cpm0b" href="https://www.mongodb.com/docs/languages/c/c-driver/current/libmongoc/tutorial/#counting-documents" target="_self"> <svg class="leafygreen-ui-x3zji3" fill="none" height="24" viewbox="0 0 28 29" width="24" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_1351_59955)"> <g clip-path="url(#clip1_1351_59955)"> <path clip-rule="evenodd" d="M13.118 1.49532C13.5403 1.25103 14.0559 1.25103 14.4783 1.49532C16.5652 2.70389 22.8385 6.34889 24.9193 7.55748C25.3416 7.80172 25.6025 8.25176 25.6025 8.74672C25.6025 11.1703 25.6025 18.4539 25.6025 20.8774C25.6025 21.366 25.3416 21.8224 24.9193 22.0667C22.8385 23.2753 16.5652 26.9203 14.4783 28.1289C14.0559 28.3732 13.5403 28.3732 13.118 28.1289C11.0373 26.9139 4.76398 23.2689 2.68323 22.0603C2.26087 21.816 2 21.366 2 20.871C2 18.4474 2 11.1639 2 8.7403C2 8.25176 2.26087 7.7953 2.68323 7.55106C4.76398 6.34889 11.0373 2.70389 13.118 1.49532Z" fill="#004482" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M2.18634 21.4946C2.01863 21.2632 2 21.051 2 20.7553C2 18.351 2 11.1061 2 8.70176C2 8.21317 2.26087 7.76319 2.67702 7.51889C4.75776 6.31675 11.0062 2.69104 13.0807 1.4889C13.5031 1.24461 14.0683 1.25104 14.4907 1.49533C16.5652 2.69747 22.795 6.29104 24.8696 7.49319C25.0373 7.58963 25.1677 7.70535 25.2795 7.86606L2.18634 21.4946Z" fill="#659AD2" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M13.8011 5.8089C18.6024 5.8089 22.4968 9.83964 22.4968 14.8089C22.4968 19.7782 18.6024 23.8089 13.8011 23.8089C8.99986 23.8089 5.10547 19.7782 5.10547 14.8089C5.10547 9.83964 8.99986 5.8089 13.8011 5.8089ZM13.8011 10.3089C16.1987 10.3089 18.1489 12.3275 18.1489 14.8089C18.1489 17.2903 16.1987 19.3089 13.8011 19.3089C11.4036 19.3089 9.4533 17.2903 9.4533 14.8089C9.4533 12.3275 11.4036 10.3089 13.8011 10.3089Z" fill="white" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M25.2857 7.87247C25.6087 8.18102 25.6025 8.65034 25.6025 9.01673C25.6025 11.4596 25.5839 18.396 25.6087 20.8325C25.6087 21.0896 25.528 21.3532 25.4099 21.5589L13.5466 14.8089L25.2857 7.87247Z" fill="#00599C" fill-rule="evenodd"> </path> </g> </g> <defs> <clippath id="clip0_1351_59955"> <rect fill="white" height="28" transform="translate(0 0.809265)" width="28"> </rect> </clippath> <clippath id="clip1_1351_59955"> <rect fill="white" height="27" transform="translate(2 1.30887)" width="24"> </rect> </clippath> </defs> </svg> <span> C </span> </a> <a class="leafygreen-ui-18cpm0b" href="https://mongocxx.org/api/current/classmongocxx_1_1v__noabi_1_1collection.html#a03c8eb29bfc93cecaefc0ef9773fced7" target="_self"> <svg class="leafygreen-ui-x3zji3" fill="none" height="24" viewbox="0 0 28 29" width="24" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_1351_59959)"> <g clip-path="url(#clip1_1351_59959)"> <path d="M25.4013 21.5646C25.5872 21.2353 25.7034 20.8745 25.7034 20.5373V9.08012C25.7034 8.75078 25.5872 8.38217 25.4013 8.05283L13.8516 14.8127L25.4013 21.5646Z" fill="#00599C"> </path> <path d="M14.8738 28.0657L24.6729 22.3411C24.9517 22.1764 25.2151 21.8941 25.401 21.5647L13.8513 14.8127L2.30151 21.5647C2.48743 21.8941 2.74305 22.1764 3.02967 22.3411L12.8288 28.0657C13.3865 28.3951 14.316 28.3951 14.8738 28.0657Z" fill="#004482"> </path> <path d="M25.4011 8.06086C25.2152 7.73146 24.9596 7.44915 24.673 7.2845L14.8739 1.55983C14.3084 1.23046 13.3866 1.23046 12.8211 1.55983L3.02202 7.2845C2.46429 7.61385 1.99951 8.42158 1.99951 9.08033V20.5375C1.99951 20.8669 2.11571 21.2354 2.30162 21.5647L13.8514 14.8128L25.4011 8.06086Z" fill="#659AD2"> </path> <path d="M13.8512 22.8115C9.49778 22.8115 5.94995 19.2199 5.94995 14.8127C5.94995 10.4055 9.49778 6.81387 13.8512 6.81387C16.6631 6.81387 19.2813 8.34305 20.6912 10.8133L17.2751 12.813C16.5701 11.5818 15.261 10.8133 13.8512 10.8133C11.6745 10.8133 9.90055 12.6091 9.90055 14.8127C9.90055 17.0163 11.6745 18.8121 13.8512 18.8121C15.261 18.8121 16.5701 18.0436 17.2751 16.8124L20.6912 18.8121C19.2813 21.2745 16.6631 22.8115 13.8512 22.8115Z" fill="white"> </path> <path d="M21.7524 14.3657H20.8771V13.4796H19.994V14.3657H19.1187V15.2518H19.994V16.1458H20.8771V15.2518H21.7524V14.3657Z" fill="white"> </path> <path d="M25.0446 14.3657H24.1693V13.4796H23.2862V14.3657H22.4109V15.2518H23.2862V16.1458H24.1693V15.2518H25.0446V14.3657Z" fill="white"> </path> </g> </g> <defs> <clippath id="clip0_1351_59959"> <rect fill="white" height="28" transform="translate(0 0.809265)" width="28"> </rect> </clippath> <clippath id="clip1_1351_59959"> <rect fill="white" height="27" transform="translate(1.99951 1.30878)" width="24"> </rect> </clippath> </defs> </svg> <span> C++ </span> </a> <a class="leafygreen-ui-18cpm0b" href="https://www.mongodb.com/docs/drivers/go/current/fundamentals/crud/read-operations/count/" target="_self"> <svg class="leafygreen-ui-x3zji3" height="24" id="Layer_1" style="fill:#00ACD7" version="1.1" viewbox="0 0 205.4 76.7" width="24" x="0" xmlns="http://www.w3.org/2000/svg" y="0"> <path class="st00" d="M15.5 23.2c-.4 0-.5-.2-.3-.5l2.1-2.7c.2-.3.7-.5 1.1-.5h35.7c.4 0 .5.3.3.6l-1.7 2.6c-.2.3-.7.6-1 .6l-36.2-.1zM.4 32.4c-.4 0-.5-.2-.3-.5l2.1-2.7c.2-.3.7-.5 1.1-.5h45.6c.4 0 .6.3.5.6l-.8 2.4c-.1.4-.5.6-.9.6l-47.3.1zM24.6 41.6c-.4 0-.5-.3-.3-.6l1.4-2.5c.2-.3.6-.6 1-.6h20c.4 0 .6.3.6.7l-.2 2.4c0 .4-.4.7-.7.7l-21.8-.1z"> </path> <g id="CXHf1q_3_"> <path class="st00" d="M128.4 21.4c-6.3 1.6-10.6 2.8-16.8 4.4-1.5.4-1.6.5-2.9-1-1.5-1.7-2.6-2.8-4.7-3.8-6.3-3.1-12.4-2.2-18.1 1.5-6.8 4.4-10.3 10.9-10.2 19 .1 8 5.6 14.6 13.5 15.7 6.8.9 12.5-1.5 17-6.6.9-1.1 1.7-2.3 2.7-3.7H89.6c-2.1 0-2.6-1.3-1.9-3 1.3-3.1 3.7-8.3 5.1-10.9.3-.6 1-1.6 2.5-1.6h36.4c-.2 2.7-.2 5.4-.6 8.1-1.1 7.2-3.8 13.8-8.2 19.6-7.2 9.5-16.6 15.4-28.5 17-9.8 1.3-18.9-.6-26.9-6.6-7.4-5.6-11.6-13-12.7-22.2-1.3-10.9 1.9-20.7 8.5-29.3C70.4 8.7 79.8 2.8 91.3.7c9.4-1.7 18.4-.6 26.5 4.9 5.3 3.5 9.1 8.3 11.6 14.1.6.9.2 1.4-1 1.7z"> </path> <path class="st00" d="M161.5 76.7c-9.1-.2-17.4-2.8-24.4-8.8-5.9-5.1-9.6-11.6-10.8-19.3-1.8-11.3 1.3-21.3 8.1-30.2 7.3-9.6 16.1-14.6 28-16.7 10.2-1.8 19.8-.8 28.5 5.1 7.9 5.4 12.8 12.7 14.1 22.3 1.7 13.5-2.2 24.5-11.5 33.9-6.6 6.7-14.7 10.9-24 12.8-2.7.5-5.4.6-8 .9zm23.8-40.4c-.1-1.3-.1-2.3-.3-3.3-1.8-9.9-10.9-15.5-20.4-13.3-9.3 2.1-15.3 8-17.5 17.4-1.8 7.8 2 15.7 9.2 18.9 5.5 2.4 11 2.1 16.3-.6 7.9-4.1 12.2-10.5 12.7-19.1z"> </path> </g> </svg> <span> Go </span> </a> <a class="leafygreen-ui-18cpm0b" href="https://www.mongodb.com/docs/languages/java/reactive-streams-driver/current/read/count-documents/" target="_self"> <svg class="leafygreen-ui-x3zji3" fill="none" height="24" viewbox="0 0 30 41" width="24" xmlns="http://www.w3.org/2000/svg"> <path d="M10.0921 30.7949C10.0921 30.7949 8.57608 31.6793 11.166 31.9636C14.2929 32.311 15.9037 32.2794 19.3464 31.6161C19.3464 31.6161 20.2623 32.1846 21.5257 32.6901C13.7876 35.9748 4.02791 32.5005 10.0921 30.7949Z" fill="#0074BD"> </path> <path d="M9.14539 26.4678C9.14539 26.4678 7.43985 27.7312 10.0298 27.9838C13.3778 28.3312 15.9992 28.3628 20.579 27.4785C20.579 27.4785 21.2107 28.1101 22.1898 28.4576C12.8724 31.2054 2.44949 28.6787 9.14539 26.4678Z" fill="#0074BD"> </path> <path d="M17.1039 19.1398C18.9989 21.3191 16.5985 23.3089 16.5985 23.3089C16.5985 23.3089 21.431 20.8138 19.2201 17.6869C17.1355 14.7811 15.5563 13.3282 24.1788 8.33789C24.1473 8.33789 10.6607 11.6858 17.1039 19.1398Z" fill="#EA2D2E"> </path> <path d="M27.3377 33.9845C27.3377 33.9845 28.4431 34.9004 26.1059 35.6269C21.6525 36.985 7.53417 37.3957 3.61769 35.6901C2.19639 35.0899 4.84949 34.2372 5.67069 34.0477C6.52347 33.8582 7.02884 33.8898 7.02884 33.8898C5.44961 32.7843 -3.10981 36.0691 2.67016 36.9851C18.4308 39.5433 31.4121 35.8164 27.3377 33.9845Z" fill="#0074BD"> </path> <path d="M10.8194 21.983C10.8194 21.983 3.6497 23.6885 8.2926 24.3203C10.2509 24.5729 14.1357 24.5097 17.7995 24.2255C20.7685 23.9728 23.7375 23.4359 23.7375 23.4359C23.7375 23.4359 22.6951 23.8781 21.9372 24.415C14.6411 26.3416 0.585992 25.4257 4.62881 23.4675C8.00839 21.7935 10.8194 21.983 10.8194 21.983Z" fill="#0074BD"> </path> <path d="M23.6745 29.1846C31.0969 25.3313 27.6542 21.6359 25.2538 22.1413C24.6537 22.2676 24.401 22.3623 24.401 22.3623C24.401 22.3623 24.6221 22.0149 25.0327 21.8886C29.7703 20.2146 33.4025 26.7842 23.5166 29.4057C23.5482 29.3741 23.6429 29.2794 23.6745 29.1846Z" fill="#0074BD"> </path> <path d="M19.2206 0.25293C19.2206 0.25293 23.3266 4.35891 15.3357 10.6758C8.92404 15.7293 13.8828 18.6351 15.3357 21.9199C11.6087 18.5403 8.86088 15.5714 10.6928 12.792C13.3775 8.74919 20.863 6.79093 19.2206 0.25293Z" fill="#EA2D2E"> </path> <path d="M11.5455 39.6068C18.6521 40.049 29.5803 39.3541 29.833 35.9746C29.833 35.9746 29.3276 37.238 23.9583 38.2487C17.894 39.3858 10.4085 39.2594 5.95508 38.533C5.95508 38.5646 6.87103 39.3225 11.5455 39.6068Z" fill="#0074BD"> </path> </svg> <span> Java RS </span> </a> <a class="leafygreen-ui-18cpm0b" href="https://www.mongodb.com/docs/drivers/kotlin/coroutine/current/usage-examples/count/" target="_self"> <svg class="leafygreen-ui-x3zji3" fill="none" height="24" viewbox="0 0 28 29" width="24" xmlns="http://www.w3.org/2000/svg"> <path d="M28 29H0V1H28L14 15L28 29Z" fill="url(#:R35tlqcmqn9:paint0_linear_211_40588)"> </path> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":R35tlqcmqn9:paint0_linear_211_40588" x1="28" x2="8.34465e-07" y1="0.999999" y2="29"> <stop offset="0.00343514" stop-color="#E44857"> </stop> <stop offset="0.4689" stop-color="#C711E1"> </stop> <stop offset="1" stop-color="#7F52FF"> </stop> </lineargradient> </defs> </svg> <span> Kotlin Coroutine </span> </a> <a class="leafygreen-ui-18cpm0b" href="https://www.mongodb.com/docs/languages/kotlin/kotlin-sync-driver/current/read/count/" target="_self"> <svg class="leafygreen-ui-x3zji3" fill="none" height="24" viewbox="0 0 28 29" width="24" xmlns="http://www.w3.org/2000/svg"> <path d="M28 29H0V1H28L14 15L28 29Z" fill="url(#:R39tlqcmqn9:paint0_linear_211_40588)"> </path> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":R39tlqcmqn9:paint0_linear_211_40588" x1="28" x2="8.34465e-07" y1="0.999999" y2="29"> <stop offset="0.00343514" stop-color="#E44857"> </stop> <stop offset="0.4689" stop-color="#C711E1"> </stop> <stop offset="1" stop-color="#7F52FF"> </stop> </lineargradient> </defs> </svg> <span> Kotlin Sync </span> </a> <a class="leafygreen-ui-18cpm0b" href="https://www.mongodb.com/docs/php-library/current/reference/method/MongoDBCollection-countDocuments/" target="_self"> <svg class="leafygreen-ui-x3zji3" height="24" viewbox="0 0 700 301" width="24" x="0" xmlns="http://www.w3.org/2000/svg" y="0"> <defs> <clippath clippathunits="userSpaceOnUse" id="a"> <path d="M11.52 162C11.52 81.677 135.307 16.561 288 16.561S564.481 81.677 564.481 162c0 80.322-123.788 145.439-276.481 145.439-152.693 0-276.48-65.117-276.48-145.439"> </path> </clippath> <clippath clippathunits="userSpaceOnUse" id="c"> <path d="M0 324h576V0H0v324z"> </path> </clippath> <clippath clippathunits="userSpaceOnUse" id="d"> <path d="M0 324h576V0H0v324z"> </path> </clippath> <radialgradient cx="0" cy="0" fx="0" fy="0" gradienttransform="matrix(363.05789 0 0 -363.05789 177.52 256.307)" gradientunits="userSpaceOnUse" id="b" r="1" spreadmethod="pad"> <stop offset="0" stop-color="#aeb2d5"> </stop> <stop offset=".3" stop-color="#aeb2d5"> </stop> <stop offset=".75" stop-color="#484c89"> </stop> <stop offset="1" stop-color="#484c89"> </stop> </radialgradient> </defs> <g clip-path="url(#a)" transform="matrix(1.25 0 0 -1.25 -4.4 394.299)"> <path d="M11.52 162C11.52 81.677 135.307 16.561 288 16.561S564.481 81.677 564.481 162c0 80.322-123.788 145.439-276.481 145.439-152.693 0-276.48-65.117-276.48-145.439" fill="url(#b)"> </path> </g> <g clip-path="url(#c)" transform="matrix(1.25 0 0 -1.25 -4.4 394.299)"> <path d="M288 27.36c146.729 0 265.68 60.28 265.68 134.64 0 74.36-118.951 134.641-265.68 134.641S22.32 236.36 22.32 162.001C22.32 87.64 141.271 27.358 288 27.358" fill="#777bb3"> </path> </g> <g clip-path="url(#d)" transform="matrix(1.25 0 0 -1.25 -4.4 394.299)"> <path d="M161.734 145.307c12.065 0 21.072 2.225 26.771 6.61 5.638 4.342 9.532 11.863 11.573 22.354 1.903 9.806 1.178 16.653-2.154 20.348-3.407 3.774-10.773 5.688-21.893 5.688h-19.28l-10.69-55h15.673zm-63.063-67.75a2.998 2.998 0 00-2.944 3.572l28.328 145.75a3 3 0 002.945 2.428h61.054c19.188 0 33.47-5.21 42.447-15.487 9.025-10.331 11.812-24.772 8.283-42.921-1.436-7.394-3.906-14.261-7.34-20.41-3.44-6.154-7.985-11.85-13.512-16.93-6.616-6.191-14.104-10.681-22.236-13.323-8.003-2.607-18.28-3.93-30.548-3.93h-24.722l-7.06-36.321a3 3 0 00-2.944-2.428h-31.75z"> </path> <path d="M159.224 197.307h16.808c13.42 0 18.083-2.945 19.667-4.7 2.628-2.914 3.124-9.058 1.435-17.767-1.898-9.75-5.416-16.663-10.458-20.545-5.162-3.974-13.554-5.988-24.941-5.988H149.7l9.523 49zm28.83 35H127a6 6 0 01-5.89-4.855L92.784 81.702a6 6 0 015.889-7.144h31.75a6 6 0 015.89 4.854l6.588 33.895h22.249c12.582 0 23.174 1.372 31.479 4.077 8.54 2.775 16.399 7.48 23.354 13.984 5.752 5.292 10.49 11.232 14.08 17.657 3.59 6.427 6.17 13.594 7.668 21.302 3.715 19.104.697 34.402-8.97 45.466-9.571 10.958-24.613 16.514-44.705 16.514m-45.633-90h19.313c12.8 0 22.336 2.411 28.6 7.234 6.267 4.824 10.493 12.875 12.689 24.157 2.1 10.832 1.144 18.476-2.871 22.93-4.02 4.452-12.06 6.68-24.121 6.68h-21.754l-11.856-61m45.633 84c18.367 0 31.766-4.82 40.188-14.462 8.42-9.64 10.957-23.098 7.597-40.375-1.383-7.117-3.722-13.624-7.015-19.519-3.297-5.899-7.602-11.293-12.922-16.184-6.34-5.933-13.383-10.16-21.133-12.679-7.75-2.525-17.621-3.782-29.621-3.782h-27.196l-7.531-38.75h-31.75L127 226.307h61.055" fill="#fff"> </path> <path d="M311.583 116.307c-.896 0-1.745.4-2.314 1.092a2.994 2.994 0 00-.631 2.48l12.531 64.489c1.192 6.133.898 10.535-.827 12.395-1.056 1.137-4.228 3.044-13.607 3.044h-22.702l-15.755-81.072a3 3 0 00-2.945-2.428h-31.5a2.998 2.998 0 00-2.945 3.572l28.328 145.75a3 3 0 002.945 2.428h31.5a3 3 0 002.945-3.572l-6.836-35.178h24.422c18.605 0 31.221-3.28 38.569-10.028 7.49-6.884 9.827-17.891 6.947-32.72l-13.18-67.824a3 3 0 00-2.945-2.428h-32z"> </path> <path d="M293.661 271.057h-31.5a6 6 0 01-5.89-4.855l-28.328-145.75a5.998 5.998 0 015.89-7.145h31.5a6 6 0 015.89 4.855l15.283 78.645h20.23c9.362 0 11.327-2 11.406-2.086.568-.61 1.315-3.44.082-9.78l-12.53-64.49a5.998 5.998 0 015.89-7.144h32a6 6 0 015.89 4.855l13.178 67.825c3.093 15.921.447 27.864-7.86 35.5-7.929 7.281-21.209 10.82-40.6 10.82h-20.784l6.143 31.605a6.001 6.001 0 01-5.89 7.145m0-6l-7.53-38.75h28.061c17.657 0 29.836-3.082 36.54-9.238 6.702-6.16 8.71-16.14 6.031-29.938l-13.18-67.824h-32l12.531 64.488c1.426 7.336.902 12.34-1.574 15.008-2.477 2.668-7.746 4.004-15.805 4.004H281.56l-16.226-83.5h-31.5l28.328 145.75h31.5" fill="#fff"> </path> <path d="M409.55 145.307c12.065 0 21.072 2.225 26.77 6.61 5.639 4.34 9.533 11.862 11.575 22.354 1.903 9.806 1.178 16.653-2.155 20.348-3.407 3.774-10.773 5.688-21.893 5.688h-19.281l-10.69-55h15.674zm-63.062-67.75a2.999 2.999 0 00-2.945 3.572l28.328 145.75a3.002 3.002 0 002.946 2.428h61.053c19.189 0 33.47-5.21 42.448-15.487 9.025-10.33 11.81-24.771 8.283-42.921-1.438-7.394-3.907-14.261-7.342-20.41-3.44-6.154-7.984-11.85-13.511-16.93-6.616-6.191-14.104-10.681-22.236-13.323-8.003-2.607-18.281-3.93-30.548-3.93H388.24l-7.057-36.321a3.001 3.001 0 00-2.946-2.428h-31.75z"> </path> <path d="M407.04 197.307h16.807c13.421 0 18.083-2.945 19.667-4.7 2.63-2.914 3.125-9.058 1.435-17.766-1.898-9.75-5.417-16.664-10.458-20.546-5.162-3.974-13.554-5.988-24.94-5.988h-12.034l9.522 49zm28.83 35h-61.054a6 6 0 01-5.889-4.855L340.6 81.702a6 6 0 015.889-7.144h31.75a6 6 0 015.89 4.854l6.587 33.895h22.25c12.581 0 23.173 1.372 31.478 4.077 8.541 2.775 16.401 7.481 23.356 13.986 5.752 5.291 10.488 11.23 14.078 17.655 3.591 6.427 6.171 13.594 7.668 21.302 3.715 19.105.697 34.403-8.969 45.467-9.572 10.957-24.613 16.513-44.706 16.513m-45.632-90h19.312c12.801 0 22.336 2.411 28.601 7.234 6.267 4.824 10.492 12.875 12.688 24.157 2.102 10.832 1.145 18.476-2.87 22.93-4.02 4.452-12.06 6.68-24.122 6.68h-21.754l-11.855-61m45.632 84c18.367 0 31.766-4.82 40.188-14.462 8.422-9.64 10.957-23.098 7.597-40.375-1.383-7.117-3.722-13.624-7.015-19.519-3.297-5.899-7.602-11.293-12.922-16.184-6.34-5.933-13.383-10.16-21.133-12.679-7.75-2.525-17.62-3.782-29.62-3.782h-27.197l-7.53-38.75h-31.75l28.328 145.75h61.054" fill="#fff"> </path> </g> </svg> <span> PHP </span> </a> <a class="leafygreen-ui-18cpm0b" href="https://motor.readthedocs.io/en/stable/api-tornado/motor_collection.html#motor.motor_tornado.MotorCollection.count_documents" target="_self"> <svg class="leafygreen-ui-x3zji3" height="24" viewbox="0 0 111.6 147" width="24" xmlns="http://www.w3.org/2000/svg"> <lineargradient gradienttransform="matrix(.5625 0 0 -.568 -160.323 -146.09)" gradientunits="userSpaceOnUse" id=":R3htlqcmqn9:aa" x1="280.848" x2="389.865" y1="-268.463" y2="-362.257"> <stop offset="0" stop-color="#5a9fd4"> </stop> <stop offset="1" stop-color="#306998"> </stop> </lineargradient> <path d="M55.3 3.2c-4.6 0-9 .4-12.8 1.1-11.3 2-13.4 6.2-13.4 13.9v10.2h26.8v3.4H19c-7.8 0-14.6 4.7-16.8 13.6C-.3 55.6-.4 62 2.2 72.7c1.9 7.9 6.5 13.6 14.2 13.6h9.2V74c0-8.8 7.7-16.7 16.7-16.7h26.8c7.5 0 13.4-6.1 13.4-13.6V18.2c0-7.3-6.1-12.7-13.4-13.9-4.4-.8-9.2-1.1-13.8-1.1zm-14.5 8.2c2.8 0 5 2.3 5 5.1s-2.3 5.1-5 5.1c-2.8 0-5-2.3-5-5.1s2.2-5.1 5-5.1z" fill="url(#:R3htlqcmqn9:aa)"> </path> <lineargradient gradienttransform="matrix(.5625 0 0 -.568 -160.323 -146.09)" gradientunits="userSpaceOnUse" id=":R3htlqcmqn9:bb" x1="432.011" x2="393.081" y1="-419.025" y2="-363.946"> <stop offset="0" stop-color="#ffd43b"> </stop> <stop offset="1" stop-color="#ffe873"> </stop> </lineargradient> <path d="M86 31.8v11.9c0 9.2-7.8 17-16.8 17H42.5c-7.3 0-13.4 6.3-13.4 13.6v25.5c0 7.3 6.3 11.5 13.4 13.6 8.5 2.5 16.6 2.9 26.8 0 6.8-2 13.4-5.9 13.4-13.6V89.7H55.9v-3.4h40.2c7.8 0 10.7-5.4 13.4-13.6 2.8-8.4 2.7-16.5 0-27.3-1.9-7.8-5.6-13.6-13.4-13.6H86zM71 96.5c2.8 0 5 2.3 5 5.1s-2.3 5.1-5 5.1c-2.8 0-5-2.3-5-5.1-.1-2.8 2.2-5.1 5-5.1z" fill="url(#:R3htlqcmqn9:bb)"> </path> <radialgradient cx="-2274.721" cy="144.526" gradienttransform="matrix(0 -.2399 -1.0547 0 208.637 -414.922)" gradientunits="userSpaceOnUse" id=":R3htlqcmqn9:cc" r="29.037"> <stop offset="0" stop-color="#b8b8b8" stop-opacity=".498"> </stop> <stop offset="1" stop-color="#7f7f7f" stop-opacity="0"> </stop> </radialgradient> <path d="M92.1 130.9c0 3.8-16.1 7-35.9 7s-35.9-3.1-35.9-7c0-3.8 16.1-7 35.9-7s35.9 3.1 35.9 7z" fill="url(#:R3htlqcmqn9:cc)" opacity=".444"> </path> </svg> <span> Motor </span> </a> <a class="leafygreen-ui-18cpm0b" href="https://www.mongodb.com/docs/drivers/rust/current/usage-examples/count/" target="_self"> <svg class="leafygreen-ui-x3zji3" height="24" viewbox="0 0 30 30" width="24" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_5454_14623)"> <path d="M15.2561 3.08398C8.56014 3.08398 3.11035 8.53634 3.11035 15.2297C3.11035 21.9231 8.56271 27.3755 15.2561 27.3755C21.9495 27.3755 27.4019 21.9231 27.4019 15.2297C27.4019 8.53634 21.9495 3.08398 15.2561 3.08398ZM15.2381 4.16315C15.4458 4.16853 15.6432 4.25509 15.7881 4.40437C15.9331 4.55365 16.0142 4.75384 16.0141 4.96225C16.0141 5.17418 15.9299 5.37744 15.7801 5.5273C15.6302 5.67715 15.4269 5.76134 15.215 5.76134C15.0031 5.76134 14.7998 5.67715 14.65 5.5273C14.5001 5.37744 14.4159 5.17418 14.4159 4.96225C14.4159 4.85533 14.4373 4.7495 14.4789 4.65101C14.5205 4.55252 14.5814 4.46338 14.6581 4.38887C14.7347 4.31435 14.8256 4.25598 14.9252 4.21721C15.0249 4.17844 15.1313 4.16006 15.2381 4.16315ZM17.0676 5.47871C18.4704 5.74146 19.7992 6.30644 20.9617 7.13439C22.1242 7.96235 23.0926 9.03345 23.7995 10.2733L22.8565 12.4008C22.6947 12.7682 22.8617 13.1999 23.2265 13.3643L25.0406 14.1686C25.0968 14.7356 25.1037 15.3065 25.0611 15.8747H24.0513C23.9511 15.8747 23.91 15.9415 23.91 16.0391V16.5016C23.91 17.5911 23.2959 17.83 22.7563 17.8891C22.2424 17.9482 21.6746 17.6733 21.6026 17.3598C21.2994 15.6563 20.7958 15.294 19.9993 14.6645C20.9885 14.0375 22.0163 13.11 22.0163 11.8715C22.0163 10.5328 21.099 9.69002 20.4747 9.27634C19.5959 8.69822 18.6247 8.5826 18.3626 8.5826H7.93063C9.37312 6.97114 11.3066 5.88021 13.4318 5.47871L14.6626 6.76857C14.9401 7.05891 15.4 7.07176 15.6903 6.79169L17.0676 5.47871ZM5.71063 11.3936C5.91853 11.3996 6.11589 11.4864 6.26079 11.6356C6.40568 11.7849 6.48669 11.9847 6.4866 12.1927C6.4866 12.4046 6.40241 12.6079 6.25255 12.7577C6.10269 12.9076 5.89944 12.9918 5.6875 12.9918C5.47557 12.9918 5.27232 12.9076 5.12246 12.7577C4.9726 12.6079 4.88841 12.4046 4.88841 12.1927C4.88836 12.0858 4.90977 11.9799 4.95137 11.8814C4.99297 11.7829 5.0539 11.6938 5.13057 11.6193C5.20724 11.5448 5.29809 11.4864 5.39772 11.4476C5.49736 11.4089 5.60376 11.3905 5.71063 11.3936ZM24.7631 11.4295C24.971 11.4356 25.1683 11.5224 25.3132 11.6716C25.4581 11.8208 25.5391 12.0206 25.539 12.2286C25.539 12.4406 25.4548 12.6438 25.305 12.7937C25.1551 12.9435 24.9519 13.0277 24.7399 13.0277C24.528 13.0277 24.3247 12.9435 24.1749 12.7937C24.025 12.6438 23.9408 12.4406 23.9408 12.2286C23.9408 12.1217 23.9622 12.0159 24.0038 11.9174C24.0454 11.8189 24.1063 11.7298 24.183 11.6553C24.2597 11.5807 24.3505 11.5224 24.4502 11.4836C24.5498 11.4448 24.6562 11.4264 24.7631 11.4295ZM7.21632 11.558H8.60896V17.8377H5.79799C5.45083 16.6186 5.34264 15.3439 5.47938 14.0838L7.20091 13.3181C7.56834 13.1536 7.73535 12.7245 7.57091 12.3571L7.21632 11.558ZM13.0284 11.6248H16.3456C16.5177 11.6248 17.5558 11.8227 17.5558 12.6012C17.5558 13.2461 16.7592 13.4774 16.104 13.4774H13.0258L13.0284 11.6248ZM13.0284 16.1368H15.5696C15.8008 16.1368 16.8106 16.2036 17.1318 17.4934C17.232 17.8891 17.4556 19.179 17.6072 19.5927C17.7588 20.0552 18.3729 20.9802 19.0281 20.9802H23.1751C22.8972 21.3524 22.5933 21.7044 22.2656 22.0336L20.5774 21.6713C20.1843 21.5866 19.7963 21.8384 19.7115 22.2315L19.3107 24.102C18.0217 24.6859 16.622 24.9848 15.2069 24.9781C13.7919 24.9714 12.395 24.6595 11.1116 24.0635L10.7108 22.1929C10.626 21.7998 10.2406 21.548 9.84743 21.6328L8.19528 21.9874C7.88869 21.6711 7.6037 21.3346 7.34223 20.9802H15.3769C15.4668 20.9802 15.5285 20.9647 15.5285 20.88V18.0381C15.5285 17.9559 15.4668 17.9379 15.3769 17.9379H13.0258L13.0284 16.1368ZM9.3207 22.6452C9.5286 22.6512 9.72596 22.738 9.87085 22.8872C10.0157 23.0364 10.0968 23.2363 10.0967 23.4443C10.0967 23.6562 10.0125 23.8594 9.86262 24.0093C9.71276 24.1592 9.50951 24.2434 9.29757 24.2434C9.08564 24.2434 8.88239 24.1592 8.73253 24.0093C8.58267 23.8594 8.49848 23.6562 8.49848 23.4443C8.49843 23.3373 8.51984 23.2315 8.56144 23.133C8.60303 23.0345 8.66397 22.9454 8.74064 22.8709C8.81731 22.7964 8.90815 22.738 9.00779 22.6992C9.10743 22.6605 9.21383 22.6421 9.3207 22.6452ZM21.153 22.6811C21.3609 22.6872 21.5583 22.774 21.7031 22.9232C21.848 23.0724 21.929 23.2722 21.929 23.4802C21.929 23.6922 21.8448 23.8954 21.6949 24.0453C21.5451 24.1951 21.3418 24.2793 21.1299 24.2793C20.9179 24.2793 20.7147 24.1951 20.5648 24.0453C20.415 23.8954 20.3308 23.6922 20.3308 23.4802C20.3307 23.3733 20.3521 23.2675 20.3937 23.169C20.4353 23.0705 20.4963 22.9814 20.5729 22.9068C20.6496 22.8323 20.7404 22.774 20.8401 22.7352C20.9397 22.6964 21.0461 22.678 21.153 22.6811Z" fill="black"> </path> <path clip-rule="evenodd" d="M26.7232 15.2304C26.7232 18.2717 25.515 21.1885 23.3645 23.3391C21.2139 25.4896 18.2971 26.6978 15.2558 26.6978C12.2144 26.6978 9.29761 25.4896 7.14705 23.3391C4.99649 21.1885 3.78832 18.2717 3.78832 15.2304C3.78832 12.189 4.99649 9.27222 7.14705 7.12166C9.29761 4.9711 12.2144 3.76293 15.2558 3.76293C18.2971 3.76293 21.2139 4.9711 23.3645 7.12166C25.515 9.27222 26.7232 12.189 26.7232 15.2304ZM26.5073 14.1229L28.2957 15.2304L26.5073 16.3378L28.0439 17.7741L26.0757 18.5115L27.3039 20.2202L25.2252 20.5594L26.0988 22.4762L23.9944 22.4017L24.4775 24.4521L22.4271 23.969L22.5016 26.0734L20.5848 25.1998L20.2456 27.2785L18.5369 26.0503L17.7995 28.0185L16.3632 26.482L15.2558 28.2703L14.1483 26.482L12.712 28.0185L11.9746 26.0503L10.2659 27.2785L9.92672 25.1998L8.00992 26.0734L8.08443 23.969L6.03401 24.4521L6.51707 22.4017L4.4127 22.4762L5.28631 20.5594L3.20763 20.2202L4.43582 18.5115L2.46763 17.7741L4.00415 16.3378L2.21582 15.2304L4.00415 14.1229L2.46763 12.6866L4.43582 11.9492L3.20763 10.2405L5.28631 9.90133L4.4127 7.98453L6.51707 8.05904L6.03401 6.00862L8.08443 6.49168L8.00992 4.3873L9.92672 5.26092L10.2659 3.18223L11.9746 4.41043L12.712 2.44224L14.1483 3.97876L15.2558 2.19043L16.3632 3.97876L17.7995 2.44224L18.5369 4.41043L20.2456 3.18223L20.5848 5.26092L22.5016 4.3873L22.4271 6.49168L24.4775 6.00862L23.9944 8.05904L26.0988 7.98453L25.2252 9.90133L27.3039 10.2405L26.0757 11.9492L28.0439 12.6866L26.5073 14.1229Z" fill="black" fill-rule="evenodd" stroke-linecap="round" stroke-linejoin="round"> </path> </g> <defs> <clippath id="clip0_5454_14623"> <rect fill="black" height="30" width="30"> </rect> </clippath> </defs> </svg> <span> Rust </span> </a> <a class="leafygreen-ui-18cpm0b" href="https://www.mongodb.com/docs/languages/scala/scala-driver/current/get-started/quickstart/#count-documents-in-a-collection" target="_self"> <svg class="leafygreen-ui-x3zji3" height="24" viewbox="0 0 70 70" width="24" xmlns="http://www.w3.org/2000/svg"> <defs> <lineargradient id=":R3ptlqcmqn9:aaa" x1=".006%" x2="96.837%" y1="49.998%" y2="49.998%"> <stop offset="0%" stop-color="#CD413F"> </stop> <stop offset="75.091%" stop-color="#CD4543"> </stop> <stop offset="100%" stop-color="#D04543"> </stop> </lineargradient> </defs> <g fill="none" fill-rule="nonzero"> <path d="M13 39v5c0 .843 17.73 2.255 29.28 5 5.582-1.327 9.72-2.966 9.72-5v-5c0-2.034-4.138-3.673-9.72-5C30.73 36.745 13 38.157 13 39M13 20v5c0 .843 17.73 2.255 29.28 5 5.582-1.327 9.72-2.966 9.72-5v-5c0-2.034-4.138-3.673-9.72-5C30.73 17.745 13 19.157 13 20" fill="#731818"> </path> <g fill="url(#:R3ptlqcmqn9:aaa)" transform="translate(13)"> <path d="M0 29.53v14.766c0-1.232 39-3.692 39-9.844V19.686c0 6.152-39 8.612-39 9.844M0 9.843V24.61c0-1.231 39-3.691 39-9.843V0C39 6.152 0 8.612 0 9.843M0 49.216v14.766c0-1.231 39-3.691 39-9.843V39.373c0 6.151-39 8.612-39 9.843"> </path> </g> </g> </svg> <span> Scala </span> </a> <a class="leafygreen-ui-18cpm0b" href="https://www.mongodb.com/docs/atlas/device-sdks/sdk/swift/app-services/mongodb-remote-access/#count-documents-in-the-collection" target="_self"> <svg class="leafygreen-ui-x3zji3" height="24" viewbox="-252 343.9 106.1 106.1" width="24" xmlns="http://www.w3.org/2000/svg"> <path d="M-145.9 373.3v-3.2c-.1-2.3-.2-4.7-.6-7-.4-2.3-1.1-4.5-2.2-6.6-1.1-2.1-2.4-4-4.1-5.6-1.7-1.7-3.6-3-5.6-4.1-2.1-1.1-4.3-1.8-6.6-2.2-2.3-.4-4.6-.6-7-.6h-53.7c-.6 0-1.2 0-1.7.1-1.7.1-3.5.2-5.2.5-1.7.3-3.4.8-5 1.4-.5.2-1.1.5-1.6.7-1.6.8-3 1.8-4.4 2.9-.4.4-.9.8-1.3 1.2-1.7 1.7-3 3.6-4.1 5.6-1.1 2.1-1.8 4.3-2.2 6.6-.4 2.3-.5 4.6-.6 7v53.7c.1 2.3.2 4.7.6 7 .4 2.3 1.1 4.5 2.2 6.6 1.1 2.1 2.4 4 4.1 5.6 1.7 1.7 3.6 3 5.6 4.1 2.1 1.1 4.3 1.8 6.6 2.2 2.3.4 4.6.6 7 .6h53.7c2.3-.1 4.7-.2 7-.6 2.3-.4 4.5-1.1 6.6-2.2 2.1-1.1 4-2.4 5.6-4.1 1.7-1.7 3-3.6 4.1-5.6 1.1-2.1 1.8-4.3 2.2-6.6.4-2.3.6-4.6.6-7v-3.2V377v-3.7z" fill="#F05138"> </path> <path d="M-168 409.4l.3-1.2c4.4-17.5-6.3-38.3-24.5-49.2 8 10.8 11.5 23.9 8.4 35.3-.3 1-.6 2-1 3-.4-.3-.9-.6-1.6-.9 0 0-18.1-11.2-37.7-30.9-.5-.5 10.5 15.7 22.9 28.8-5.9-3.3-22.2-15.2-32.6-24.6 1.3 2.1 2.8 4.2 4.4 6.1 8.6 11 19.9 24.5 33.4 34.9-9.5 5.8-22.9 6.3-36.2 0-3.3-1.5-6.4-3.4-9.3-5.5 5.6 9 14.3 16.8 24.9 21.4 12.6 5.4 25.2 5.1 34.5.1 0 0 .1 0 .1-.1.4-.2.8-.5 1.2-.7 4.5-2.3 13.3-4.6 18.1 4.6 1.4 2.1 3.9-9.9-5.3-21.1z" fill="#FFF"> </path> </svg> <span> Swift </span> </a> </div> <button class="leafygreen-ui-ki2t97"> Show all <svg aria-label="Chevron Down Icon" class="" fill="none" height="16" role="img" viewbox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M1.636 5.364a1 1 0 0 0 0 1.414l4.95 4.95.707.707a1 1 0 0 0 1.414 0l.707-.707 4.95-4.95a1 1 0 0 0 0-1.414l-.707-.707a1 1 0 0 0-1.414 0L8 8.899 3.757 4.657a1 1 0 0 0-1.414 0l-.707.707Z" fill="currentColor" fill-rule="evenodd"> </path> </svg> </button> </div> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Definition <a class="headerlink leafygreen-ui-1kepx47" href="#definition" 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="definition"> </div> </a> </h2> <dl class="method"> <dt> <code class="leafygreen-ui-1l06pbn"> db.collection.countDocuments(query, options) </code> <a class="headerlink leafygreen-ui-1kepx47" href="#mongodb-method-db.collection.countDocuments" title="Permalink to this definition"> <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="mongodb-method-db.collection.countDocuments"> </div> </a> </dt> <dd> <p class="leafygreen-ui-1kp3ins"> Returns an integer for the number of documents that match the query of the collection or view. This method is available for use in <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/transactions/#std-label-transactions"> Transactions <!-- --> . </a> </p> </dd> </dl> </section> <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 <code class="leafygreen-ui-1l06pbn"> db.collection.countDocuments() </code> 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"> Syntax <a class="headerlink leafygreen-ui-1kepx47" href="#syntax" 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="syntax"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> The <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-method-db.collection.countDocuments" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> countDocuments() </code> </span> </a> method has the following form: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.collection.countDocuments( &lt;query&gt;, &lt;options&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">countDocuments</span>( &lt;<!-- -->query<!-- -->&gt;<!-- -->,<!-- --> <!-- -->&lt;<!-- -->options<!-- -->&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 <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-method-db.collection.countDocuments" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> countDocuments() </code> </span> </a> method takes the following parameters: </p> <div class="leafygreen-ui-skkc39" tabindex="0"> <table class="leafygreen-ui-hr8lsv"> <colgroup> <col style="width:20%"/> <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> Parameter </div> </div> </th> <th class="leafygreen-ui-13uteka" role="columnheader" scope="col"> <div class="leafygreen-ui-ui0te9"> <div> Type </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> query </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> document </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> The query selection criteria. To count all documents, specify an empty document. See also <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-countDocuments-restrictions" target="_self"> <span> Query Restrictions <!-- --> . </span> </a> </div> </div> </td> </tr> <tr class=""> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> options </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> document </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Optional. Extra options that affects the count behavior. </div> </div> </td> </tr> </tbody> </table> </div> <p class="leafygreen-ui-1kp3ins"> The <code class="leafygreen-ui-1l06pbn"> options </code> document can contain the following: </p> <div class="leafygreen-ui-skkc39" tabindex="0"> <table class="leafygreen-ui-hr8lsv"> <colgroup> <col style="width:20%"/> <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> Field </div> </div> </th> <th class="leafygreen-ui-13uteka" role="columnheader" scope="col"> <div class="leafygreen-ui-ui0te9"> <div> Type </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> <code class="leafygreen-ui-1l06pbn"> limit </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> integer </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Optional. The maximum number of documents to count. </div> </div> </td> </tr> <tr class=""> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> skip </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> integer </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Optional. The number of documents to skip before counting. </div> </div> </td> </tr> <tr class=""> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> hint </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> string or document </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Optional. An index name or the index specification to use for the query. </div> </div> </td> </tr> <tr class=""> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> maxTimeMS </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> integer </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Optional. The maximum amount of time to allow the count to run. </div> </div> </td> </tr> </tbody> </table> </div> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Behavior <a class="headerlink leafygreen-ui-1kepx47" href="#behavior" 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="behavior"> </div> </a> </h2> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Mechanics <a class="headerlink leafygreen-ui-1kepx47" href="#mechanics" 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="mechanics"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> Unlike <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/db.collection.count/#mongodb-method-db.collection.count"> <code class="leafygreen-ui-1l06pbn"> db.collection.count() </code> </a> , <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-method-db.collection.countDocuments" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> db.collection.countDocuments() </code> </span> </a> does not use the metadata to return the count. Instead, it performs an aggregation of the document to return an accurate count, even after an unclean shutdown or in the presence of <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-orphaned-document"> orphaned documents </a> in a sharded cluster. </p> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-method-db.collection.countDocuments" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> db.collection.countDocuments() </code> </span> </a> wraps the following aggregation operation and returns just the value of <code class="leafygreen-ui-1l06pbn"> n </code> : </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.collection.aggregate([\n { $match: &lt;query&gt; },\n { $group: { _id: null, n: { $sum: 1 } } }\n])","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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>(<!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">$match</span>: &lt;<!-- -->query<!-- -->&gt; <!-- -->}<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">$group</span>: <!-- -->{ <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-literal">null</span>, <span class="lg-highlight-attr">n</span>: <!-- -->{ <span class="lg-highlight-attr">$sum</span>: <span class="lg-highlight-number">1</span> } } }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">])</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> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Empty or Non-Existing Collections and Views <a class="headerlink leafygreen-ui-1kepx47" href="#empty-or-non-existing-collections-and-views" 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="empty-or-non-existing-collections-and-views"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-method-db.collection.countDocuments" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> db.collection.countDocuments() </code> </span> </a> returns <code class="leafygreen-ui-1l06pbn"> 0 </code> on an empty or non-existing collection or view. </p> <span class="leafygreen-ui-1qnjd6d" id="std-label-countDocuments-restrictions"> </span> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Query Restrictions <a class="headerlink leafygreen-ui-1kepx47" href="#query-restrictions" 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="query-restrictions"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> You cannot use the following query operators as part of the query expression for <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-method-db.collection.countDocuments" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> db.collection.countDocuments() </code> : </span> </a> </p> <div class="leafygreen-ui-skkc39" tabindex="0"> <table class="leafygreen-ui-hr8lsv"> <colgroup> <col style="width:30%"/> <col style="width:70%"/> </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> Restricted Operator </div> </div> </th> <th class="leafygreen-ui-13uteka" role="columnheader" scope="col"> <div class="leafygreen-ui-ui0te9"> <div> Alternative </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/query/where/#mongodb-query-op.-where"> <code class="leafygreen-ui-1l06pbn"> $where </code> </a> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> As an alternative, use <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/query/expr/#mongodb-query-op.-expr"> <code class="leafygreen-ui-1l06pbn"> $expr </code> </a> instead. </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/query/near/#mongodb-query-op.-near"> <code class="leafygreen-ui-1l06pbn"> $near </code> </a> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <p class="leafygreen-ui-1kp3ins"> As an alternative, use <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/query/geoWithin/#mongodb-query-op.-geoWithin"> <code class="leafygreen-ui-1l06pbn"> $geoWithin </code> </a> with <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/query/center/#mongodb-query-op.-center"> <code class="leafygreen-ui-1l06pbn"> $center </code> </a> ; i.e. </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ $geoWithin: { $center: [ [ &lt;x&gt;, &lt;y&gt; ], &lt;radius&gt; ] } }","programmingLanguage":"JavaScript"} </script> <div class="css-1lju8ps"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-tyg50d"> <pre class="leafygreen-ui-1agdxuk" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-attr">$geoWithin</span>: <!-- -->{ <span class="lg-highlight-attr">$center</span>: <!-- -->[ <!-- -->[ &lt;<!-- -->x<!-- -->&gt;<!-- -->,<!-- --> <!-- -->&lt;<!-- -->y<!-- -->&gt; <!-- -->]<!-- -->, &lt;<!-- -->radius<!-- -->&gt; <!-- -->] } }</td></tr></tbody></table></code></pre> </div> </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/operator/query/nearSphere/#mongodb-query-op.-nearSphere"> <code class="leafygreen-ui-1l06pbn"> $nearSphere </code> </a> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <p class="leafygreen-ui-1kp3ins"> As an alternative, use <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/query/geoWithin/#mongodb-query-op.-geoWithin"> <code class="leafygreen-ui-1l06pbn"> $geoWithin </code> </a> with <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/query/centerSphere/#mongodb-query-op.-centerSphere"> <code class="leafygreen-ui-1l06pbn"> $centerSphere </code> </a> ; i.e. </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ $geoWithin: { $centerSphere: [ [ &lt;x&gt;, &lt;y&gt; ], &lt;radius&gt; ] } }","programmingLanguage":"JavaScript"} </script> <div class="css-1lju8ps"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-tyg50d"> <pre class="leafygreen-ui-1agdxuk" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-attr">$geoWithin</span>: <!-- -->{ <span class="lg-highlight-attr">$centerSphere</span>: <!-- -->[ <!-- -->[ &lt;<!-- -->x<!-- -->&gt;<!-- -->,<!-- --> <!-- -->&lt;<!-- -->y<!-- -->&gt; <!-- -->]<!-- -->, &lt;<!-- -->radius<!-- -->&gt; <!-- -->] } }</td></tr></tbody></table></code></pre> </div> </div> </div> </div> </div> </td> </tr> </tbody> </table> </div> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Transactions <a class="headerlink leafygreen-ui-1kepx47" href="#transactions" 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="transactions"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-method-db.collection.countDocuments" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> db.collection.countDocuments() </code> </span> </a> can be used inside <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/transactions/#std-label-transactions"> distributed transactions <!-- --> . </a> </p> <p class="leafygreen-ui-1kp3ins"> When you use <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-method-db.collection.countDocuments" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> db.collection.countDocuments() </code> </span> </a> in a transaction, the resulting count will not filter out any uncommitted <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/transactions/#std-label-transactions"> multi-document transactions <!-- --> . </a> </p> <div class="leafygreen-ui-85da11" role="note"> <h2 class="leafygreen-ui-1ac4g5h"> Important </h2> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> In most cases, a distributed transaction incurs a greater performance cost over single document writes, and the availability of distributed transactions should not be a replacement for effective schema design. For many scenarios, the <a class="leafygreen-ui-tqgtui" href="/docs/manual/data-modeling/concepts/embedding-vs-references/#std-label-data-modeling-embedding"> denormalized data model (embedded documents and arrays) </a> will continue to be optimal for your data and use cases. That is, for many scenarios, modeling your data appropriately will minimize the need for distributed transactions. </p> <p class="leafygreen-ui-1kp3ins"> For additional transactions usage considerations (such as runtime limit and oplog size limit), see also <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/transactions-production-consideration/#std-label-production-considerations"> Production Considerations <!-- --> . </a> </p> </div> </div> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Client Disconnection <a class="headerlink leafygreen-ui-1kepx47" href="#client-disconnection" 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="client-disconnection"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> Starting in MongoDB 4.2, if the client that issued <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-method-db.collection.countDocuments" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> db.collection.countDocuments() </code> </span> </a> disconnects before the operation completes, MongoDB marks <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-method-db.collection.countDocuments" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> db.collection.countDocuments() </code> </span> </a> for termination using <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/command/killOp/#mongodb-dbcommand-dbcmd.killOp"> <code class="leafygreen-ui-1l06pbn"> killOp </code> . </a> </p> </section> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Examples <a class="headerlink leafygreen-ui-1kepx47" href="#examples" 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="examples"> </div> </a> </h2> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Count all Documents in a Collection <a class="headerlink leafygreen-ui-1kepx47" href="#count-all-documents-in-a-collection" 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="count-all-documents-in-a-collection"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> To count the number of documents in the <code class="leafygreen-ui-1l06pbn"> orders </code> collection, use the following operation: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.orders.countDocuments( {}, { hint: \"_id_\"} )","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">orders</span>.<span class="lg-highlight-title lg-highlight-function">countDocuments</span>( <!-- -->{<!-- -->}<!-- -->, <!-- -->{ <span class="lg-highlight-attr">hint</span>: <span class="lg-highlight-string">"_id_"</span>} )</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-15mdk4" role="note"> <h2 class="leafygreen-ui-6n7b7d"> Note </h2> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> If you use <code class="leafygreen-ui-1l06pbn"> db.collection.countDocuments() </code> with an empty query filter, MongoDB performs a full collection scan which can be inefficient. To improve performance, this example specifies a <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/cursor.hint/#mongodb-method-cursor.hint"> <code class="leafygreen-ui-1l06pbn"> hint() </code> </a> to use the automatically generated <code class="leafygreen-ui-1l06pbn"> _id </code> index. Alternatively, you can use a query filter that finds all documents such as <code class="leafygreen-ui-1l06pbn"> { "_id": { $gte: MinKey } } </code> to count all documents using an index. </p> </div> </div> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Count all Documents that Match a Query <a class="headerlink leafygreen-ui-1kepx47" href="#count-all-documents-that-match-a-query" 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="count-all-documents-that-match-a-query"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> Count the number of the documents in the <code class="leafygreen-ui-1l06pbn"> orders </code> collection with the field <code class="leafygreen-ui-1l06pbn"> ord_dt </code> greater than <code class="leafygreen-ui-1l06pbn"> new Date('01/01/2012') </code> : </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.orders.countDocuments( { ord_dt: { $gt: new Date('01/01/2012') } }, { limit: 100 } )","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-1q4bxgx" tabindex="0"><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">orders</span>.<span class="lg-highlight-title lg-highlight-function">countDocuments</span>( <!-- -->{ <span class="lg-highlight-attr">ord_dt</span>: <!-- -->{ <span class="lg-highlight-attr">$gt</span>: <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">Date</span>(<span class="lg-highlight-string">'01/01/2012'</span>) } }<!-- -->, <!-- -->{ <span class="lg-highlight-attr">limit</span>: <span class="lg-highlight-number">100</span> } )</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-13vw3ie" role="note"> <h2 class="leafygreen-ui-1fn4p2b"> Tip </h2> <h3 class="leafygreen-ui-144d5kf"> <strong> See also: </strong> </h3> <div class="leafygreen-ui-9mycqc"> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/db.collection.estimatedDocumentCount/#mongodb-method-db.collection.estimatedDocumentCount"> <code class="leafygreen-ui-1l06pbn"> db.collection.estimatedDocumentCount() </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/group/#mongodb-pipeline-pipe.-group"> <code class="leafygreen-ui-1l06pbn"> $group </code> </a> and <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/sum/#mongodb-group-grp.-sum"> <code class="leafygreen-ui-1l06pbn"> $sum </code> </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/command/count/#mongodb-dbcommand-dbcmd.count"> <code class="leafygreen-ui-1l06pbn"> count </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/collStats/#std-label-collstat-count"> collStats pipeline stage with the count </a> option </p> </li> </ul> </div> </div> </section> </section> </section>
https://www.mongodb.com/docs/manual/reference/command/nav-user-management/
<section> <h1 class="contains-headerlink leafygreen-ui-41fr9s" weight="medium"> User Management Commands <a class="headerlink leafygreen-ui-1kepx47" href="#user-management-commands" 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="user-management-commands"> </div> </a> </h1> <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 command, including syntax and examples, click on the link to the command's reference page. </p> </div> </div> <div class="leafygreen-ui-skkc39" tabindex="0"> <table class="leafygreen-ui-hr8lsv"> <colgroup> <col style="width:30%"/> <col style="width:70%"/> </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> Name </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/command/createUser/#mongodb-dbcommand-dbcmd.createUser"> <code class="leafygreen-ui-1l06pbn"> createUser </code> </a> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Creates a new user. </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/command/dropAllUsersFromDatabase/#mongodb-dbcommand-dbcmd.dropAllUsersFromDatabase"> <code class="leafygreen-ui-1l06pbn"> dropAllUsersFromDatabase </code> </a> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Deletes all users associated with a database. </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/command/dropUser/#mongodb-dbcommand-dbcmd.dropUser"> <code class="leafygreen-ui-1l06pbn"> dropUser </code> </a> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Removes a single user. </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/command/grantRolesToUser/#mongodb-dbcommand-dbcmd.grantRolesToUser"> <code class="leafygreen-ui-1l06pbn"> grantRolesToUser </code> </a> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Grants a role and its privileges to a user. </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/command/revokeRolesFromUser/#mongodb-dbcommand-dbcmd.revokeRolesFromUser"> <code class="leafygreen-ui-1l06pbn"> revokeRolesFromUser </code> </a> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Removes a role from a user. </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/command/updateUser/#mongodb-dbcommand-dbcmd.updateUser"> <code class="leafygreen-ui-1l06pbn"> updateUser </code> </a> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Updates a user's data. </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/command/usersInfo/#mongodb-dbcommand-dbcmd.usersInfo"> <code class="leafygreen-ui-1l06pbn"> usersInfo </code> </a> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Returns information about the specified users. </div> </div> </td> </tr> </tbody> </table> </div> </section>
https://www.mongodb.com/docs/manual/reference/command/grantRolesToUser/
<section> <h1 class="contains-headerlink leafygreen-ui-41fr9s" weight="medium"> grantRolesToUser <a class="headerlink leafygreen-ui-1kepx47" href="#grantrolestouser" 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="grantrolestouser"> </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="#definition" target="_self"> <span> Definition </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#compatibility" target="_self"> <span> Compatibility </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#syntax" target="_self"> <span> Syntax </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#command-fields" target="_self"> <span> Command Fields </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#required-access" target="_self"> <span> Required Access </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#example" target="_self"> <span> Example </span> </a> </li> </ul> </div> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Definition <a class="headerlink leafygreen-ui-1kepx47" href="#definition" 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="definition"> </div> </a> </h2> <dl class="dbcommand"> <dt> <code class="leafygreen-ui-1l06pbn"> grantRolesToUser </code> <a class="headerlink leafygreen-ui-1kepx47" href="#mongodb-dbcommand-dbcmd.grantRolesToUser" title="Permalink to this definition"> <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="mongodb-dbcommand-dbcmd.grantRolesToUser"> </div> </a> </dt> <dd> <p class="leafygreen-ui-1kp3ins"> Grants additional roles to a user. </p> <div class="leafygreen-ui-13vw3ie" role="note"> <h2 class="leafygreen-ui-1fn4p2b"> Tip </h2> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> In <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/mongodb-shell/#std-program-mongosh" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongosh </code> </span> </a> , this command can also be run through the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/db.grantRolesToUser/#mongodb-method-db.grantRolesToUser"> <code class="leafygreen-ui-1l06pbn"> db.grantRolesToUser() </code> </a> helper method <!-- --> . </p> <p class="leafygreen-ui-1kp3ins"> Helper methods are convenient for <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/mongodb-shell/#std-program-mongosh" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongosh </code> </span> </a> users, but they may not return the same level of information as database commands. In cases where the convenience is not needed or the additional return fields are required, use the database command. </p> </div> </div> </dd> </dl> </section> <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"> This command is available in 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> <div class="leafygreen-ui-85da11" role="note"> <h2 class="leafygreen-ui-1ac4g5h"> Important </h2> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> This command is not supported in M0, M2, M5, and M10+ clusters. For more information, see <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/atlas/unsupported-commands/" target="_self"> <span> Unsupported Commands <!-- --> . </span> </a> </p> </div> </div> <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"> Syntax <a class="headerlink leafygreen-ui-1kepx47" href="#syntax" 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="syntax"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> The <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-dbcommand-dbcmd.grantRolesToUser" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> grantRolesToUser </code> </span> </a> command uses the following syntax: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.runCommand(\n {\n grantRolesToUser: \"&lt;user&gt;\",\n roles: [ &lt;roles&gt; ],\n writeConcern: { &lt;write&gt; },\n comment: &lt;any&gt;\n }\n)","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">runCommand</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">grantRolesToUser</span>: <span class="lg-highlight-string">"&lt;user&gt;"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">roles</span>: <!-- -->[ &lt;<!-- -->roles<!-- -->&gt; <!-- -->]<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">writeConcern</span>: <!-- -->{ <!-- -->&lt;write concern&gt; },</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> comment: &lt;any&gt;</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">)</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> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Command Fields <a class="headerlink leafygreen-ui-1kepx47" href="#command-fields" 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="command-fields"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> The command takes the following fields: </p> <div class="leafygreen-ui-skkc39" tabindex="0"> <table class="leafygreen-ui-hr8lsv"> <colgroup> <col style="width:20%"/> <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> Field </div> </div> </th> <th class="leafygreen-ui-13uteka" role="columnheader" scope="col"> <div class="leafygreen-ui-ui0te9"> <div> Type </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> <code class="leafygreen-ui-1l06pbn"> grantRolesToUser </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> string </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> The name of the user to give additional roles. </div> </div> </td> </tr> <tr class=""> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> roles </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> array </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> An array of additional roles to grant to the user. </div> </div> </td> </tr> <tr class=""> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> writeConcern </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> document </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <p class="leafygreen-ui-1kp3ins"> Optional. The level of <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/write-concern/#std-label-write-concern"> write concern </a> for the operation. See <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/write-concern/#std-label-wc-specs"> Write Concern Specification <!-- --> . </a> </p> </div> </div> </td> </tr> <tr class=""> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> comment </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> any </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <p class="leafygreen-ui-1kp3ins"> Optional. A user-provided comment to attach to this command. Once set, this comment appears alongside records of this command in the following locations: </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/log-messages/#std-label-log-messages-ref"> mongod log messages </a> , in the <code class="leafygreen-ui-1l06pbn"> attr.command.cursor.comment </code> field. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/database-profiler/#std-label-profiler"> Database profiler </a> output, in the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/database-profiler/#mongodb-data-system.profile.command"> <code class="leafygreen-ui-1l06pbn"> command.comment </code> </a> field. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/command/currentOp/#mongodb-dbcommand-dbcmd.currentOp"> <code class="leafygreen-ui-1l06pbn"> currentOp </code> </a> output, in the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/command/currentOp/#mongodb-data-currentOp.command"> <code class="leafygreen-ui-1l06pbn"> command.comment </code> </a> field. </p> </li> </ul> <p class="leafygreen-ui-1kp3ins"> A comment can be any valid <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/bson-types/#std-label-bson-types"> BSON type </a> (string, integer, object, array, etc). </p> </div> </div> </td> </tr> </tbody> </table> </div> <p class="leafygreen-ui-1kp3ins"> In the <code class="leafygreen-ui-1l06pbn"> roles </code> field, you can specify both <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/built-in-roles/#std-label-built-in-roles"> built-in roles </a> and <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/security-user-defined-roles/#std-label-user-defined-roles"> user-defined roles <!-- --> . </a> </p> <p class="leafygreen-ui-1kp3ins"> To specify a role that exists in the same database where <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-dbcommand-dbcmd.grantRolesToUser" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> grantRolesToUser </code> </span> </a> runs, you can either specify the role with the name of the role: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"\"readWrite\"","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"><span class="lg-highlight-string">"readWrite"</span></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"> Or you can specify the role with a document, as in: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ role: \"&lt;role&gt;\", db: \"&lt;database&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">{ <span class="lg-highlight-attr">role</span>: <span class="lg-highlight-string">"&lt;role&gt;"</span>, <span class="lg-highlight-attr">db</span>: <span class="lg-highlight-string">"&lt;database&gt;"</span> }</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"> To specify a role that exists in a different database, specify the role with a document. </p> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Required Access <a class="headerlink leafygreen-ui-1kepx47" href="#required-access" 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="required-access"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> You must have the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/privilege-actions/#mongodb-authaction-grantRole"> <code class="leafygreen-ui-1l06pbn"> grantRole </code> </a> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/privilege-actions/#std-label-security-user-actions"> action </a> on a database to grant a role on that database. </p> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Example <a class="headerlink leafygreen-ui-1kepx47" href="#example" 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="example"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> Given a user <code class="leafygreen-ui-1l06pbn"> accountUser01 </code> in the <code class="leafygreen-ui-1l06pbn"> products </code> database with the following roles: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"\"roles\" : [\n { \"role\" : \"assetsReader\",\n \"db\" : \"assets\"\n }\n]","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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"><span class="lg-highlight-string">"roles"</span> <!-- -->: <!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"role"</span> <!-- -->: <span class="lg-highlight-string">"assetsReader"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"db"</span> <!-- -->: <span class="lg-highlight-string">"assets"</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">]</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 <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-dbcommand-dbcmd.grantRolesToUser" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> grantRolesToUser </code> </span> </a> operation gives <code class="leafygreen-ui-1l06pbn"> accountUser01 </code> the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/built-in-roles/#mongodb-authrole-read"> <code class="leafygreen-ui-1l06pbn"> read </code> </a> role on the <code class="leafygreen-ui-1l06pbn"> stock </code> database and the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/built-in-roles/#mongodb-authrole-readWrite"> <code class="leafygreen-ui-1l06pbn"> readWrite </code> </a> role on the <code class="leafygreen-ui-1l06pbn"> products </code> database. </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"use products\ndb.runCommand( { grantRolesToUser: \"accountUser01\",\n roles: [\n { role: \"read\", db: \"stock\"},\n \"readWrite\"\n ],\n writeConcern: { w: \"majority\" , wtimeout: 2000 }\n } )","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">use products</td></tr><tr class=""><td class="leafygreen-ui-7razhx">db.<span class="lg-highlight-title lg-highlight-function">runCommand</span>( <!-- -->{ <span class="lg-highlight-attr">grantRolesToUser</span>: <span class="lg-highlight-string">"accountUser01"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">roles</span>: <!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">role</span>: <span class="lg-highlight-string">"read"</span>, <span class="lg-highlight-attr">db</span>: <span class="lg-highlight-string">"stock"</span>}<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"readWrite"</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> ]<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">writeConcern</span>: <!-- -->{ <span class="lg-highlight-attr">w</span>: <span class="lg-highlight-string">"majority"</span> <!-- -->, <span class="lg-highlight-attr">wtimeout</span>: <span class="lg-highlight-number">2000</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> } )</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 user <code class="leafygreen-ui-1l06pbn"> accountUser01 </code> in the <code class="leafygreen-ui-1l06pbn"> products </code> database now has the following roles: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"\"roles\" : [\n { \"role\" : \"assetsReader\",\n \"db\" : \"assets\"\n },\n { \"role\" : \"read\",\n \"db\" : \"stock\"\n },\n { \"role\" : \"readWrite\",\n \"db\" : \"products\"\n }\n]","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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"><span class="lg-highlight-string">"roles"</span> <!-- -->: <!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"role"</span> <!-- -->: <span class="lg-highlight-string">"assetsReader"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"db"</span> <!-- -->: <span class="lg-highlight-string">"assets"</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"role"</span> <!-- -->: <span class="lg-highlight-string">"read"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"db"</span> <!-- -->: <span class="lg-highlight-string">"stock"</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"role"</span> <!-- -->: <span class="lg-highlight-string">"readWrite"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"db"</span> <!-- -->: <span class="lg-highlight-string">"products"</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">]</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> </section> </section>
https://www.mongodb.com/docs/manual/reference/command/enableSharding/
<section> <h1 class="contains-headerlink leafygreen-ui-41fr9s" weight="medium"> enableSharding <a class="headerlink leafygreen-ui-1kepx47" href="#enablesharding" 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="enablesharding"> </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="#definition" target="_self"> <span> Definition </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#compatibility" target="_self"> <span> Compatibility </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#syntax" target="_self"> <span> Syntax </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#command-fields" target="_self"> <span> Command Fields </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#behavior" target="_self"> <span> Behavior </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#example" target="_self"> <span> Example </span> </a> </li> </ul> </div> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Definition <a class="headerlink leafygreen-ui-1kepx47" href="#definition" 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="definition"> </div> </a> </h2> <dl class="dbcommand"> <dt> <code class="leafygreen-ui-1l06pbn"> enableSharding </code> <a class="headerlink leafygreen-ui-1kepx47" href="#mongodb-dbcommand-dbcmd.enableSharding" title="Permalink to this definition"> <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="mongodb-dbcommand-dbcmd.enableSharding"> </div> </a> </dt> <dd> <div class="leafygreen-ui-15mdk4" role="note"> <h2 class="leafygreen-ui-6n7b7d"> Note </h2> <div class="leafygreen-ui-9mycqc"> <div> <p> <em> Changed <!-- --> in version <!-- --> 6.0 </em> . </p> </div> <p class="leafygreen-ui-1kp3ins"> Starting in MongoDB 6.0, this command is <strong> not </strong> required to <a class="leafygreen-ui-tqgtui" href="/docs/manual/sharding/#std-label-sharding-background"> shard </a> a collection. </p> </div> </div> <p class="leafygreen-ui-1kp3ins"> The <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-dbcommand-dbcmd.enableSharding" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> enableSharding </code> </span> </a> command explicitly creates a database. </p> <div class="leafygreen-ui-13vw3ie" role="note"> <h2 class="leafygreen-ui-1fn4p2b"> Tip </h2> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> In <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/mongodb-shell/#std-program-mongosh" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongosh </code> </span> </a> , this command can also be run through the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/sh.enableSharding/#mongodb-method-sh.enableSharding"> <code class="leafygreen-ui-1l06pbn"> sh.enableSharding() </code> </a> helper method <!-- --> . </p> <p class="leafygreen-ui-1kp3ins"> Helper methods are convenient for <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/mongodb-shell/#std-program-mongosh" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongosh </code> </span> </a> users, but they may not return the same level of information as database commands. In cases where the convenience is not needed or the additional return fields are required, use the database command. </p> </div> </div> </dd> </dl> </section> <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"> This command is available in 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> <div class="leafygreen-ui-85da11" role="note"> <h2 class="leafygreen-ui-1ac4g5h"> Important </h2> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> This command is not supported in serverless instances. For more information, see <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/atlas/unsupported-commands/" target="_self"> <span> Unsupported Commands <!-- --> . </span> </a> </p> </div> </div> <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"> Syntax <a class="headerlink leafygreen-ui-1kepx47" href="#syntax" 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="syntax"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> The command has the following syntax: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <em> Recommended </em> . Specify the database to create: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.adminCommand(\n {\n enableSharding: \"&lt;database&gt;\"\n }\n)","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">adminCommand</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">enableSharding</span>: <span class="lg-highlight-string">"&lt;database name&gt;"</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">)</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> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Optionally, you can include the primary shard specification in the command, although this is not recommended: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.adminCommand(\n {\n enableSharding: \"&lt;database&gt;\",\n primaryShard: \"&lt;shard&gt;\"\n }\n)","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">adminCommand</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">enableSharding</span>: <span class="lg-highlight-string">"&lt;database name&gt;"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">primaryShard</span>: <span class="lg-highlight-string">"&lt;shard name&gt;"</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">)</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> </li> </ul> <p class="leafygreen-ui-1kp3ins"> You can only run the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-dbcommand-dbcmd.enableSharding" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> enableSharding </code> </span> </a> command on the <code class="leafygreen-ui-1l06pbn"> admin </code> database from a <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongos/#mongodb-binary-bin.mongos"> <code class="leafygreen-ui-1l06pbn"> mongos </code> </a> instance. </p> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Command Fields <a class="headerlink leafygreen-ui-1kepx47" href="#command-fields" 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="command-fields"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> The command takes the following fields: </p> <div class="leafygreen-ui-skkc39" tabindex="0"> <table class="leafygreen-ui-hr8lsv"> <colgroup> <col style="width:20%"/> <col style="width:20%"/> <col style="width:60%"/> </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> Field </div> </div> </th> <th class="leafygreen-ui-13uteka" role="columnheader" scope="col"> <div class="leafygreen-ui-ui0te9"> <div> Type </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="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-cmd-enableSharding-db" target="_self"> <span> enableSharding </span> </a> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> String </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <span class="leafygreen-ui-1qnjd6d" id="std-label-cmd-enableSharding-db"> </span> <p class="leafygreen-ui-1kp3ins"> The database you want to use. The database is created if it does not exist. </p> </div> </div> </td> </tr> <tr class=""> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-cmd-enableSharding-primaryShard" target="_self"> <span> primaryShard </span> </a> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> String </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <span class="leafygreen-ui-1qnjd6d" id="std-label-cmd-enableSharding-primaryShard"> </span> <p class="leafygreen-ui-1kp3ins"> Optional. The <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/sharded-cluster-shards/#std-label-primary-shard"> primary shard </a> for the database. It's the default shard for all unsharded collections in the database. </p> <p class="leafygreen-ui-1kp3ins"> <strong class="css-4dei7l"> WARNING: </strong> In general, you should <strong> not </strong> specify the primary shard. Allow the cluster to select the primary shard instead. </p> </div> </div> </td> </tr> </tbody> </table> </div> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Returns <a class="headerlink leafygreen-ui-1kepx47" href="#returns" 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="returns"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> The command returns a document that contains status of the operation. </p> </section> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Behavior <a class="headerlink leafygreen-ui-1kepx47" href="#behavior" 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="behavior"> </div> </a> </h2> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Write Concern <a class="headerlink leafygreen-ui-1kepx47" href="#write-concern" 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="write-concern"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongos/#mongodb-binary-bin.mongos"> <code class="leafygreen-ui-1l06pbn"> mongos </code> </a> uses <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/write-concern/#mongodb-writeconcern-writeconcern.-majority-"> <code class="leafygreen-ui-1l06pbn"> "majority" </code> </a> for the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-dbcommand-dbcmd.enableSharding" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> enableSharding </code> </span> </a> command and its helper <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/sh.enableSharding/#mongodb-method-sh.enableSharding"> <code class="leafygreen-ui-1l06pbn"> sh.enableSharding() </code> . </a> </p> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Primary Shard <a class="headerlink leafygreen-ui-1kepx47" href="#primary-shard" 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="primary-shard"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> In general, you should not need to specify the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-cmd-enableSharding-primaryShard" target="_self"> <span> primaryShard </span> </a> in the command. Instead, allow the balancer to select the primary shard. </p> <p class="leafygreen-ui-1kp3ins"> However, if you do specify the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-cmd-enableSharding-primaryShard" target="_self"> <span> primaryShard </span> </a> in the command for a <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-cmd-enableSharding-db" target="_self"> <span> database </span> </a> and the database is already sharding enabled with a different primary shard, the operation returns an error and the primary shard for the database remains as before. To change the primary shard for a database, use <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/command/movePrimary/#mongodb-dbcommand-dbcmd.movePrimary"> <code class="leafygreen-ui-1l06pbn"> movePrimary </code> </a> instead. </p> </section> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Example <a class="headerlink leafygreen-ui-1kepx47" href="#example" 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="example"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> The following command, run from a <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongos/#mongodb-binary-bin.mongos"> <code class="leafygreen-ui-1l06pbn"> mongos </code> </a> , creates the the <code class="leafygreen-ui-1l06pbn"> shardTest </code> database: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.adminCommand( { enableSharding: \"shardTest\" } )","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">adminCommand</span>( <!-- -->{ <span class="lg-highlight-attr">enableSharding</span>: <span class="lg-highlight-string">"shardTest"</span> } )</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-13vw3ie" role="note"> <h2 class="leafygreen-ui-1fn4p2b"> Tip </h2> <h3 class="leafygreen-ui-144d5kf"> <strong> See also: </strong> </h3> <div class="leafygreen-ui-9mycqc"> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/tutorial/deploy-shard-cluster/"> Deploy a Self-Managed Sharded Cluster </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/sh.shardCollection/#mongodb-method-sh.shardCollection"> <code class="leafygreen-ui-1l06pbn"> sh.shardCollection() </code> </a> </p> </li> </ul> </div> </div> </section> </section>
https://www.mongodb.com/docs/manual/reference/command/shardingState/
<section> <h1 class="contains-headerlink leafygreen-ui-41fr9s" weight="medium"> shardingState <a class="headerlink leafygreen-ui-1kepx47" href="#shardingstate" 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="shardingstate"> </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="#syntax" target="_self"> <span> Syntax </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#behavior" target="_self"> <span> Behavior </span> </a> </li> </ul> </div> <dl class="dbcommand"> <dt> <code class="leafygreen-ui-1l06pbn"> shardingState </code> <a class="headerlink leafygreen-ui-1kepx47" href="#mongodb-dbcommand-dbcmd.shardingState" title="Permalink to this definition"> <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="mongodb-dbcommand-dbcmd.shardingState"> </div> </a> </dt> <dd> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-dbcommand-dbcmd.shardingState" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> shardingState </code> </span> </a> is an admin command that reports if <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> is a member of a <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-sharded-cluster"> sharded cluster </a> . To run the command, you must run against the <code class="leafygreen-ui-1l06pbn"> admin </code> database. See <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/db.adminCommand/#mongodb-method-db.adminCommand"> <code class="leafygreen-ui-1l06pbn"> db.adminCommand() </code> . </a> </p> </dd> </dl> <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"> This command is available in 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> <div class="leafygreen-ui-15mdk4" role="note"> <h2 class="leafygreen-ui-6n7b7d"> Note </h2> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> This command is supported in all MongoDB Atlas clusters. For information on Atlas support for all commands, see <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/atlas/unsupported-commands/" target="_self"> <span> Unsupported Commands <!-- --> . </span> </a> </p> </div> </div> <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"> Syntax <a class="headerlink leafygreen-ui-1kepx47" href="#syntax" 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="syntax"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> The command has the following syntax: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.adminCommand(\n {\n shardingState: 1\n }\n)","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">adminCommand</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">shardingState</span>: <span class="lg-highlight-number">1</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">)</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> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Behavior <a class="headerlink leafygreen-ui-1kepx47" href="#behavior" 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="behavior"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> For <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-dbcommand-dbcmd.shardingState" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> shardingState </code> </span> </a> to detect that a <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> is a member of a sharded cluster, the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> must satisfy the following conditions: </p> <ol class="leafygreen-ui-rioki0" type="1"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> is a primary member of a replica set, and </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> instance is a member of a sharded cluster. </p> </li> </ol> <p class="leafygreen-ui-1kp3ins"> If <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-dbcommand-dbcmd.shardingState" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> shardingState </code> </span> </a> detects that a <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> is a member of a sharded cluster, <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-dbcommand-dbcmd.shardingState" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> shardingState </code> </span> </a> returns a document that resembles the following prototype: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{\n \"enabled\" : true,\n \"configServer\" : \"&lt;configdb-string&gt;\",\n \"shardName\" : \"&lt;string&gt;\",\n \"shardHost\" : \"string:\",\n \"versions\" : {\n \"&lt;database&gt;.&lt;collection&gt;\" : {\n \"placementVersion\": Timestamp({ t: 1, i: 1024 }),\n \"timestamp\": Timestamp({ t: 1682444810, i: 8 })\n },\n \"&lt;database&gt;.&lt;collection&gt;\" : {\n \"placementVersion\": Timestamp({ t: 0, i: 0 }),\n \"timestamp\": Timestamp({ t: 0, i: 0 })\n }\n },\n \"ok\" : 1,\n \"$clusterTime\" : {\n \"clusterTime\" : Timestamp({ t: 1682457265, i: 1 }),\n \"signature\" : {\n \"hash\" : BinData(0,\"B2ViX7XLzFLS5Fl9XEuFXbwKIM4=\"),\n \"keyId\" : NumberLong(\"6488045157173166092\")\n }\n },\n \"operationTime\" : Timestamp({ t: 1682457260, i: 1 })\n}","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"enabled"</span> <!-- -->: <span class="lg-highlight-literal">true</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"configServer"</span> <!-- -->: <span class="lg-highlight-string">"&lt;configdb-string&gt;"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"shardName"</span> <!-- -->: <span class="lg-highlight-string">"&lt;string&gt;"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"shardHost"</span> <!-- -->: <span class="lg-highlight-string">"string:"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"versions"</span> <!-- -->: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"&lt;database&gt;.&lt;collection&gt;"</span> <!-- -->: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"placementVersion"</span>: <span class="lg-highlight-title lg-highlight-class">Timestamp</span>(<!-- -->{ <span class="lg-highlight-attr">t</span>: <span class="lg-highlight-number">1</span>, <span class="lg-highlight-attr">i</span>: <span class="lg-highlight-number">1024</span> })<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"timestamp"</span>: <span class="lg-highlight-title lg-highlight-class">Timestamp</span>(<!-- -->{ <span class="lg-highlight-attr">t</span>: <span class="lg-highlight-number">1682444810</span>, <span class="lg-highlight-attr">i</span>: <span class="lg-highlight-number">8</span> })</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"&lt;database&gt;.&lt;collection&gt;"</span> <!-- -->: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"placementVersion"</span>: <span class="lg-highlight-title lg-highlight-class">Timestamp</span>(<!-- -->{ <span class="lg-highlight-attr">t</span>: <span class="lg-highlight-number">0</span>, <span class="lg-highlight-attr">i</span>: <span class="lg-highlight-number">0</span> })<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"timestamp"</span>: <span class="lg-highlight-title lg-highlight-class">Timestamp</span>(<!-- -->{ <span class="lg-highlight-attr">t</span>: <span class="lg-highlight-number">0</span>, <span class="lg-highlight-attr">i</span>: <span class="lg-highlight-number">0</span> })</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"ok"</span> <!-- -->: <span class="lg-highlight-number">1</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"$clusterTime"</span> <!-- -->: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"clusterTime"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">Timestamp</span>(<!-- -->{ <span class="lg-highlight-attr">t</span>: <span class="lg-highlight-number">1682457265</span>, <span class="lg-highlight-attr">i</span>: <span class="lg-highlight-number">1</span> })<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"signature"</span> <!-- -->: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"hash"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">BinData</span>(<span class="lg-highlight-number">0</span>,<span class="lg-highlight-string">"B2ViX7XLzFLS5Fl9XEuFXbwKIM4="</span>)<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"keyId"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">NumberLong</span>(<span class="lg-highlight-string">"6488045157173166092"</span>)</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"operationTime"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">Timestamp</span>(<!-- -->{ <span class="lg-highlight-attr">t</span>: <span class="lg-highlight-number">1682457260</span>, <span class="lg-highlight-attr">i</span>: <span class="lg-highlight-number">1</span> })</td></tr><tr class=""><td class="leafygreen-ui-7razhx">}</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"> Otherwise, <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-dbcommand-dbcmd.shardingState" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> shardingState </code> </span> </a> will return the following document: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{\n \"enabled\" : false,\n \"ok\" : 1,\n \"$clusterTime\" : {\n \"clusterTime\" : Timestamp({t:1510716515, i: 1}),\n \"signature\" : {\n \"hash\" : BinData(0,\"B2ViX7XLzFLS5Fl9XEuFXbwKIM4=\"),\n \"keyId\" : NumberLong(\"6488045157173166092\")\n }\n },\n \"operationTime\" : Timestamp({t: 1510716515, i: 1})\n}","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"enabled"</span> <!-- -->: <span class="lg-highlight-literal">false</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"ok"</span> <!-- -->: <span class="lg-highlight-number">1</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"$clusterTime"</span> <!-- -->: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"clusterTime"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">Timestamp</span>(<!-- -->{<span class="lg-highlight-attr">t</span>:<span class="lg-highlight-number">1510716515</span>, <span class="lg-highlight-attr">i</span>: <span class="lg-highlight-number">1</span>})<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"signature"</span> <!-- -->: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"hash"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">BinData</span>(<span class="lg-highlight-number">0</span>,<span class="lg-highlight-string">"B2ViX7XLzFLS5Fl9XEuFXbwKIM4="</span>)<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"keyId"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">NumberLong</span>(<span class="lg-highlight-string">"6488045157173166092"</span>)</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"operationTime"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">Timestamp</span>(<!-- -->{<span class="lg-highlight-attr">t</span>: <span class="lg-highlight-number">1510716515</span>, <span class="lg-highlight-attr">i</span>: <span class="lg-highlight-number">1</span>})</td></tr><tr class=""><td class="leafygreen-ui-7razhx">}</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 response from <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-dbcommand-dbcmd.shardingState" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> shardingState </code> </span> </a> when used with a <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-config-database"> config server </a> is: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{\n \"enabled\" : false,\n \"ok\" : 1,\n \"operationTime\" : Timestamp({t: 1510767613, i: 1}),\n \"$gleStats\" : {\n \"lastOpTime\" : Timestamp({t: 0, i: 0}),\n \"electionId\" : ObjectId(\"7fffffff0000000000000001\")\n },\n \"$clusterTime\" : {\n \"clusterTime\" : Timestamp({t: 1510767613, i: 1}),\n \"signature\" : {\n \"hash\" : BinData(0,\"IwBZ4SZjIMI5NdM62NObV/R31GM=\"),\n \"keyId\" : NumberLong(\"6488693018630029321\")\n }\n }\n}","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"enabled"</span> <!-- -->: <span class="lg-highlight-literal">false</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"ok"</span> <!-- -->: <span class="lg-highlight-number">1</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"operationTime"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">Timestamp</span>(<!-- -->{<span class="lg-highlight-attr">t</span>: <span class="lg-highlight-number">1510767613</span>, <span class="lg-highlight-attr">i</span>: <span class="lg-highlight-number">1</span>})<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"$gleStats"</span> <!-- -->: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"lastOpTime"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">Timestamp</span>(<!-- -->{<span class="lg-highlight-attr">t</span>: <span class="lg-highlight-number">0</span>, <span class="lg-highlight-attr">i</span>: <span class="lg-highlight-number">0</span>})<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"electionId"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">ObjectId</span>(<span class="lg-highlight-string">"7fffffff0000000000000001"</span>)</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"$clusterTime"</span> <!-- -->: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"clusterTime"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">Timestamp</span>(<!-- -->{<span class="lg-highlight-attr">t</span>: <span class="lg-highlight-number">1510767613</span>, <span class="lg-highlight-attr">i</span>: <span class="lg-highlight-number">1</span>})<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"signature"</span> <!-- -->: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"hash"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">BinData</span>(<span class="lg-highlight-number">0</span>,<span class="lg-highlight-string">"IwBZ4SZjIMI5NdM62NObV/R31GM="</span>)<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"keyId"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">NumberLong</span>(<span class="lg-highlight-string">"6488693018630029321"</span>)</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">}</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-15mdk4" role="note"> <h2 class="leafygreen-ui-6n7b7d"> Note </h2> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongos/#mongodb-binary-bin.mongos"> <code class="leafygreen-ui-1l06pbn"> mongos </code> </a> instances do not provide the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-dbcommand-dbcmd.shardingState" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> shardingState </code> . </span> </a> </p> </div> </div> <div class="leafygreen-ui-1sjx7ru" role="note"> <h2 class="leafygreen-ui-29m78u"> Warning </h2> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> This command obtains a write lock on the affected database and will block other operations until it has completed; however, the operation is typically short lived. </p> </div> </div> </section> </section>
https://www.mongodb.com/docs/manual/reference/method/rs.stepDown/
<section> <h1 class="contains-headerlink leafygreen-ui-41fr9s" weight="medium"> rs.stepDown() <a class="headerlink leafygreen-ui-1kepx47" href="#rs.stepdown--" 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="rs.stepdown--"> </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="#description" target="_self"> <span> Description </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#behavior" target="_self"> <span> Behavior </span> </a> </li> </ul> </div> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Description <a class="headerlink leafygreen-ui-1kepx47" href="#description" 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="description"> </div> </a> </h2> <dl class="method"> <dt> <code class="leafygreen-ui-1l06pbn"> rs.stepDown(stepDownSecs, secondaryCatchUpPeriodSecs) </code> <a class="headerlink leafygreen-ui-1kepx47" href="#mongodb-method-rs.stepDown" title="Permalink to this definition"> <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="mongodb-method-rs.stepDown"> </div> </a> </dt> <dd> <p class="leafygreen-ui-1kp3ins"> Instructs the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-primary"> primary </a> of the replica set to become a <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-secondary"> secondary </a> . After the primary steps down, eligible secondaries will hold an <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/replica-set-elections/#std-label-replica-set-election-internals"> election for primary <!-- --> . </a> </p> <p class="leafygreen-ui-1kp3ins"> The <!-- --> method <!-- --> does not immediately step down the primary. If no <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/replica-configuration/#mongodb-rsconf-rsconf.members-n-.priority"> <code class="leafygreen-ui-1l06pbn"> electable </code> </a> secondaries are up to date with the primary, the primary waits up to <code class="leafygreen-ui-1l06pbn"> secondaryCatchUpPeriodSecs </code> (by default 10 seconds) for a secondary to catch up. Once an electable secondary is available, the <!-- --> method <!-- --> steps down the primary. </p> <p class="leafygreen-ui-1kp3ins"> Once stepped down, the original primary becomes a secondary and is ineligible from becoming primary again for the remainder of time specified by <code class="leafygreen-ui-1l06pbn"> stepDownSecs </code> . </p> <p class="leafygreen-ui-1kp3ins"> For a detailed explanation of the <!-- --> method <!-- --> 's execution, see <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-rs.stepDown-behavior" target="_self"> <span> Behavior </span> </a> . </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"> The <!-- --> method <!-- --> is only valid against the primary and throws an error if run on a non-primary member. </p> </div> </div> <div class="leafygreen-ui-85da11" role="note"> <h2 class="leafygreen-ui-1ac4g5h"> Important </h2> <h3 class="leafygreen-ui-144d5kf"> <strong> mongosh Method </strong> </h3> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> This page documents a <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/mongodb-shell/#mongodb-binary-bin.mongosh" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongosh </code> </span> </a> method. This is <em> not </em> the documentation for database commands or language-specific drivers, such as Node.js. </p> <p class="leafygreen-ui-1kp3ins"> For the database command, see the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/command/replSetStepDown/#mongodb-dbcommand-dbcmd.replSetStepDown"> <code class="leafygreen-ui-1l06pbn"> replSetStepDown </code> </a> command <!-- --> . </p> <p class="leafygreen-ui-1kp3ins"> For MongoDB API drivers, refer to the language-specific <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/drivers/" target="_self"> <span> MongoDB driver documentation <!-- --> . </span> </a> </p> </div> </div> <p class="leafygreen-ui-1kp3ins"> The <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-method-rs.stepDown" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> rs.stepDown() </code> </span> </a> method has the following parameters: </p> <div class="leafygreen-ui-skkc39" tabindex="0"> <table class="leafygreen-ui-hr8lsv"> <colgroup> <col style="width:20%"/> <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> Parameter </div> </div> </th> <th class="leafygreen-ui-13uteka" role="columnheader" scope="col"> <div class="leafygreen-ui-ui0te9"> <div> Type </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> <code class="leafygreen-ui-1l06pbn"> stepDownSecs </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> number </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <p class="leafygreen-ui-1kp3ins"> The number of seconds to step down the primary, during which time the stepdown member is ineligible for becoming primary. If you specify a non-numeric value, the command uses <code class="leafygreen-ui-1l06pbn"> 60 </code> seconds. </p> <p class="leafygreen-ui-1kp3ins"> The stepdown period starts from the time that the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> receives the command. The stepdown period must be greater than the <code class="leafygreen-ui-1l06pbn"> secondaryCatchUpPeriodSecs </code> . </p> </div> </div> </td> </tr> <tr class=""> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> secondaryCatchUpPeriodSecs </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> number </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <p class="leafygreen-ui-1kp3ins"> Optional. The number of seconds that <code class="leafygreen-ui-1l06pbn"> mongod </code> will wait for an electable secondary to catch up to the primary. </p> <p class="leafygreen-ui-1kp3ins"> When specified, <code class="leafygreen-ui-1l06pbn"> secondaryCatchUpPeriodSecs </code> overrides the default wait time of <code class="leafygreen-ui-1l06pbn"> 10 </code> seconds. </p> </div> </div> </td> </tr> </tbody> </table> </div> </dd> </dl> <span class="leafygreen-ui-1qnjd6d" id="std-label-rs.stepDown-behavior"> </span> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Behavior <a class="headerlink leafygreen-ui-1kepx47" href="#behavior" 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="behavior"> </div> </a> </h2> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Concurrent Operations <a class="headerlink leafygreen-ui-1kepx47" href="#concurrent-operations" 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="concurrent-operations"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> The <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-method-rs.stepDown" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> rs.stepDown() </code> </span> </a> <!-- --> method <!-- --> attempts to terminate long running user operations that block the primary from stepping down, such as an index build, a write operation or a map-reduce job. </p> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Availability of Eligible Secondaries <a class="headerlink leafygreen-ui-1kepx47" href="#availability-of-eligible-secondaries" 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="availability-of-eligible-secondaries"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> The <!-- --> method <!-- --> then initiates a catchup period where it waits up to <code class="leafygreen-ui-1l06pbn"> secondaryCatchUpPeriodSeconds </code> , by default 10 seconds, for a secondary to become up-to-date with the primary. The primary only steps down if a secondary is up-to-date with the primary during the catchup period to prevent <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/replica-set-rollbacks/#std-label-replica-set-rollbacks"> rollbacks <!-- --> . </a> </p> <p class="leafygreen-ui-1kp3ins"> If no electable secondary meets this criterion by the end of the waiting period, the primary does not step down and the <!-- --> method <!-- --> errors. </p> <p class="leafygreen-ui-1kp3ins"> Once the primary steps down successfully, that node cannot become the primary for the remainder of the <code class="leafygreen-ui-1l06pbn"> stepDownSecs </code> period, which began when the node received the <!-- --> method <!-- --> . </p> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Client Connections <a class="headerlink leafygreen-ui-1kepx47" href="#client-connections" 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="client-connections"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-method-rs.stepDown" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> rs.stepDown() </code> </span> </a> <!-- --> method <!-- --> doesn't close all client connections. </p> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Writes During Stepdown <a class="headerlink leafygreen-ui-1kepx47" href="#writes-during-stepdown" 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="writes-during-stepdown"> </div> </a> </h3> <div class="leafygreen-ui-15mdk4" role="note"> <h2 class="leafygreen-ui-6n7b7d"> Note </h2> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> All writes to the primary fail during the period starting when the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-method-rs.stepDown" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> rs.stepDown() </code> </span> </a> <!-- --> method <!-- --> is received until either a new primary is elected, or if there are no electable secondaries, the original primary resumes normal operation. </p> <p class="leafygreen-ui-1kp3ins"> Writes that were in progress when <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-method-rs.stepDown" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> rs.stepDown() </code> </span> </a> is run are killed. In-progress <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/transactions/#std-label-transactions"> transactions </a> also fail with <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/transactions-in-applications/#std-label-transient-transaction-error"> <code class="leafygreen-ui-1l06pbn"> TransientTransactionError </code> </a> and can be retried as a whole. </p> <p class="leafygreen-ui-1kp3ins"> The time period where writes fail is at maximum: </p> <p class="leafygreen-ui-1kp3ins"> <code class="leafygreen-ui-1l06pbn"> secondaryCatchUpPeriodSecs </code> (10s by default) + <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/replica-configuration/#mongodb-rsconf-rsconf.settings.electionTimeoutMillis"> <code class="leafygreen-ui-1l06pbn"> electionTimeoutMillis </code> </a> (10s by default). </p> </div> </div> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Election Handoff <a class="headerlink leafygreen-ui-1kepx47" href="#election-handoff" 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="election-handoff"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> When you step down a primary using <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-method-rs.stepDown" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> rs.stepDown() </code> </span> </a> or <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/command/replSetStepDown/#mongodb-dbcommand-dbcmd.replSetStepDown"> <code class="leafygreen-ui-1l06pbn"> replSetStepDown </code> </a> without setting the <code class="leafygreen-ui-1l06pbn"> force </code> field to <code class="leafygreen-ui-1l06pbn"> true </code> , the stepped-down primary nominates an eligible secondary to call an election immediately. </p> </section> </section> </section>
https://www.mongodb.com/docs/manual/reference/operator/aggregation/binarySize/
<section> <h1 class="contains-headerlink leafygreen-ui-41fr9s" weight="medium"> $binarySize (aggregation) <a class="headerlink leafygreen-ui-1kepx47" href="#-binarysize--aggregation-" 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="-binarysize--aggregation-"> </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="#definition" target="_self"> <span> Definition </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#behavior" target="_self"> <span> Behavior </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#example" target="_self"> <span> Example </span> </a> </li> </ul> </div> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Definition <a class="headerlink leafygreen-ui-1kepx47" href="#definition" 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="definition"> </div> </a> </h2> <dl class="expression"> <dt> <code class="leafygreen-ui-1l06pbn"> $binarySize </code> <a class="headerlink leafygreen-ui-1kepx47" href="#mongodb-expression-exp.-binarySize" title="Permalink to this definition"> <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="mongodb-expression-exp.-binarySize"> </div> </a> </dt> <dd> <p class="leafygreen-ui-1kp3ins"> Returns the size of a given string or binary data value's content in bytes. </p> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-expression-exp.-binarySize" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $binarySize </code> </span> </a> has the following syntax: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ $binarySize: &lt;string&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">{ <span class="lg-highlight-attr">$binarySize</span>: <span class="lg-highlight-tag lg-highlight-xml">&lt;</span><span class="lg-highlight-name lg-highlight-tag lg-highlight-xml">string</span><span class="lg-highlight-tag lg-highlight-xml"> </span><span class="lg-highlight-attr lg-highlight-tag lg-highlight-xml">or</span><span class="lg-highlight-tag lg-highlight-xml"> </span><span class="lg-highlight-attr lg-highlight-tag lg-highlight-xml">binData</span><span class="lg-highlight-tag lg-highlight-xml">&gt;</span><span class="lg-highlight-xml"> }</span></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 argument can be any valid <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/#std-label-aggregation-expressions"> expression </a> as long as it resolves to either a string or binary data value. For more information on expressions, see <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/#std-label-aggregation-expressions"> Expression Operators <!-- --> . </a> </p> </dd> </dl> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Behavior <a class="headerlink leafygreen-ui-1kepx47" href="#behavior" 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="behavior"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> The argument for <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-expression-exp.-binarySize" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $binarySize </code> </span> </a> must resolve to either: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> A string, </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> A binary data value, or </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> null. </p> </li> </ul> <p class="leafygreen-ui-1kp3ins"> If the argument is a string or binary data value, the expression returns the size of the argument in bytes. </p> <p class="leafygreen-ui-1kp3ins"> If the argument is <code class="leafygreen-ui-1l06pbn"> null </code> , the expression returns <code class="leafygreen-ui-1l06pbn"> null </code> . </p> <p class="leafygreen-ui-1kp3ins"> If the argument resolves to any other data type, <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-expression-exp.-binarySize" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $binarySize </code> </span> </a> errors. </p> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> String Size Calculation <a class="headerlink leafygreen-ui-1kepx47" href="#string-size-calculation" 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="string-size-calculation"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> If the argument for <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-expression-exp.-binarySize" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $binarySize </code> </span> </a> is a string, the operator counts the number of UTF-8 encoded bytes in a string where each character may use between one and four bytes. </p> <p class="leafygreen-ui-1kp3ins"> For example, US-ASCII characters are encoded using one byte. Characters with diacritic markings and additional Latin alphabetical characters (Latin characters outside of the English alphabet) are encoded using two bytes. Chinese, Japanese and Korean characters typically require three bytes, and other planes of unicode (emoji, mathematical symbols, etc.) require four bytes. </p> <p class="leafygreen-ui-1kp3ins"> Consider the following examples: </p> <div class="leafygreen-ui-skkc39" tabindex="0"> <table class="leafygreen-ui-hr8lsv"> <colgroup> <col style="width:40%"/> <col style="width:15%"/> <col style="width:45%"/> </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> Example </div> </div> </th> <th class="leafygreen-ui-13uteka" role="columnheader" scope="col"> <div class="leafygreen-ui-ui0te9"> <div> Results </div> </div> </th> <th class="leafygreen-ui-13uteka" role="columnheader" scope="col"> <div class="leafygreen-ui-ui0te9"> <div> Notes </div> </div> </th> </tr> </thead> <tbody> <tr class="leafygreen-ui-15dvrnp"> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ $binarySize: \"abcde\" }","programmingLanguage":"JavaScript"} </script> <div class="css-1lju8ps"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1jheeh3"> <pre class="leafygreen-ui-1agdxuk" 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">{ <span class="lg-highlight-attr">$binarySize</span>: <span class="lg-highlight-string">"abcde"</span> }</td></tr></tbody></table></code></pre> </div> </div> </div> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> 5 </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Each character is encoded using one byte. </div> </div> </td> </tr> <tr class="leafygreen-ui-15dvrnp"> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ $binarySize: \"Hello World!\" }","programmingLanguage":"JavaScript"} </script> <div class="css-1lju8ps"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-tyg50d"> <pre class="leafygreen-ui-1agdxuk" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-attr">$binarySize</span>: <span class="lg-highlight-string">"Hello World!"</span> }</td></tr></tbody></table></code></pre> </div> </div> </div> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> 12 </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Each character is encoded using one byte. </div> </div> </td> </tr> <tr class="leafygreen-ui-15dvrnp"> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ $binarySize: \"cafeteria\" }","programmingLanguage":"JavaScript"} </script> <div class="css-1lju8ps"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-tyg50d"> <pre class="leafygreen-ui-1agdxuk" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-attr">$binarySize</span>: <span class="lg-highlight-string">"cafeteria"</span> }</td></tr></tbody></table></code></pre> </div> </div> </div> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> 9 </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Each character is encoded using one byte. </div> </div> </td> </tr> <tr class="leafygreen-ui-15dvrnp"> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ $binarySize: \"cafétéria\" }","programmingLanguage":"JavaScript"} </script> <div class="css-1lju8ps"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-tyg50d"> <pre class="leafygreen-ui-1agdxuk" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-attr">$binarySize</span>: <span class="lg-highlight-string">"cafétéria"</span> }</td></tr></tbody></table></code></pre> </div> </div> </div> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> 11 </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> é </code> is encoded using two bytes. </div> </div> </td> </tr> <tr class="leafygreen-ui-15dvrnp"> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ $binarySize: \"\" }","programmingLanguage":"JavaScript"} </script> <div class="css-1lju8ps"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1jheeh3"> <pre class="leafygreen-ui-1agdxuk" 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">{ <span class="lg-highlight-attr">$binarySize</span>: <span class="lg-highlight-string">""</span> }</td></tr></tbody></table></code></pre> </div> </div> </div> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> 0 </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Empty strings return 0. </div> </div> </td> </tr> <tr class="leafygreen-ui-15dvrnp"> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ $binarySize: \"$€λG\" }","programmingLanguage":"JavaScript"} </script> <div class="css-1lju8ps"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1jheeh3"> <pre class="leafygreen-ui-1agdxuk" 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">{ <span class="lg-highlight-attr">$binarySize</span>: <span class="lg-highlight-string">"$€λG"</span> }</td></tr></tbody></table></code></pre> </div> </div> </div> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> 7 </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> € </code> is encoded using three bytes. <code class="leafygreen-ui-1l06pbn"> λ </code> is encoded using two bytes. </div> </div> </td> </tr> <tr class="leafygreen-ui-15dvrnp"> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ $binarySize: \"寿司\" }","programmingLanguage":"JavaScript"} </script> <div class="css-1lju8ps"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1jheeh3"> <pre class="leafygreen-ui-1agdxuk" 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">{ <span class="lg-highlight-attr">$binarySize</span>: <span class="lg-highlight-string">"寿司"</span> }</td></tr></tbody></table></code></pre> </div> </div> </div> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> 6 </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Each character is encoded using three bytes. </div> </div> </td> </tr> </tbody> </table> </div> </section> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Example <a class="headerlink leafygreen-ui-1kepx47" href="#example" 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="example"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> In <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/mongodb-shell/#mongodb-binary-bin.mongosh" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongosh </code> </span> </a> , create a sample collection named <code class="leafygreen-ui-1l06pbn"> images </code> with the following documents: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.images.insertMany([\n { _id: 1, name: \"cat.jpg\", binary: new BinData(0, \"OEJTfmD8twzaj/LPKLIVkA==\")},\n { _id: 2, name: \"big_ben.jpg\", binary: new BinData(0, \"aGVsZmRqYWZqYmxhaGJsYXJnYWZkYXJlcTU1NDE1Z2FmZCBmZGFmZGE=\")},\n { _id: 3, name: \"tea_set.jpg\", binary: new BinData(0, \"MyIRAFVEd2aImaq7zN3u/w==\")},\n { _id: 4, name: \"concert.jpg\", binary: new BinData(0, \"TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx5IGJ5IGhpcyByZWFzb24sIGJ1dCBieSB0aGlzIHNpbmd1bGFyIHBhc3Npb24gZnJvbSBvdGhlciBhbmltYWxzLCB3aGljaCBpcyBhIGx1c3Qgb2YgdGhlIG1pbmQsIHRoYXQgYnkgYSBwZXJzZXZlcmFuY2Ugb2YgZGVsaWdodCBpbiB0aGUgY29udGludWVkIGFuZCBpbmRlZmF0aWdhYmxlIGdlbmVyYXRpb24gb2Yga25vd2xlZGdlLCBleGNlZWRzIHRoZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbGVhc3VyZS4=\")},\n { _id: 5, name: \"empty.jpg\", binary: new BinData(0, \"\") }\n])","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><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">images</span>.<span class="lg-highlight-title lg-highlight-function">insertMany</span>(<!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">1</span>, <span class="lg-highlight-attr">name</span>: <span class="lg-highlight-string">"cat.jpg"</span>, <span class="lg-highlight-attr">binary</span>: <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">BinData</span>(<span class="lg-highlight-number">0</span>, <span class="lg-highlight-string">"OEJTfmD8twzaj/LPKLIVkA=="</span>)}<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">2</span>, <span class="lg-highlight-attr">name</span>: <span class="lg-highlight-string">"big_ben.jpg"</span>, <span class="lg-highlight-attr">binary</span>: <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">BinData</span>(<span class="lg-highlight-number">0</span>, <span class="lg-highlight-string">"aGVsZmRqYWZqYmxhaGJsYXJnYWZkYXJlcTU1NDE1Z2FmZCBmZGFmZGE="</span>)}<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">3</span>, <span class="lg-highlight-attr">name</span>: <span class="lg-highlight-string">"tea_set.jpg"</span>, <span class="lg-highlight-attr">binary</span>: <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">BinData</span>(<span class="lg-highlight-number">0</span>, <span class="lg-highlight-string">"MyIRAFVEd2aImaq7zN3u/w=="</span>)}<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">4</span>, <span class="lg-highlight-attr">name</span>: <span class="lg-highlight-string">"concert.jpg"</span>, <span class="lg-highlight-attr">binary</span>: <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">BinData</span>(<span class="lg-highlight-number">0</span>, <span class="lg-highlight-string">"TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx5IGJ5IGhpcyByZWFzb24sIGJ1dCBieSB0aGlzIHNpbmd1bGFyIHBhc3Npb24gZnJvbSBvdGhlciBhbmltYWxzLCB3aGljaCBpcyBhIGx1c3Qgb2YgdGhlIG1pbmQsIHRoYXQgYnkgYSBwZXJzZXZlcmFuY2Ugb2YgZGVsaWdodCBpbiB0aGUgY29udGludWVkIGFuZCBpbmRlZmF0aWdhYmxlIGdlbmVyYXRpb24gb2Yga25vd2xlZGdlLCBleGNlZWRzIHRoZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbGVhc3VyZS4="</span>)}<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">5</span>, <span class="lg-highlight-attr">name</span>: <span class="lg-highlight-string">"empty.jpg"</span>, <span class="lg-highlight-attr">binary</span>: <span class="lg-highlight-keyword">new</span> <span class="lg-highlight-title lg-highlight-class">BinData</span>(<span class="lg-highlight-number">0</span>, <span class="lg-highlight-string">""</span>) }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">])</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 aggregation <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/project/#mongodb-pipeline-pipe.-project"> <code class="leafygreen-ui-1l06pbn"> projects </code> : </a> </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> The <code class="leafygreen-ui-1l06pbn"> name </code> field </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> The <code class="leafygreen-ui-1l06pbn"> imageSize </code> field, which uses <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-expression-exp.-binarySize" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $binarySize </code> </span> </a> to return the size of the document's <code class="leafygreen-ui-1l06pbn"> binary </code> field in bytes. </p> </li> </ul> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.images.aggregate([\n {\n $project: {\n \"name\": \"$name\",\n \"imageSize\": { $binarySize: \"$binary\" }\n }\n }\n])","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">images</span>.<span class="lg-highlight-title lg-highlight-function">aggregate</span>(<!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">$project</span>: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"name"</span>: <span class="lg-highlight-string">"$name"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"imageSize"</span>: <!-- -->{ <span class="lg-highlight-attr">$binarySize</span>: <span class="lg-highlight-string">"$binary"</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">])</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 operation returns the following result: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ \"_id\" : 1, \"name\" : \"cat.jpg\", \"imageSize\" : 16 }\n{ \"_id\" : 2, \"name\" : \"big_ben.jpg\", \"imageSize\" : 41 }\n{ \"_id\" : 3, \"name\" : \"teaset.jpg\", \"imageSize\" : 16 }\n{ \"_id\" : 4, \"name\" : \"concert.jpg\", \"imageSize\" : 269 }\n{ \"_id\" : 5, \"name\" : \"empty.jpg\", \"imageSize\" : 0 }","programmingLanguage":"JavaScript"} </script> <div class="css-1lju8ps"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1jheeh3"> <pre class="leafygreen-ui-1453az5" 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">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">1</span>, <span class="lg-highlight-string">"name"</span> <!-- -->: <span class="lg-highlight-string">"cat.jpg"</span>, <span class="lg-highlight-string">"imageSize"</span> <!-- -->: <span class="lg-highlight-number">16</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">2</span>, <span class="lg-highlight-string">"name"</span> <!-- -->: <span class="lg-highlight-string">"big_ben.jpg"</span>, <span class="lg-highlight-string">"imageSize"</span> <!-- -->: <span class="lg-highlight-number">41</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">3</span>, <span class="lg-highlight-string">"name"</span> <!-- -->: <span class="lg-highlight-string">"teaset.jpg"</span>, <span class="lg-highlight-string">"imageSize"</span> <!-- -->: <span class="lg-highlight-number">16</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">4</span>, <span class="lg-highlight-string">"name"</span> <!-- -->: <span class="lg-highlight-string">"concert.jpg"</span>, <span class="lg-highlight-string">"imageSize"</span> <!-- -->: <span class="lg-highlight-number">269</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">5</span>, <span class="lg-highlight-string">"name"</span> <!-- -->: <span class="lg-highlight-string">"empty.jpg"</span>, <span class="lg-highlight-string">"imageSize"</span> <!-- -->: <span class="lg-highlight-number">0</span> }</td></tr></tbody></table></code></pre> </div> </div> </div> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Find Largest Binary Data <a class="headerlink leafygreen-ui-1kepx47" href="#find-largest-binary-data" 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="find-largest-binary-data"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> The following pipeline returns the image with the largest binary data size: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.images.aggregate([\n // First Stage\n { $project: { name: \"$name\", imageSize: { $binarySize: \"$binary\" } } },\n // Second Stage\n { $sort: { \"imageSize\" : -1 } },\n // Third Stage\n { $limit: 1 }\n])","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><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">images</span>.<span class="lg-highlight-title lg-highlight-function">aggregate</span>(<!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-comment">// First Stage</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">$project</span>: <!-- -->{ <span class="lg-highlight-attr">name</span>: <span class="lg-highlight-string">"$name"</span>, <span class="lg-highlight-attr">imageSize</span>: <!-- -->{ <span class="lg-highlight-attr">$binarySize</span>: <span class="lg-highlight-string">"$binary"</span> } } }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-comment">// Second Stage</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">$sort</span>: <!-- -->{ <span class="lg-highlight-string">"imageSize"</span> <!-- -->: <!-- -->-<span class="lg-highlight-number">1</span> } }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-comment">// Third Stage</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">$limit</span>: <span class="lg-highlight-number">1</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">])</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> <dl> <dt> First Stage </dt> <dd class="css-1ufxuu7"> <p class="leafygreen-ui-1kp3ins"> The first stage of the pipeline <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/project/#mongodb-pipeline-pipe.-project"> <code class="leafygreen-ui-1l06pbn"> projects </code> : </a> </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> The <code class="leafygreen-ui-1l06pbn"> name </code> field </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> The <code class="leafygreen-ui-1l06pbn"> imageSize </code> field, which uses <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-expression-exp.-binarySize" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $binarySize </code> </span> </a> to return the size of the document's <code class="leafygreen-ui-1l06pbn"> binary </code> field in bytes. </p> </li> </ul> <p class="leafygreen-ui-1kp3ins"> This stage outputs the following documents to the next stage: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ \"_id\" : 1, \"name\" : \"cat.jpg\", \"imageSize\" : 16 }\n{ \"_id\" : 2, \"name\" : \"big_ben.jpg\", \"imageSize\" : 41 }\n{ \"_id\" : 3, \"name\" : \"teaset.jpg\", \"imageSize\" : 16 }\n{ \"_id\" : 4, \"name\" : \"concert.jpg\", \"imageSize\" : 269 }\n{ \"_id\" : 5, \"name\" : \"empty.jpg\", \"imageSize\" : 0 }","programmingLanguage":"JavaScript"} </script> <div class="css-1lju8ps"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1jheeh3"> <pre class="leafygreen-ui-1453az5" 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">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">1</span>, <span class="lg-highlight-string">"name"</span> <!-- -->: <span class="lg-highlight-string">"cat.jpg"</span>, <span class="lg-highlight-string">"imageSize"</span> <!-- -->: <span class="lg-highlight-number">16</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">2</span>, <span class="lg-highlight-string">"name"</span> <!-- -->: <span class="lg-highlight-string">"big_ben.jpg"</span>, <span class="lg-highlight-string">"imageSize"</span> <!-- -->: <span class="lg-highlight-number">41</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">3</span>, <span class="lg-highlight-string">"name"</span> <!-- -->: <span class="lg-highlight-string">"teaset.jpg"</span>, <span class="lg-highlight-string">"imageSize"</span> <!-- -->: <span class="lg-highlight-number">16</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">4</span>, <span class="lg-highlight-string">"name"</span> <!-- -->: <span class="lg-highlight-string">"concert.jpg"</span>, <span class="lg-highlight-string">"imageSize"</span> <!-- -->: <span class="lg-highlight-number">269</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">5</span>, <span class="lg-highlight-string">"name"</span> <!-- -->: <span class="lg-highlight-string">"empty.jpg"</span>, <span class="lg-highlight-string">"imageSize"</span> <!-- -->: <span class="lg-highlight-number">0</span> }</td></tr></tbody></table></code></pre> </div> </div> </div> </dd> <dt> Second Stage </dt> <dd class="css-1ufxuu7"> <p class="leafygreen-ui-1kp3ins"> The second stage <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/sort/#mongodb-pipeline-pipe.-sort"> <code class="leafygreen-ui-1l06pbn"> sorts </code> </a> the documents by <code class="leafygreen-ui-1l06pbn"> imageSize </code> in descending order. </p> <p class="leafygreen-ui-1kp3ins"> This stage outputs the following documents to the next stage: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ \"_id\" : 4, \"name\" : \"concert.jpg\", \"imageSize\" : 269 }\n{ \"_id\" : 2, \"name\" : \"big_ben.jpg\", \"imageSize\" : 41 }\n{ \"_id\" : 1, \"name\" : \"cat.jpg\", \"imageSize\" : 16 }\n{ \"_id\" : 3, \"name\" : \"teaset.jpg\", \"imageSize\" : 16 }\n{ \"_id\" : 5, \"name\" : \"empty.jpg\", \"imageSize\" : 0 }","programmingLanguage":"JavaScript"} </script> <div class="css-1lju8ps"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1jheeh3"> <pre class="leafygreen-ui-1453az5" 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">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">4</span>, <span class="lg-highlight-string">"name"</span> <!-- -->: <span class="lg-highlight-string">"concert.jpg"</span>, <span class="lg-highlight-string">"imageSize"</span> <!-- -->: <span class="lg-highlight-number">269</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">2</span>, <span class="lg-highlight-string">"name"</span> <!-- -->: <span class="lg-highlight-string">"big_ben.jpg"</span>, <span class="lg-highlight-string">"imageSize"</span> <!-- -->: <span class="lg-highlight-number">41</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">1</span>, <span class="lg-highlight-string">"name"</span> <!-- -->: <span class="lg-highlight-string">"cat.jpg"</span>, <span class="lg-highlight-string">"imageSize"</span> <!-- -->: <span class="lg-highlight-number">16</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">3</span>, <span class="lg-highlight-string">"name"</span> <!-- -->: <span class="lg-highlight-string">"teaset.jpg"</span>, <span class="lg-highlight-string">"imageSize"</span> <!-- -->: <span class="lg-highlight-number">16</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">5</span>, <span class="lg-highlight-string">"name"</span> <!-- -->: <span class="lg-highlight-string">"empty.jpg"</span>, <span class="lg-highlight-string">"imageSize"</span> <!-- -->: <span class="lg-highlight-number">0</span> }</td></tr></tbody></table></code></pre> </div> </div> </div> </dd> <dt> Third Stage </dt> <dd class="css-1ufxuu7"> <p class="leafygreen-ui-1kp3ins"> The third stage <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/limit/#mongodb-pipeline-pipe.-limit"> <code class="leafygreen-ui-1l06pbn"> limits </code> </a> the output documents to only return the document appearing first in the sort order: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ \"_id\" : 4, \"name\" : \"concert.jpg\", \"imageSize\" : 269 }","programmingLanguage":"JavaScript"} </script> <div class="css-1lju8ps"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1jheeh3"> <pre class="leafygreen-ui-1agdxuk" 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">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">4</span>, <span class="lg-highlight-string">"name"</span> <!-- -->: <span class="lg-highlight-string">"concert.jpg"</span>, <span class="lg-highlight-string">"imageSize"</span> <!-- -->: <span class="lg-highlight-number">269</span> }</td></tr></tbody></table></code></pre> </div> </div> </div> </dd> </dl> <div class="leafygreen-ui-13vw3ie" role="note"> <h2 class="leafygreen-ui-1fn4p2b"> Tip </h2> <h3 class="leafygreen-ui-144d5kf"> <strong> See also: </strong> </h3> <div class="leafygreen-ui-9mycqc"> <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/project/#mongodb-pipeline-pipe.-project"> <code class="leafygreen-ui-1l06pbn"> $project </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/sort/#mongodb-pipeline-pipe.-sort"> <code class="leafygreen-ui-1l06pbn"> $sort </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/limit/#mongodb-pipeline-pipe.-limit"> <code class="leafygreen-ui-1l06pbn"> $limit </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/strLenBytes/#mongodb-expression-exp.-strLenBytes"> <code class="leafygreen-ui-1l06pbn"> $strLenBytes </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/bsonSize/#mongodb-expression-exp.-bsonSize"> <code class="leafygreen-ui-1l06pbn"> $bsonSize </code> </a> </p> </li> </ul> </div> </div> </section> </section> </section>
https://www.mongodb.com/docs/manual/reference/cluster-parameters/defaultMaxTimeMS/
<section> <h1 class="contains-headerlink leafygreen-ui-41fr9s" weight="medium"> defaultMaxTimeMS <a class="headerlink leafygreen-ui-1kepx47" href="#defaultmaxtimems" 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="defaultmaxtimems"> </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="#definition" target="_self"> <span> Definition </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#access-control" target="_self"> <span> Access Control </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#syntax" target="_self"> <span> Syntax </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#behavior" target="_self"> <span> Behavior </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-x9koo9" href="#long-running-queries" target="_self"> <span> Long-Running Queries </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#example" target="_self"> <span> Example </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-x9koo9" href="#results" target="_self"> <span> Results </span> </a> </li> </ul> </div> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Definition <a class="headerlink leafygreen-ui-1kepx47" href="#definition" 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="definition"> </div> </a> </h2> <dl class="parameter"> <dt> <code class="leafygreen-ui-1l06pbn"> defaultMaxTimeMS </code> <a class="headerlink leafygreen-ui-1kepx47" href="#mongodb-parameter-param.defaultMaxTimeMS" title="Permalink to this definition"> <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="mongodb-parameter-param.defaultMaxTimeMS"> </div> </a> </dt> <dd> <div> <p> <em> New <!-- --> in version <!-- --> 8.0 </em> . </p> </div> <p class="leafygreen-ui-1kp3ins"> Available for both <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> and <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongos/#mongodb-binary-bin.mongos"> <code class="leafygreen-ui-1l06pbn"> mongos </code> . </a> </p> <p class="leafygreen-ui-1kp3ins"> Specifies a default time limit in milliseconds for individual read operations to complete. If a query specifies a <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/cursor.maxTimeMS/#mongodb-method-cursor.maxTimeMS"> <code class="leafygreen-ui-1l06pbn"> maxTimeMS() </code> </a> option, that value overrides the <code class="leafygreen-ui-1l06pbn"> defaultMaxTimeMS </code> value. </p> <p class="leafygreen-ui-1kp3ins"> <code class="leafygreen-ui-1l06pbn"> defaultMaxTimeMS </code> applies to the following read operations: </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/command/aggregate/#mongodb-dbcommand-dbcmd.aggregate"> <code class="leafygreen-ui-1l06pbn"> aggregate </code> </a> (except <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/merge/#mongodb-pipeline-pipe.-merge"> <code class="leafygreen-ui-1l06pbn"> $merge </code> </a> and <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/out/#mongodb-pipeline-pipe.-out"> <code class="leafygreen-ui-1l06pbn"> $out </code> </a> stages) </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/command/count/#mongodb-dbcommand-dbcmd.count"> <code class="leafygreen-ui-1l06pbn"> count </code> </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/command/dbHash/#mongodb-dbcommand-dbcmd.dbHash"> <code class="leafygreen-ui-1l06pbn"> dbHash </code> </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/command/distinct/#mongodb-dbcommand-dbcmd.distinct"> <code class="leafygreen-ui-1l06pbn"> distinct </code> </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/command/find/#mongodb-dbcommand-dbcmd.find"> <code class="leafygreen-ui-1l06pbn"> find </code> </a> </p> </li> </ul> </dd> </dl> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Access Control <a class="headerlink leafygreen-ui-1kepx47" href="#access-control" 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="access-control"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> To modify cluster parameters, you must <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/authentication/#std-label-authentication"> authenticate </a> as a user that has one of the following roles: </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/built-in-roles/#mongodb-authrole-clusterAdmin"> <code class="leafygreen-ui-1l06pbn"> clusterAdmin </code> </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/built-in-roles/#mongodb-authrole-clusterMonitor"> <code class="leafygreen-ui-1l06pbn"> clusterMonitor </code> </a> </p> </li> </ul> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Syntax <a class="headerlink leafygreen-ui-1kepx47" href="#syntax" 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="syntax"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> To set <code class="leafygreen-ui-1l06pbn"> defaultMaxTimeMS </code> for your deployment, run the following command on the <code class="leafygreen-ui-1l06pbn"> admin </code> database: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.adminCommand(\n {\n setClusterParameter: {\n defaultMaxTimeMS: { readOperations: &lt;value&gt; }\n }\n }\n)","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">adminCommand</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">setClusterParameter</span>: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">defaultMaxTimeMS</span>: <!-- -->{ <span class="lg-highlight-attr">readOperations</span>: &lt;<!-- -->value<!-- -->&gt; <!-- -->}</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">)</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"> To view the current value for <code class="leafygreen-ui-1l06pbn"> defaultMaxTimeMS </code> , run the following command on the <code class="leafygreen-ui-1l06pbn"> admin </code> database: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.adminCommand( { getClusterParameter: \"defaultMaxTimeMS\" } )","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-1q4bxgx" tabindex="0"><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">adminCommand</span>( <!-- -->{ <span class="lg-highlight-attr">getClusterParameter</span>: <span class="lg-highlight-string">"defaultMaxTimeMS"</span> } )</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> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Behavior <a class="headerlink leafygreen-ui-1kepx47" href="#behavior" 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="behavior"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> By default, <code class="leafygreen-ui-1l06pbn"> defaultMaxTimeMS.readOperations </code> is 0, meaning no default query timeout is set. If there is no default query timeout, the query runs until it either returns a result or fails. </p> <p class="leafygreen-ui-1kp3ins"> If a query specifies a <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/cursor.maxTimeMS/#mongodb-method-cursor.maxTimeMS"> <code class="leafygreen-ui-1l06pbn"> maxTimeMS() </code> </a> option, that value overrides the <code class="leafygreen-ui-1l06pbn"> defaultMaxTimeMS </code> value. </p> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Long-Running Queries <a class="headerlink leafygreen-ui-1kepx47" href="#long-running-queries" 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="long-running-queries"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> If your deployment needs to run long queries, such as <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/atlas/reference/faq/deployment/#std-label-analytics-nodes-overview" target="_self"> <span> analytics node </span> </a> queries, you must specify a timeout for those queries at the operation level using <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/cursor.maxTimeMS/#mongodb-method-cursor.maxTimeMS"> <code class="leafygreen-ui-1l06pbn"> maxTimeMS() </code> </a> . If you don't specify an operation timeout, those queries use the <code class="leafygreen-ui-1l06pbn"> defaultMaxTimeMS </code> timeout, and won't run for the required amount of time. </p> </section> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Example <a class="headerlink leafygreen-ui-1kepx47" href="#example" 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="example"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> The following command sets the default query timeout <code class="leafygreen-ui-1l06pbn"> 5000 </code> milliseconds: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.runCommand( {\n setClusterParameter: {\n defaultMaxTimeMS: { readOperations: 5000 }\n }\n} )","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">runCommand</span>( <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">setClusterParameter</span>: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">defaultMaxTimeMS</span>: <!-- -->{ <span class="lg-highlight-attr">readOperations</span>: <span class="lg-highlight-number">5000</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">} )</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"> To check the value of <code class="leafygreen-ui-1l06pbn"> defaultMaxTimeMS </code> , run the following command: </p> <div class="css-1f5771r"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.adminCommand( { getClusterParameter: \"defaultMaxTimeMS\" } )","programmingLanguage":"JavaScript"} </script> <div class="css-1lju8ps"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1jheeh3"> <pre class="leafygreen-ui-1agdxuk" 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">adminCommand</span>( <!-- -->{ <span class="lg-highlight-attr">getClusterParameter</span>: <span class="lg-highlight-string">"defaultMaxTimeMS"</span> } )</td></tr></tbody></table></code></pre> </div> </div> </div> <div class="css-9st569 efa38qy0" style="--border-color:#E8EDEB"> <button aria-disabled="false" class="lg-ui-button-0000 leafygreen-ui-hix6y6" data-lgid="lg-button" role="button" type="button"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg alt="" aria-hidden="true" class="leafygreen-ui-hjnzs9" fill="none" height="16" role="presentation" viewbox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M14.364 10.778a1 1 0 0 0 0-1.414l-4.95-4.95-.707-.707a1 1 0 0 0-1.414 0l-.707.707-4.95 4.95a1 1 0 0 0 0 1.414l.707.707a1 1 0 0 0 1.414 0L8 7.243l4.243 4.242a1 1 0 0 0 1.414 0l.707-.707Z" fill="currentColor" fill-rule="evenodd"> </path> </svg> HIDE OUTPUT </div> </button> </div> <div class="leafygreen-ui-1oteowz"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{\n \"clusterParameters\" : [\n {\n \"_id\" : \"defaultMaxTimeMS\",\n \"clusterParameterTime\" : Timestamp(1711564868, 17),\n \"readOperations\" : NumberLong(5000)\n }\n ],\n \"ok\" : 1,\n \"$clusterTime\" : {\n \"clusterTime\" : Timestamp(1712161244, 1),\n \"signature\" : {\n \"hash\" : BinData(0,\"AAAAAAAAAAAAAAAAAAAAAAAAAAA=\"),\n \"keyId\" : NumberLong(0)\n }\n },\n \"operationTime\" : Timestamp(1712161244, 1)\n}","programmingLanguage":"JavaScript"} </script> <div class="css-1sax7hu e11q6jfk0" style="--code-container-border:initial;--code-pre-border:none"> <div class="leafygreen-ui-1fyvhqe"> <div class="leafygreen-ui-1jheeh3"> <pre class="leafygreen-ui-12cejcz" tabindex="-1"><code class="lg-highlight-hljs-dark javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"clusterParameters"</span> <!-- -->: <!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-string">"defaultMaxTimeMS"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"clusterParameterTime"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">Timestamp</span>(<span class="lg-highlight-number">1711564868</span>, <span class="lg-highlight-number">17</span>)<!-- -->,</td></tr><tr class="leafygreen-ui-xe5l08"><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"readOperations"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">NumberLong</span>(<span class="lg-highlight-number">5000</span>)</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> ]<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"ok"</span> <!-- -->: <span class="lg-highlight-number">1</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"$clusterTime"</span> <!-- -->: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"clusterTime"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">Timestamp</span>(<span class="lg-highlight-number">1712161244</span>, <span class="lg-highlight-number">1</span>)<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"signature"</span> <!-- -->: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"hash"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">BinData</span>(<span class="lg-highlight-number">0</span>,<span class="lg-highlight-string">"AAAAAAAAAAAAAAAAAAAAAAAAAAA="</span>)<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"keyId"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">NumberLong</span>(<span class="lg-highlight-number">0</span>)</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"operationTime"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">Timestamp</span>(<span class="lg-highlight-number">1712161244</span>, <span class="lg-highlight-number">1</span>)</td></tr><tr class=""><td class="leafygreen-ui-7razhx">}</td></tr></tbody></table></code></pre> </div> </div> </div> </div> </div> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Results <a class="headerlink leafygreen-ui-1kepx47" href="#results" 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="results"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> After you set <code class="leafygreen-ui-1l06pbn"> defaultMaxTimeMS </code> for your deployment, consider these queries: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.test.find( { name: \"Carol\" } )\n\ndb.test.find( { name: \"Carol\" } ).maxTimeMS( 8000 )","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">test</span>.<span class="lg-highlight-title lg-highlight-function">find</span>( <!-- -->{ <span class="lg-highlight-attr">name</span>: <span class="lg-highlight-string">"Carol"</span> } )</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><div class="leafygreen-ui-ihxujy"></div></td></tr><tr class=""><td class="leafygreen-ui-7razhx">db.<span class="lg-highlight-property">test</span>.<span class="lg-highlight-title lg-highlight-function">find</span>( <!-- -->{ <span class="lg-highlight-attr">name</span>: <span class="lg-highlight-string">"Carol"</span> } ).<span class="lg-highlight-title lg-highlight-function">maxTimeMS</span>( <span class="lg-highlight-number">8000</span> )</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 first query uses the <code class="leafygreen-ui-1l06pbn"> defaultMaxTimeMS </code> value of 5,000 milliseconds. </p> <p class="leafygreen-ui-1kp3ins"> The second query specifies <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/cursor.maxTimeMS/#mongodb-method-cursor.maxTimeMS"> <code class="leafygreen-ui-1l06pbn"> maxTimeMS() </code> </a> , which overrides the <code class="leafygreen-ui-1l06pbn"> defaultMaxTimeMS </code> and causes the query to timeout after 8,000 milliseconds. </p> </section> </section> </section>
https://www.mongodb.com/docs/manual/reference/method/ClientEncryption.decrypt/
<section> <h1 class="contains-headerlink leafygreen-ui-41fr9s" weight="medium"> ClientEncryption.decrypt() <a class="headerlink leafygreen-ui-1kepx47" href="#clientencryption.decrypt--" 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="clientencryption.decrypt--"> </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="#syntax" target="_self"> <span> Syntax </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#behavior" target="_self"> <span> Behavior </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#example" target="_self"> <span> Example </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#learn-more" target="_self"> <span> Learn More </span> </a> </li> </ul> </div> <dl class="method"> <dt> <code class="leafygreen-ui-1l06pbn"> ClientEncryption.decrypt(encryptedValue) </code> <a class="headerlink leafygreen-ui-1kepx47" href="#mongodb-method-ClientEncryption.decrypt" title="Permalink to this definition"> <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="mongodb-method-ClientEncryption.decrypt"> </div> </a> </dt> <dd> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-method-ClientEncryption.decrypt" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> ClientEncryption.decrypt() </code> </span> </a> decrypts the <code class="leafygreen-ui-1l06pbn"> encryptionValue </code> <em> if </em> the current database connection was configured with access to the Key Management Service (KMS) and key vault used to encrypt <code class="leafygreen-ui-1l06pbn"> encryptionValue </code> . </p> <table class="css-11h39yh e1nex8bq0"> <colgroup> <col class="field-name"/> <col class="field-body"/> </colgroup> <tbody> <tr class="css-x8snli"> <th> Returns <!-- --> : </th> <td> The decrypted value. </td> </tr> </tbody> </table> </dd> </dl> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Syntax <a class="headerlink leafygreen-ui-1kepx47" href="#syntax" 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="syntax"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> <code class="leafygreen-ui-1l06pbn"> ClientEncryption.decrypt </code> has the following syntax: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"clientEncryption = db.getMongo().getClientEncryption()\n\nclientEncryption.decrypt(encryptedValue)","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">clientEncryption <!-- -->= <!-- -->db.<span class="lg-highlight-title lg-highlight-function">getMongo</span>(<!-- -->).<span class="lg-highlight-title lg-highlight-function">getClientEncryption</span>(<!-- -->)</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><div class="leafygreen-ui-ihxujy"></div></td></tr><tr class=""><td class="leafygreen-ui-7razhx">clientEncryption.<span class="lg-highlight-title lg-highlight-function">decrypt</span>(<!-- -->encryptedValue)</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 <code class="leafygreen-ui-1l06pbn"> encryptedValue </code> <em> must </em> be a <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/mongodb-extended-json/#mongodb-bsontype-Binary"> <code class="leafygreen-ui-1l06pbn"> binary data </code> </a> object with <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://github.com/mongodb/specifications/blob/master/source/client-side-encryption/subtype6.rst" rel="noopener noreferrer"> <span> subtype 6 </span> <svg alt="" aria-hidden="true" class="leafygreen-ui-1ie5kuq" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M13.823 2.4491C13.8201 2.30008 13.6999 2.17994 13.5509 2.17704L9.5062 2.09836C9.25654 2.09351 9.12821 2.39519 9.30482 2.5718L10.3856 3.65257L7.93433 6.10383C7.87964 6.15852 7.83047 6.21665 7.78683 6.27752L5.99909 8.06525C5.46457 8.59977 5.46457 9.4664 5.99909 10.0009C6.53361 10.5354 7.40023 10.5354 7.93475 10.0009L9.72249 8.21317C9.78336 8.16953 9.84148 8.12037 9.89618 8.06567L12.3474 5.61441L13.4282 6.69518C13.6048 6.87179 13.9065 6.74347 13.9016 6.4938L13.823 2.4491Z" fill="currentColor"> </path> <path d="M7.25 3.12893C7.66421 3.12893 8 3.46472 8 3.87893C8 4.29315 7.66421 4.62893 7.25 4.62893H4C3.72386 4.62893 3.5 4.85279 3.5 5.12893V11.9929C3.5 12.2691 3.72386 12.4929 4 12.4929H10.864C11.1401 12.4929 11.364 12.2691 11.364 11.9929V8.75C11.364 8.33579 11.6998 8 12.114 8C12.5282 8 12.864 8.33579 12.864 8.75V11.9929C12.864 13.0975 11.9686 13.9929 10.864 13.9929H4C2.89543 13.9929 2 13.0975 2 11.9929V5.12893C2 4.02436 2.89543 3.12893 4 3.12893H7.25Z" fill="currentColor"> </path> </svg> </a> created using client-side field level encryption. </p> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Behavior <a class="headerlink leafygreen-ui-1kepx47" href="#behavior" 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="behavior"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> Read operations issued from a database connection <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/Mongo/#mongodb-method-Mongo"> <code class="leafygreen-ui-1l06pbn"> configured </code> </a> with access to the correct Key Management Service (KMS) and Key Vault can automatically decrypt field values encrypted using <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/ClientEncryption.encrypt/#mongodb-method-ClientEncryption.encrypt"> <code class="leafygreen-ui-1l06pbn"> ClientEncryption.encrypt() </code> </a> . Clients only need to use <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-method-ClientEncryption.decrypt" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> decrypt() </code> </span> </a> to decrypt <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/mongodb-extended-json/#mongodb-bsontype-Binary"> <code class="leafygreen-ui-1l06pbn"> Binary </code> </a> subtype 6 values not stored within a document field. </p> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Enable Client-Side Field Level Encryption on Database Connection <a class="headerlink leafygreen-ui-1kepx47" href="#enable-client-side-field-level-encryption-on-database-connection" 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="enable-client-side-field-level-encryption-on-database-connection"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> The <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/mongodb-shell/#mongodb-binary-bin.mongosh" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongosh </code> </span> </a> client-side field level encryption methods require a database connection with client-side field level encryption enabled. If the current database connection was not initiated with client-side field level encryption enabled, either: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Use the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/Mongo/#mongodb-method-Mongo"> <code class="leafygreen-ui-1l06pbn"> Mongo() </code> </a> constructor from the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/mongodb-shell/#mongodb-binary-bin.mongosh" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongosh </code> </span> </a> to establish a connection with the required client-side field level encryption options. The <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/Mongo/#mongodb-method-Mongo"> <code class="leafygreen-ui-1l06pbn"> Mongo() </code> </a> method supports the following Key Management Service (KMS) providers for Customer Master Key (CMK) management: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/queryable-encryption/fundamentals/kms-providers/#std-label-qe-fundamentals-kms-providers-aws"> Amazon Web Services KMS </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/queryable-encryption/fundamentals/kms-providers/#std-label-qe-fundamentals-kms-providers-azure"> Azure Key Vault </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/queryable-encryption/fundamentals/kms-providers/#std-label-qe-fundamentals-kms-providers-gcp"> Google Cloud Platform KMS </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/queryable-encryption/fundamentals/kms-providers/#std-label-qe-fundamentals-kms-providers-local"> Locally Managed Key </a> </p> </li> </ul> <p class="leafygreen-ui-1kp3ins"> <em> or </em> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Use the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/mongodb-shell/#mongodb-binary-bin.mongosh" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongosh </code> </span> </a> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/mongodb-shell/reference/options/#std-label-mongosh-client-side-field-level-encryption-options" target="_self"> <span> command line options </span> </a> to establish a connection with the required options. The command line options only support the <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/queryable-encryption/fundamentals/kms-providers/#std-label-qe-fundamentals-kms-providers-aws"> Amazon Web Services KMS </a> provider for CMK management. </p> </li> </ul> </section> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Example <a class="headerlink leafygreen-ui-1kepx47" href="#example" 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="example"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> The following example uses a locally managed KMS for the client-side field level encryption configuration. </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"HowTo","steps":[{"@type":"HowToStep","text":"Start mongoshRun:--nodb means don't connect to a database.Generate a Key StringGenerate a base 64 96-byte string:Create an Encryption Options ObjectTo create a client-side field level encryption options object, use\nthe TEST_LOCAL_KEY string from the previous step:Create an Encrypted Client ObjectTo create an encrypted client object, use the Mongo()\nconstructor. Replace the mongodb://myMongo.example.net URI with\nthe connection string URI for the target\ncluster. For example:","name":"Create Your Encrypted Connection"},{"@type":"HowToStep","text":"Retrieve the ClientEncryption object\nand use the ClientEncryption.decrypt() method to decrypt\na value encrypted by ClientEncryption.encrypt().","name":"Decrypt Your Data"}],"name":"Example","image":"https://webimages.mongodb.com/_com_assets/cms/kuyj2focmkbxv7gh3-stacked_default_slate_blue.svg?auto=format%252Ccompress"} </script> <div class="css-4nyere eccljxs0"> <div class="css-1nuklj8 e1ckbxcu1"> <div class="css-18fui5z e1ckbxcu0"> <div class="css-19lsqsq e1ckbxcu2"> 1 </div> </div> <div class="css-1ed38mk"> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Create Your Encrypted Connection <a class="headerlink leafygreen-ui-1kepx47" href="#create-your-encrypted-connection" 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="create-your-encrypted-connection"> </div> </a> </h3> <ol class="leafygreen-ui-rioki0" type="a"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Start mongosh </p> <p class="leafygreen-ui-1kp3ins"> Run: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"mongosh --nodb","programmingLanguage":"Bash"} </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 bash leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">mongosh --nodb</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"> <code class="leafygreen-ui-1l06pbn"> --nodb </code> means don't connect to a database. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Generate a Key String </p> <p class="leafygreen-ui-1kp3ins"> Generate a base 64 96-byte string: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"const TEST_LOCAL_KEY = require(\"crypto\").randomBytes(96).toString(\"base64\")","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-1q4bxgx" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-keyword">const</span> <span class="lg-highlight-variable lg-highlight-constant">TEST_LOCAL_KEY</span> <!-- -->= <span class="lg-highlight-built_in">require</span>(<span class="lg-highlight-string">"crypto"</span>).<span class="lg-highlight-title lg-highlight-function">randomBytes</span>(<span class="lg-highlight-number">96</span>).<span class="lg-highlight-title lg-highlight-function">toString</span>(<span class="lg-highlight-string">"base64"</span>)</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> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Create an Encryption Options Object </p> <p class="leafygreen-ui-1kp3ins"> To create a client-side field level encryption options object, use the <code class="leafygreen-ui-1l06pbn"> TEST_LOCAL_KEY </code> string from the previous step: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":" var autoEncryptionOpts = {\n \"keyVaultNamespace\" : \"encryption.__dataKeys\",\n \"kmsProviders\" : {\n \"local\" : {\n \"key\" : BinData(0, TEST_LOCAL_KEY)\n }\n }\n }","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-keyword">var</span> autoEncryptionOpts <!-- -->= <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"keyVaultNamespace"</span> <!-- -->: <span class="lg-highlight-string">"encryption.__dataKeys"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"kmsProviders"</span> <!-- -->: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"local"</span> <!-- -->: <!-- -->{</td></tr><tr class="leafygreen-ui-1wr1lm6"><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"key"</span> <!-- -->: <span class="lg-highlight-title lg-highlight-class">BinData</span>(<span class="lg-highlight-number">0</span>, <span class="lg-highlight-variable lg-highlight-constant">TEST_LOCAL_KEY</span>)</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</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> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Create an Encrypted Client Object </p> <p class="leafygreen-ui-1kp3ins"> To create an encrypted client object, use the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/Mongo/#mongodb-method-Mongo"> <code class="leafygreen-ui-1l06pbn"> Mongo() </code> </a> constructor. Replace the <code class="leafygreen-ui-1l06pbn"> mongodb://myMongo.example.net </code> URI with the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/connection-string/#std-label-mongodb-uri"> connection string URI </a> for the target cluster. For example: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"encryptedClient = Mongo(\n \"mongodb://myMongo.example.net:27017/?replSetName=myMongo\",\n autoEncryptionOpts\n)","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">encryptedClient <!-- -->= <span class="lg-highlight-title lg-highlight-class">Mongo</span>(</td></tr><tr class="leafygreen-ui-1wr1lm6"><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"mongodb://myMongo.example.net:27017/?replSetName=myMongo"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->autoEncryptionOpts</td></tr><tr class=""><td class="leafygreen-ui-7razhx">)</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> </li> </ol> </section> </div> </div> <div class="css-1nuklj8 e1ckbxcu1"> <div class="css-18fui5z e1ckbxcu0"> <div class="css-19lsqsq e1ckbxcu2"> 2 </div> </div> <div class="css-1ed38mk"> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Decrypt Your Data <a class="headerlink leafygreen-ui-1kepx47" href="#decrypt-your-data" 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="decrypt-your-data"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> Retrieve the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/getClientEncryption/#mongodb-method-getClientEncryption"> <code class="leafygreen-ui-1l06pbn"> ClientEncryption </code> </a> object and use the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-method-ClientEncryption.decrypt" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> ClientEncryption.decrypt() </code> </span> </a> method to decrypt a value encrypted by <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/ClientEncryption.encrypt/#mongodb-method-ClientEncryption.encrypt"> <code class="leafygreen-ui-1l06pbn"> ClientEncryption.encrypt() </code> . </a> </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"clientEncryption = encryptedClient.getClientEncryption();\n\nclientEncryption.decrypt(BinData(6,\"AmTi2H3xaEk8u9+jlFNaLLkC3Q/+kmwDbbWrq+h9nuv9W+u7A5a0UnpULBNZH+Q21fAztPpU09wpKPrju9dKfpN1Afpj1/ZhFcH6LYZOWSBBOAuUNjPLxMNSYOOuITuuYWo=\"))","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">clientEncryption <!-- -->= <!-- -->encryptedClient.<span class="lg-highlight-title lg-highlight-function">getClientEncryption</span>(<!-- -->)<!-- -->;</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><div class="leafygreen-ui-ihxujy"></div></td></tr><tr class=""><td class="leafygreen-ui-7razhx">clientEncryption.<span class="lg-highlight-title lg-highlight-function">decrypt</span>(<span class="lg-highlight-title lg-highlight-class">BinData</span>(<span class="lg-highlight-number">6</span>,<span class="lg-highlight-string">"AmTi2H3xaEk8u9+jlFNaLLkC3Q/+kmwDbbWrq+h9nuv9W+u7A5a0UnpULBNZH+Q21fAztPpU09wpKPrju9dKfpN1Afpj1/ZhFcH6LYZOWSBBOAuUNjPLxMNSYOOuITuuYWo="</span>))</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> </section> </div> </div> </div> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Example Results <a class="headerlink leafygreen-ui-1kepx47" href="#example-results" 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="example-results"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> If successful, <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-method-ClientEncryption.decrypt" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> decrypt() </code> </span> </a> returns the decrypted value: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"\"123-45-6789\"","programmingLanguage":"JavaScript"} </script> <div class="css-1lju8ps"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1jheeh3"> <pre class="leafygreen-ui-1agdxuk" 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"><span class="lg-highlight-string">"123-45-6789"</span></td></tr></tbody></table></code></pre> </div> </div> </div> </section> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Learn More <a class="headerlink leafygreen-ui-1kepx47" href="#learn-more" 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="learn-more"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> For complete documentation on initiating MongoDB connections with client-side field level encryption enabled, see <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/Mongo/#mongodb-method-Mongo"> <code class="leafygreen-ui-1l06pbn"> Mongo() </code> . </a> </p> </section> </section>
https://www.mongodb.com/docs/manual/reference/method/db.collection.insertMany/
<section> <h1 class="contains-headerlink leafygreen-ui-41fr9s" weight="medium"> db.collection.insertMany() <a class="headerlink leafygreen-ui-1kepx47" href="#db.collection.insertmany--" 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.insertmany--"> </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="#definition" target="_self"> <span> Definition </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#compatibility" target="_self"> <span> Compatibility </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#syntax" target="_self"> <span> Syntax </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#behaviors" target="_self"> <span> Behaviors </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#examples" target="_self"> <span> Examples </span> </a> </li> </ul> </div> <div class="leafygreen-ui-147elvs"> <p class="leafygreen-ui-1ronz74"> MongoDB with drivers </p> <div class="leafygreen-ui-18k5rfm"> <p class="leafygreen-ui-1kp3ins"> This page documents a <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/mongodb-shell/#mongodb-binary-bin.mongosh" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongosh </code> </span> </a> method. To see the equivalent method in a MongoDB driver, see the corresponding page for your programming language: </p> </div> <div class="leafygreen-ui-zgrwqu notranslate"> <a class="leafygreen-ui-v22cck" href="https://www.mongodb.com/docs/drivers/csharp/current/fundamentals/crud/write-operations/insert/#insert-multiple-documents" target="_self"> <svg class="leafygreen-ui-x3zji3" fill="none" height="24" viewbox="0 0 28 29" width="24" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_1351_59964)"> <g clip-path="url(#clip1_1351_59964)"> <path d="M25.7709 9.2495C25.7709 8.79827 25.678 8.39408 25.4827 8.04627C25.2874 7.70785 25.0084 7.42586 24.627 7.20025C21.465 5.35781 18.2937 3.51538 15.1317 1.67295C14.2761 1.17474 13.4484 1.19354 12.6021 1.70115C11.3466 2.45316 5.04112 6.10042 3.15321 7.20025C2.3813 7.65142 2 8.34705 2 9.24005C2 12.9531 2 16.6568 2 20.3698C2 20.8117 2.093 21.2064 2.279 21.5449C2.4743 21.8927 2.7626 22.1841 3.15321 22.4191C5.03182 23.5189 11.3373 27.1662 12.6021 27.9182C13.4484 28.4258 14.2761 28.4446 15.1317 27.9463C18.2937 26.1039 21.465 24.2615 24.627 22.4191C25.0177 22.1935 25.306 21.9021 25.5012 21.5449C25.6873 21.2064 25.7803 20.8117 25.7803 20.3698C25.7709 20.3698 25.7709 12.9531 25.7709 9.2495Z" fill="#A179DC"> </path> <path d="M13.9227 14.7673L2.27905 21.5449C2.47435 21.8927 2.76265 22.1841 3.15326 22.4191C5.03187 23.5189 11.3373 27.1662 12.6021 27.9182C13.4484 28.4258 14.2762 28.4445 15.1317 27.9463C18.2938 26.1039 21.4651 24.2615 24.6271 22.4191C25.0177 22.1935 25.306 21.9021 25.5013 21.5449L13.9227 14.7673Z" fill="#280068"> </path> <path d="M25.7711 9.24949C25.7711 8.79827 25.6781 8.39408 25.4828 8.04626L13.9229 14.7768L25.4921 21.5543C25.6781 21.2159 25.7711 20.8211 25.7711 20.3793C25.7711 20.3699 25.7711 12.9531 25.7711 9.24949Z" fill="#390091"> </path> <path d="M20.7771 12.2387V13.5078H22.0325V12.2387H22.6557V13.5078H23.9111V14.1376H22.6557V15.4066H23.9111V16.0364H22.6557V17.3054H22.0325V16.0364H20.7771V17.3054H20.1539V16.0364H18.8984V15.4066H20.1539V14.1376H18.8984V13.5078H20.1539V12.2387H20.7771ZM22.0325 14.1376H20.7771V15.4066H22.0325V14.1376Z" fill="white"> </path> <path d="M13.9508 5.87482C17.2151 5.87482 20.0702 7.67022 21.6047 10.3399L21.5861 10.3117L17.7452 12.5489C16.9919 11.2517 15.5969 10.3775 14.0066 10.3587H13.9601C11.5328 10.3587 9.56116 12.3515 9.56116 14.805C9.56116 15.604 9.77503 16.3654 10.1377 17.014C10.9004 18.3488 12.3232 19.2512 13.9601 19.2512C15.6062 19.2512 17.0384 18.3394 17.7917 16.9858L17.7731 17.014L21.614 19.2606C20.0981 21.9021 17.2895 23.6975 14.0531 23.7257H13.9508C10.6679 23.7257 7.81274 21.9209 6.28753 19.2418C5.54353 17.9352 5.11572 16.4124 5.11572 14.7956C5.11572 9.87931 9.06825 5.87482 13.9508 5.87482Z" fill="white"> </path> </g> </g> <defs> <clippath id="clip0_1351_59964"> <rect fill="white" height="28" transform="translate(0 0.809265)" width="28"> </rect> </clippath> <clippath id="clip1_1351_59964"> <rect fill="white" height="27" transform="translate(2 1.30966)" width="24"> </rect> </clippath> </defs> </svg> <span> C# </span> </a> <a class="leafygreen-ui-v22cck" href="https://www.mongodb.com/docs/drivers/java/sync/current/fundamentals/crud/write-operations/insert/#insert-multiple-documents" target="_self"> <svg class="leafygreen-ui-x3zji3" fill="none" height="24" viewbox="0 0 30 41" width="24" xmlns="http://www.w3.org/2000/svg"> <path d="M10.0921 30.7949C10.0921 30.7949 8.57608 31.6793 11.166 31.9636C14.2929 32.311 15.9037 32.2794 19.3464 31.6161C19.3464 31.6161 20.2623 32.1846 21.5257 32.6901C13.7876 35.9748 4.02791 32.5005 10.0921 30.7949Z" fill="#0074BD"> </path> <path d="M9.14539 26.4678C9.14539 26.4678 7.43985 27.7312 10.0298 27.9838C13.3778 28.3312 15.9992 28.3628 20.579 27.4785C20.579 27.4785 21.2107 28.1101 22.1898 28.4576C12.8724 31.2054 2.44949 28.6787 9.14539 26.4678Z" fill="#0074BD"> </path> <path d="M17.1039 19.1398C18.9989 21.3191 16.5985 23.3089 16.5985 23.3089C16.5985 23.3089 21.431 20.8138 19.2201 17.6869C17.1355 14.7811 15.5563 13.3282 24.1788 8.33789C24.1473 8.33789 10.6607 11.6858 17.1039 19.1398Z" fill="#EA2D2E"> </path> <path d="M27.3377 33.9845C27.3377 33.9845 28.4431 34.9004 26.1059 35.6269C21.6525 36.985 7.53417 37.3957 3.61769 35.6901C2.19639 35.0899 4.84949 34.2372 5.67069 34.0477C6.52347 33.8582 7.02884 33.8898 7.02884 33.8898C5.44961 32.7843 -3.10981 36.0691 2.67016 36.9851C18.4308 39.5433 31.4121 35.8164 27.3377 33.9845Z" fill="#0074BD"> </path> <path d="M10.8194 21.983C10.8194 21.983 3.6497 23.6885 8.2926 24.3203C10.2509 24.5729 14.1357 24.5097 17.7995 24.2255C20.7685 23.9728 23.7375 23.4359 23.7375 23.4359C23.7375 23.4359 22.6951 23.8781 21.9372 24.415C14.6411 26.3416 0.585992 25.4257 4.62881 23.4675C8.00839 21.7935 10.8194 21.983 10.8194 21.983Z" fill="#0074BD"> </path> <path d="M23.6745 29.1846C31.0969 25.3313 27.6542 21.6359 25.2538 22.1413C24.6537 22.2676 24.401 22.3623 24.401 22.3623C24.401 22.3623 24.6221 22.0149 25.0327 21.8886C29.7703 20.2146 33.4025 26.7842 23.5166 29.4057C23.5482 29.3741 23.6429 29.2794 23.6745 29.1846Z" fill="#0074BD"> </path> <path d="M19.2206 0.25293C19.2206 0.25293 23.3266 4.35891 15.3357 10.6758C8.92404 15.7293 13.8828 18.6351 15.3357 21.9199C11.6087 18.5403 8.86088 15.5714 10.6928 12.792C13.3775 8.74919 20.863 6.79093 19.2206 0.25293Z" fill="#EA2D2E"> </path> <path d="M11.5455 39.6068C18.6521 40.049 29.5803 39.3541 29.833 35.9746C29.833 35.9746 29.3276 37.238 23.9583 38.2487C17.894 39.3858 10.4085 39.2594 5.95508 38.533C5.95508 38.5646 6.87103 39.3225 11.5455 39.6068Z" fill="#0074BD"> </path> </svg> <span> Java Sync </span> </a> <a class="leafygreen-ui-v22cck" href="https://www.mongodb.com/docs/drivers/node/current/fundamentals/crud/write-operations/insert/#insert-multiple-documents" target="_self"> <svg class="leafygreen-ui-x3zji3" fill="none" height="24" viewbox="0 0 30 30" width="24" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:R2dtlqcmqn9:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":R2dtlqcmqn9:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":R2dtlqcmqn9:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":R2dtlqcmqn9:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <span> Node.js </span> </a> <a class="leafygreen-ui-v22cck" href="https://www.mongodb.com/docs/languages/python/pymongo-driver/current/write/insert/#insert-multiple-documents" target="_self"> <svg class="leafygreen-ui-x3zji3" height="24" viewbox="0 0 111.6 147" width="24" xmlns="http://www.w3.org/2000/svg"> <lineargradient gradienttransform="matrix(.5625 0 0 -.568 -160.323 -146.09)" gradientunits="userSpaceOnUse" id=":R2htlqcmqn9:aa" x1="280.848" x2="389.865" y1="-268.463" y2="-362.257"> <stop offset="0" stop-color="#5a9fd4"> </stop> <stop offset="1" stop-color="#306998"> </stop> </lineargradient> <path d="M55.3 3.2c-4.6 0-9 .4-12.8 1.1-11.3 2-13.4 6.2-13.4 13.9v10.2h26.8v3.4H19c-7.8 0-14.6 4.7-16.8 13.6C-.3 55.6-.4 62 2.2 72.7c1.9 7.9 6.5 13.6 14.2 13.6h9.2V74c0-8.8 7.7-16.7 16.7-16.7h26.8c7.5 0 13.4-6.1 13.4-13.6V18.2c0-7.3-6.1-12.7-13.4-13.9-4.4-.8-9.2-1.1-13.8-1.1zm-14.5 8.2c2.8 0 5 2.3 5 5.1s-2.3 5.1-5 5.1c-2.8 0-5-2.3-5-5.1s2.2-5.1 5-5.1z" fill="url(#:R2htlqcmqn9:aa)"> </path> <lineargradient gradienttransform="matrix(.5625 0 0 -.568 -160.323 -146.09)" gradientunits="userSpaceOnUse" id=":R2htlqcmqn9:bb" x1="432.011" x2="393.081" y1="-419.025" y2="-363.946"> <stop offset="0" stop-color="#ffd43b"> </stop> <stop offset="1" stop-color="#ffe873"> </stop> </lineargradient> <path d="M86 31.8v11.9c0 9.2-7.8 17-16.8 17H42.5c-7.3 0-13.4 6.3-13.4 13.6v25.5c0 7.3 6.3 11.5 13.4 13.6 8.5 2.5 16.6 2.9 26.8 0 6.8-2 13.4-5.9 13.4-13.6V89.7H55.9v-3.4h40.2c7.8 0 10.7-5.4 13.4-13.6 2.8-8.4 2.7-16.5 0-27.3-1.9-7.8-5.6-13.6-13.4-13.6H86zM71 96.5c2.8 0 5 2.3 5 5.1s-2.3 5.1-5 5.1c-2.8 0-5-2.3-5-5.1-.1-2.8 2.2-5.1 5-5.1z" fill="url(#:R2htlqcmqn9:bb)"> </path> <radialgradient cx="-2274.721" cy="144.526" gradienttransform="matrix(0 -.2399 -1.0547 0 208.637 -414.922)" gradientunits="userSpaceOnUse" id=":R2htlqcmqn9:cc" r="29.037"> <stop offset="0" stop-color="#b8b8b8" stop-opacity=".498"> </stop> <stop offset="1" stop-color="#7f7f7f" stop-opacity="0"> </stop> </radialgradient> <path d="M92.1 130.9c0 3.8-16.1 7-35.9 7s-35.9-3.1-35.9-7c0-3.8 16.1-7 35.9-7s35.9 3.1 35.9 7z" fill="url(#:R2htlqcmqn9:cc)" opacity=".444"> </path> </svg> <span> PyMongo </span> </a> <a class="leafygreen-ui-18cpm0b" href="https://mongoc.org/libmongoc/current/mongoc_collection_insert_many.html" target="_self"> <svg class="leafygreen-ui-x3zji3" fill="none" height="24" viewbox="0 0 28 29" width="24" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_1351_59955)"> <g clip-path="url(#clip1_1351_59955)"> <path clip-rule="evenodd" d="M13.118 1.49532C13.5403 1.25103 14.0559 1.25103 14.4783 1.49532C16.5652 2.70389 22.8385 6.34889 24.9193 7.55748C25.3416 7.80172 25.6025 8.25176 25.6025 8.74672C25.6025 11.1703 25.6025 18.4539 25.6025 20.8774C25.6025 21.366 25.3416 21.8224 24.9193 22.0667C22.8385 23.2753 16.5652 26.9203 14.4783 28.1289C14.0559 28.3732 13.5403 28.3732 13.118 28.1289C11.0373 26.9139 4.76398 23.2689 2.68323 22.0603C2.26087 21.816 2 21.366 2 20.871C2 18.4474 2 11.1639 2 8.7403C2 8.25176 2.26087 7.7953 2.68323 7.55106C4.76398 6.34889 11.0373 2.70389 13.118 1.49532Z" fill="#004482" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M2.18634 21.4946C2.01863 21.2632 2 21.051 2 20.7553C2 18.351 2 11.1061 2 8.70176C2 8.21317 2.26087 7.76319 2.67702 7.51889C4.75776 6.31675 11.0062 2.69104 13.0807 1.4889C13.5031 1.24461 14.0683 1.25104 14.4907 1.49533C16.5652 2.69747 22.795 6.29104 24.8696 7.49319C25.0373 7.58963 25.1677 7.70535 25.2795 7.86606L2.18634 21.4946Z" fill="#659AD2" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M13.8011 5.8089C18.6024 5.8089 22.4968 9.83964 22.4968 14.8089C22.4968 19.7782 18.6024 23.8089 13.8011 23.8089C8.99986 23.8089 5.10547 19.7782 5.10547 14.8089C5.10547 9.83964 8.99986 5.8089 13.8011 5.8089ZM13.8011 10.3089C16.1987 10.3089 18.1489 12.3275 18.1489 14.8089C18.1489 17.2903 16.1987 19.3089 13.8011 19.3089C11.4036 19.3089 9.4533 17.2903 9.4533 14.8089C9.4533 12.3275 11.4036 10.3089 13.8011 10.3089Z" fill="white" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M25.2857 7.87247C25.6087 8.18102 25.6025 8.65034 25.6025 9.01673C25.6025 11.4596 25.5839 18.396 25.6087 20.8325C25.6087 21.0896 25.528 21.3532 25.4099 21.5589L13.5466 14.8089L25.2857 7.87247Z" fill="#00599C" fill-rule="evenodd"> </path> </g> </g> <defs> <clippath id="clip0_1351_59955"> <rect fill="white" height="28" transform="translate(0 0.809265)" width="28"> </rect> </clippath> <clippath id="clip1_1351_59955"> <rect fill="white" height="27" transform="translate(2 1.30887)" width="24"> </rect> </clippath> </defs> </svg> <span> C </span> </a> <a class="leafygreen-ui-18cpm0b" href="https://www.mongodb.com/docs/languages/cpp/cpp-driver/current/write/insert/#insert-multiple-documents" target="_self"> <svg class="leafygreen-ui-x3zji3" fill="none" height="24" viewbox="0 0 28 29" width="24" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_1351_59959)"> <g clip-path="url(#clip1_1351_59959)"> <path d="M25.4013 21.5646C25.5872 21.2353 25.7034 20.8745 25.7034 20.5373V9.08012C25.7034 8.75078 25.5872 8.38217 25.4013 8.05283L13.8516 14.8127L25.4013 21.5646Z" fill="#00599C"> </path> <path d="M14.8738 28.0657L24.6729 22.3411C24.9517 22.1764 25.2151 21.8941 25.401 21.5647L13.8513 14.8127L2.30151 21.5647C2.48743 21.8941 2.74305 22.1764 3.02967 22.3411L12.8288 28.0657C13.3865 28.3951 14.316 28.3951 14.8738 28.0657Z" fill="#004482"> </path> <path d="M25.4011 8.06086C25.2152 7.73146 24.9596 7.44915 24.673 7.2845L14.8739 1.55983C14.3084 1.23046 13.3866 1.23046 12.8211 1.55983L3.02202 7.2845C2.46429 7.61385 1.99951 8.42158 1.99951 9.08033V20.5375C1.99951 20.8669 2.11571 21.2354 2.30162 21.5647L13.8514 14.8128L25.4011 8.06086Z" fill="#659AD2"> </path> <path d="M13.8512 22.8115C9.49778 22.8115 5.94995 19.2199 5.94995 14.8127C5.94995 10.4055 9.49778 6.81387 13.8512 6.81387C16.6631 6.81387 19.2813 8.34305 20.6912 10.8133L17.2751 12.813C16.5701 11.5818 15.261 10.8133 13.8512 10.8133C11.6745 10.8133 9.90055 12.6091 9.90055 14.8127C9.90055 17.0163 11.6745 18.8121 13.8512 18.8121C15.261 18.8121 16.5701 18.0436 17.2751 16.8124L20.6912 18.8121C19.2813 21.2745 16.6631 22.8115 13.8512 22.8115Z" fill="white"> </path> <path d="M21.7524 14.3657H20.8771V13.4796H19.994V14.3657H19.1187V15.2518H19.994V16.1458H20.8771V15.2518H21.7524V14.3657Z" fill="white"> </path> <path d="M25.0446 14.3657H24.1693V13.4796H23.2862V14.3657H22.4109V15.2518H23.2862V16.1458H24.1693V15.2518H25.0446V14.3657Z" fill="white"> </path> </g> </g> <defs> <clippath id="clip0_1351_59959"> <rect fill="white" height="28" transform="translate(0 0.809265)" width="28"> </rect> </clippath> <clippath id="clip1_1351_59959"> <rect fill="white" height="27" transform="translate(1.99951 1.30878)" width="24"> </rect> </clippath> </defs> </svg> <span> C++ </span> </a> <a class="leafygreen-ui-18cpm0b" href="https://www.mongodb.com/docs/drivers/go/current/fundamentals/crud/write-operations/insert/#insert-multiple-documents" target="_self"> <svg class="leafygreen-ui-x3zji3" height="24" id="Layer_1" style="fill:#00ACD7" version="1.1" viewbox="0 0 205.4 76.7" width="24" x="0" xmlns="http://www.w3.org/2000/svg" y="0"> <path class="st00" d="M15.5 23.2c-.4 0-.5-.2-.3-.5l2.1-2.7c.2-.3.7-.5 1.1-.5h35.7c.4 0 .5.3.3.6l-1.7 2.6c-.2.3-.7.6-1 .6l-36.2-.1zM.4 32.4c-.4 0-.5-.2-.3-.5l2.1-2.7c.2-.3.7-.5 1.1-.5h45.6c.4 0 .6.3.5.6l-.8 2.4c-.1.4-.5.6-.9.6l-47.3.1zM24.6 41.6c-.4 0-.5-.3-.3-.6l1.4-2.5c.2-.3.6-.6 1-.6h20c.4 0 .6.3.6.7l-.2 2.4c0 .4-.4.7-.7.7l-21.8-.1z"> </path> <g id="CXHf1q_3_"> <path class="st00" d="M128.4 21.4c-6.3 1.6-10.6 2.8-16.8 4.4-1.5.4-1.6.5-2.9-1-1.5-1.7-2.6-2.8-4.7-3.8-6.3-3.1-12.4-2.2-18.1 1.5-6.8 4.4-10.3 10.9-10.2 19 .1 8 5.6 14.6 13.5 15.7 6.8.9 12.5-1.5 17-6.6.9-1.1 1.7-2.3 2.7-3.7H89.6c-2.1 0-2.6-1.3-1.9-3 1.3-3.1 3.7-8.3 5.1-10.9.3-.6 1-1.6 2.5-1.6h36.4c-.2 2.7-.2 5.4-.6 8.1-1.1 7.2-3.8 13.8-8.2 19.6-7.2 9.5-16.6 15.4-28.5 17-9.8 1.3-18.9-.6-26.9-6.6-7.4-5.6-11.6-13-12.7-22.2-1.3-10.9 1.9-20.7 8.5-29.3C70.4 8.7 79.8 2.8 91.3.7c9.4-1.7 18.4-.6 26.5 4.9 5.3 3.5 9.1 8.3 11.6 14.1.6.9.2 1.4-1 1.7z"> </path> <path class="st00" d="M161.5 76.7c-9.1-.2-17.4-2.8-24.4-8.8-5.9-5.1-9.6-11.6-10.8-19.3-1.8-11.3 1.3-21.3 8.1-30.2 7.3-9.6 16.1-14.6 28-16.7 10.2-1.8 19.8-.8 28.5 5.1 7.9 5.4 12.8 12.7 14.1 22.3 1.7 13.5-2.2 24.5-11.5 33.9-6.6 6.7-14.7 10.9-24 12.8-2.7.5-5.4.6-8 .9zm23.8-40.4c-.1-1.3-.1-2.3-.3-3.3-1.8-9.9-10.9-15.5-20.4-13.3-9.3 2.1-15.3 8-17.5 17.4-1.8 7.8 2 15.7 9.2 18.9 5.5 2.4 11 2.1 16.3-.6 7.9-4.1 12.2-10.5 12.7-19.1z"> </path> </g> </svg> <span> Go </span> </a> <a class="leafygreen-ui-18cpm0b" href="https://www.mongodb.com/docs/languages/java/reactive-streams-driver/current/write/insert-documents/#insert-multiple-documents" target="_self"> <svg class="leafygreen-ui-x3zji3" fill="none" height="24" viewbox="0 0 30 41" width="24" xmlns="http://www.w3.org/2000/svg"> <path d="M10.0921 30.7949C10.0921 30.7949 8.57608 31.6793 11.166 31.9636C14.2929 32.311 15.9037 32.2794 19.3464 31.6161C19.3464 31.6161 20.2623 32.1846 21.5257 32.6901C13.7876 35.9748 4.02791 32.5005 10.0921 30.7949Z" fill="#0074BD"> </path> <path d="M9.14539 26.4678C9.14539 26.4678 7.43985 27.7312 10.0298 27.9838C13.3778 28.3312 15.9992 28.3628 20.579 27.4785C20.579 27.4785 21.2107 28.1101 22.1898 28.4576C12.8724 31.2054 2.44949 28.6787 9.14539 26.4678Z" fill="#0074BD"> </path> <path d="M17.1039 19.1398C18.9989 21.3191 16.5985 23.3089 16.5985 23.3089C16.5985 23.3089 21.431 20.8138 19.2201 17.6869C17.1355 14.7811 15.5563 13.3282 24.1788 8.33789C24.1473 8.33789 10.6607 11.6858 17.1039 19.1398Z" fill="#EA2D2E"> </path> <path d="M27.3377 33.9845C27.3377 33.9845 28.4431 34.9004 26.1059 35.6269C21.6525 36.985 7.53417 37.3957 3.61769 35.6901C2.19639 35.0899 4.84949 34.2372 5.67069 34.0477C6.52347 33.8582 7.02884 33.8898 7.02884 33.8898C5.44961 32.7843 -3.10981 36.0691 2.67016 36.9851C18.4308 39.5433 31.4121 35.8164 27.3377 33.9845Z" fill="#0074BD"> </path> <path d="M10.8194 21.983C10.8194 21.983 3.6497 23.6885 8.2926 24.3203C10.2509 24.5729 14.1357 24.5097 17.7995 24.2255C20.7685 23.9728 23.7375 23.4359 23.7375 23.4359C23.7375 23.4359 22.6951 23.8781 21.9372 24.415C14.6411 26.3416 0.585992 25.4257 4.62881 23.4675C8.00839 21.7935 10.8194 21.983 10.8194 21.983Z" fill="#0074BD"> </path> <path d="M23.6745 29.1846C31.0969 25.3313 27.6542 21.6359 25.2538 22.1413C24.6537 22.2676 24.401 22.3623 24.401 22.3623C24.401 22.3623 24.6221 22.0149 25.0327 21.8886C29.7703 20.2146 33.4025 26.7842 23.5166 29.4057C23.5482 29.3741 23.6429 29.2794 23.6745 29.1846Z" fill="#0074BD"> </path> <path d="M19.2206 0.25293C19.2206 0.25293 23.3266 4.35891 15.3357 10.6758C8.92404 15.7293 13.8828 18.6351 15.3357 21.9199C11.6087 18.5403 8.86088 15.5714 10.6928 12.792C13.3775 8.74919 20.863 6.79093 19.2206 0.25293Z" fill="#EA2D2E"> </path> <path d="M11.5455 39.6068C18.6521 40.049 29.5803 39.3541 29.833 35.9746C29.833 35.9746 29.3276 37.238 23.9583 38.2487C17.894 39.3858 10.4085 39.2594 5.95508 38.533C5.95508 38.5646 6.87103 39.3225 11.5455 39.6068Z" fill="#0074BD"> </path> </svg> <span> Java RS </span> </a> <a class="leafygreen-ui-18cpm0b" href="https://www.mongodb.com/docs/drivers/kotlin/coroutine/current/fundamentals/crud/write-operations/insert/#insert-multiple-documents" target="_self"> <svg class="leafygreen-ui-x3zji3" fill="none" height="24" viewbox="0 0 28 29" width="24" xmlns="http://www.w3.org/2000/svg"> <path d="M28 29H0V1H28L14 15L28 29Z" fill="url(#:R35tlqcmqn9:paint0_linear_211_40588)"> </path> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":R35tlqcmqn9:paint0_linear_211_40588" x1="28" x2="8.34465e-07" y1="0.999999" y2="29"> <stop offset="0.00343514" stop-color="#E44857"> </stop> <stop offset="0.4689" stop-color="#C711E1"> </stop> <stop offset="1" stop-color="#7F52FF"> </stop> </lineargradient> </defs> </svg> <span> Kotlin Coroutine </span> </a> <a class="leafygreen-ui-18cpm0b" href="https://www.mongodb.com/docs/languages/kotlin/kotlin-sync-driver/current/write/insert/#insert-multiple-documents" target="_self"> <svg class="leafygreen-ui-x3zji3" fill="none" height="24" viewbox="0 0 28 29" width="24" xmlns="http://www.w3.org/2000/svg"> <path d="M28 29H0V1H28L14 15L28 29Z" fill="url(#:R39tlqcmqn9:paint0_linear_211_40588)"> </path> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":R39tlqcmqn9:paint0_linear_211_40588" x1="28" x2="8.34465e-07" y1="0.999999" y2="29"> <stop offset="0.00343514" stop-color="#E44857"> </stop> <stop offset="0.4689" stop-color="#C711E1"> </stop> <stop offset="1" stop-color="#7F52FF"> </stop> </lineargradient> </defs> </svg> <span> Kotlin Sync </span> </a> <a class="leafygreen-ui-18cpm0b" href="https://www.mongodb.com/docs/php-library/current/write/insert/#insert-multiple-documents" target="_self"> <svg class="leafygreen-ui-x3zji3" height="24" viewbox="0 0 700 301" width="24" x="0" xmlns="http://www.w3.org/2000/svg" y="0"> <defs> <clippath clippathunits="userSpaceOnUse" id="a"> <path d="M11.52 162C11.52 81.677 135.307 16.561 288 16.561S564.481 81.677 564.481 162c0 80.322-123.788 145.439-276.481 145.439-152.693 0-276.48-65.117-276.48-145.439"> </path> </clippath> <clippath clippathunits="userSpaceOnUse" id="c"> <path d="M0 324h576V0H0v324z"> </path> </clippath> <clippath clippathunits="userSpaceOnUse" id="d"> <path d="M0 324h576V0H0v324z"> </path> </clippath> <radialgradient cx="0" cy="0" fx="0" fy="0" gradienttransform="matrix(363.05789 0 0 -363.05789 177.52 256.307)" gradientunits="userSpaceOnUse" id="b" r="1" spreadmethod="pad"> <stop offset="0" stop-color="#aeb2d5"> </stop> <stop offset=".3" stop-color="#aeb2d5"> </stop> <stop offset=".75" stop-color="#484c89"> </stop> <stop offset="1" stop-color="#484c89"> </stop> </radialgradient> </defs> <g clip-path="url(#a)" transform="matrix(1.25 0 0 -1.25 -4.4 394.299)"> <path d="M11.52 162C11.52 81.677 135.307 16.561 288 16.561S564.481 81.677 564.481 162c0 80.322-123.788 145.439-276.481 145.439-152.693 0-276.48-65.117-276.48-145.439" fill="url(#b)"> </path> </g> <g clip-path="url(#c)" transform="matrix(1.25 0 0 -1.25 -4.4 394.299)"> <path d="M288 27.36c146.729 0 265.68 60.28 265.68 134.64 0 74.36-118.951 134.641-265.68 134.641S22.32 236.36 22.32 162.001C22.32 87.64 141.271 27.358 288 27.358" fill="#777bb3"> </path> </g> <g clip-path="url(#d)" transform="matrix(1.25 0 0 -1.25 -4.4 394.299)"> <path d="M161.734 145.307c12.065 0 21.072 2.225 26.771 6.61 5.638 4.342 9.532 11.863 11.573 22.354 1.903 9.806 1.178 16.653-2.154 20.348-3.407 3.774-10.773 5.688-21.893 5.688h-19.28l-10.69-55h15.673zm-63.063-67.75a2.998 2.998 0 00-2.944 3.572l28.328 145.75a3 3 0 002.945 2.428h61.054c19.188 0 33.47-5.21 42.447-15.487 9.025-10.331 11.812-24.772 8.283-42.921-1.436-7.394-3.906-14.261-7.34-20.41-3.44-6.154-7.985-11.85-13.512-16.93-6.616-6.191-14.104-10.681-22.236-13.323-8.003-2.607-18.28-3.93-30.548-3.93h-24.722l-7.06-36.321a3 3 0 00-2.944-2.428h-31.75z"> </path> <path d="M159.224 197.307h16.808c13.42 0 18.083-2.945 19.667-4.7 2.628-2.914 3.124-9.058 1.435-17.767-1.898-9.75-5.416-16.663-10.458-20.545-5.162-3.974-13.554-5.988-24.941-5.988H149.7l9.523 49zm28.83 35H127a6 6 0 01-5.89-4.855L92.784 81.702a6 6 0 015.889-7.144h31.75a6 6 0 015.89 4.854l6.588 33.895h22.249c12.582 0 23.174 1.372 31.479 4.077 8.54 2.775 16.399 7.48 23.354 13.984 5.752 5.292 10.49 11.232 14.08 17.657 3.59 6.427 6.17 13.594 7.668 21.302 3.715 19.104.697 34.402-8.97 45.466-9.571 10.958-24.613 16.514-44.705 16.514m-45.633-90h19.313c12.8 0 22.336 2.411 28.6 7.234 6.267 4.824 10.493 12.875 12.689 24.157 2.1 10.832 1.144 18.476-2.871 22.93-4.02 4.452-12.06 6.68-24.121 6.68h-21.754l-11.856-61m45.633 84c18.367 0 31.766-4.82 40.188-14.462 8.42-9.64 10.957-23.098 7.597-40.375-1.383-7.117-3.722-13.624-7.015-19.519-3.297-5.899-7.602-11.293-12.922-16.184-6.34-5.933-13.383-10.16-21.133-12.679-7.75-2.525-17.621-3.782-29.621-3.782h-27.196l-7.531-38.75h-31.75L127 226.307h61.055" fill="#fff"> </path> <path d="M311.583 116.307c-.896 0-1.745.4-2.314 1.092a2.994 2.994 0 00-.631 2.48l12.531 64.489c1.192 6.133.898 10.535-.827 12.395-1.056 1.137-4.228 3.044-13.607 3.044h-22.702l-15.755-81.072a3 3 0 00-2.945-2.428h-31.5a2.998 2.998 0 00-2.945 3.572l28.328 145.75a3 3 0 002.945 2.428h31.5a3 3 0 002.945-3.572l-6.836-35.178h24.422c18.605 0 31.221-3.28 38.569-10.028 7.49-6.884 9.827-17.891 6.947-32.72l-13.18-67.824a3 3 0 00-2.945-2.428h-32z"> </path> <path d="M293.661 271.057h-31.5a6 6 0 01-5.89-4.855l-28.328-145.75a5.998 5.998 0 015.89-7.145h31.5a6 6 0 015.89 4.855l15.283 78.645h20.23c9.362 0 11.327-2 11.406-2.086.568-.61 1.315-3.44.082-9.78l-12.53-64.49a5.998 5.998 0 015.89-7.144h32a6 6 0 015.89 4.855l13.178 67.825c3.093 15.921.447 27.864-7.86 35.5-7.929 7.281-21.209 10.82-40.6 10.82h-20.784l6.143 31.605a6.001 6.001 0 01-5.89 7.145m0-6l-7.53-38.75h28.061c17.657 0 29.836-3.082 36.54-9.238 6.702-6.16 8.71-16.14 6.031-29.938l-13.18-67.824h-32l12.531 64.488c1.426 7.336.902 12.34-1.574 15.008-2.477 2.668-7.746 4.004-15.805 4.004H281.56l-16.226-83.5h-31.5l28.328 145.75h31.5" fill="#fff"> </path> <path d="M409.55 145.307c12.065 0 21.072 2.225 26.77 6.61 5.639 4.34 9.533 11.862 11.575 22.354 1.903 9.806 1.178 16.653-2.155 20.348-3.407 3.774-10.773 5.688-21.893 5.688h-19.281l-10.69-55h15.674zm-63.062-67.75a2.999 2.999 0 00-2.945 3.572l28.328 145.75a3.002 3.002 0 002.946 2.428h61.053c19.189 0 33.47-5.21 42.448-15.487 9.025-10.33 11.81-24.771 8.283-42.921-1.438-7.394-3.907-14.261-7.342-20.41-3.44-6.154-7.984-11.85-13.511-16.93-6.616-6.191-14.104-10.681-22.236-13.323-8.003-2.607-18.281-3.93-30.548-3.93H388.24l-7.057-36.321a3.001 3.001 0 00-2.946-2.428h-31.75z"> </path> <path d="M407.04 197.307h16.807c13.421 0 18.083-2.945 19.667-4.7 2.63-2.914 3.125-9.058 1.435-17.766-1.898-9.75-5.417-16.664-10.458-20.546-5.162-3.974-13.554-5.988-24.94-5.988h-12.034l9.522 49zm28.83 35h-61.054a6 6 0 01-5.889-4.855L340.6 81.702a6 6 0 015.889-7.144h31.75a6 6 0 015.89 4.854l6.587 33.895h22.25c12.581 0 23.173 1.372 31.478 4.077 8.541 2.775 16.401 7.481 23.356 13.986 5.752 5.291 10.488 11.23 14.078 17.655 3.591 6.427 6.171 13.594 7.668 21.302 3.715 19.105.697 34.403-8.969 45.467-9.572 10.957-24.613 16.513-44.706 16.513m-45.632-90h19.312c12.801 0 22.336 2.411 28.601 7.234 6.267 4.824 10.492 12.875 12.688 24.157 2.102 10.832 1.145 18.476-2.87 22.93-4.02 4.452-12.06 6.68-24.122 6.68h-21.754l-11.855-61m45.632 84c18.367 0 31.766-4.82 40.188-14.462 8.422-9.64 10.957-23.098 7.597-40.375-1.383-7.117-3.722-13.624-7.015-19.519-3.297-5.899-7.602-11.293-12.922-16.184-6.34-5.933-13.383-10.16-21.133-12.679-7.75-2.525-17.62-3.782-29.62-3.782h-27.197l-7.53-38.75h-31.75l28.328 145.75h61.054" fill="#fff"> </path> </g> </svg> <span> PHP </span> </a> <a class="leafygreen-ui-18cpm0b" href="https://www.mongodb.com/docs/mongoid/current/reference/crud/#standard" target="_self"> <svg class="leafygreen-ui-x3zji3" height="24" preserveaspectratio="xMidYMid" viewbox="0 0 300 240" width="24" xmlns="http://www.w3.org/2000/svg"> <defs> <lineargradient id=":R3htlqcmqn9:a" x1="84.75%" x2="58.254%" y1="111.399%" y2="64.584%"> <stop offset="0%" stop-color="#FB7655"> </stop> <stop offset="0%" stop-color="#FB7655"> </stop> <stop offset="41%" stop-color="#E42B1E"> </stop> <stop offset="99%" stop-color="#900"> </stop> <stop offset="100%" stop-color="#900"> </stop> </lineargradient> <lineargradient id=":R3htlqcmqn9:b" x1="116.651%" x2="1.746%" y1="60.89%" y2="19.288%"> <stop offset="0%" stop-color="#871101"> </stop> <stop offset="0%" stop-color="#871101"> </stop> <stop offset="99%" stop-color="#911209"> </stop> <stop offset="100%" stop-color="#911209"> </stop> </lineargradient> <lineargradient id=":R3htlqcmqn9:c" x1="75.774%" x2="38.978%" y1="219.327%" y2="7.829%"> <stop offset="0%" stop-color="#871101"> </stop> <stop offset="0%" stop-color="#871101"> </stop> <stop offset="99%" stop-color="#911209"> </stop> <stop offset="100%" stop-color="#911209"> </stop> </lineargradient> <lineargradient id=":R3htlqcmqn9:d" x1="50.012%" x2="66.483%" y1="7.234%" y2="79.135%"> <stop offset="0%" stop-color="#FFF"> </stop> <stop offset="0%" stop-color="#FFF"> </stop> <stop offset="23%" stop-color="#E57252"> </stop> <stop offset="46%" stop-color="#DE3B20"> </stop> <stop offset="99%" stop-color="#A60003"> </stop> <stop offset="100%" stop-color="#A60003"> </stop> </lineargradient> <lineargradient id=":R3htlqcmqn9:e" x1="46.174%" x2="49.932%" y1="16.348%" y2="83.047%"> <stop offset="0%" stop-color="#FFF"> </stop> <stop offset="0%" stop-color="#FFF"> </stop> <stop offset="23%" stop-color="#E4714E"> </stop> <stop offset="56%" stop-color="#BE1A0D"> </stop> <stop offset="99%" stop-color="#A80D00"> </stop> <stop offset="100%" stop-color="#A80D00"> </stop> </lineargradient> <lineargradient id=":R3htlqcmqn9:f" x1="36.965%" x2="49.528%" y1="15.594%" y2="92.478%"> <stop offset="0%" stop-color="#FFF"> </stop> <stop offset="0%" stop-color="#FFF"> </stop> <stop offset="18%" stop-color="#E46342"> </stop> <stop offset="40%" stop-color="#C82410"> </stop> <stop offset="99%" stop-color="#A80D00"> </stop> <stop offset="100%" stop-color="#A80D00"> </stop> </lineargradient> <lineargradient id=":R3htlqcmqn9:g" x1="13.609%" x2="85.764%" y1="58.346%" y2="-46.717%"> <stop offset="0%" stop-color="#FFF"> </stop> <stop offset="0%" stop-color="#FFF"> </stop> <stop offset="54%" stop-color="#C81F11"> </stop> <stop offset="99%" stop-color="#BF0905"> </stop> <stop offset="100%" stop-color="#BF0905"> </stop> </lineargradient> <lineargradient id=":R3htlqcmqn9:h" x1="27.624%" x2="50.745%" y1="21.135%" y2="79.056%"> <stop offset="0%" stop-color="#FFF"> </stop> <stop offset="0%" stop-color="#FFF"> </stop> <stop offset="31%" stop-color="#DE4024"> </stop> <stop offset="99%" stop-color="#BF190B"> </stop> <stop offset="100%" stop-color="#BF190B"> </stop> </lineargradient> <lineargradient id=":R3htlqcmqn9:i" x1="-20.667%" x2="104.242%" y1="122.282%" y2="-6.342%"> <stop offset="0%" stop-color="#BD0012"> </stop> <stop offset="0%" stop-color="#BD0012"> </stop> <stop offset="7%" stop-color="#FFF"> </stop> <stop offset="17%" stop-color="#FFF"> </stop> <stop offset="27%" stop-color="#C82F1C"> </stop> <stop offset="33%" stop-color="#820C01"> </stop> <stop offset="46%" stop-color="#A31601"> </stop> <stop offset="72%" stop-color="#B31301"> </stop> <stop offset="99%" stop-color="#E82609"> </stop> <stop offset="100%" stop-color="#E82609"> </stop> </lineargradient> <lineargradient id=":R3htlqcmqn9:j" x1="58.792%" x2="11.964%" y1="65.205%" y2="50.128%"> <stop offset="0%" stop-color="#8C0C01"> </stop> <stop offset="0%" stop-color="#8C0C01"> </stop> <stop offset="54%" stop-color="#990C00"> </stop> <stop offset="99%" stop-color="#A80D0E"> </stop> <stop offset="100%" stop-color="#A80D0E"> </stop> </lineargradient> <lineargradient id=":R3htlqcmqn9:k" x1="79.319%" x2="23.088%" y1="62.754%" y2="17.888%"> <stop offset="0%" stop-color="#7E110B"> </stop> <stop offset="0%" stop-color="#7E110B"> </stop> <stop offset="99%" stop-color="#9E0C00"> </stop> <stop offset="100%" stop-color="#9E0C00"> </stop> </lineargradient> <lineargradient id=":R3htlqcmqn9:l" x1="92.88%" x2="59.841%" y1="74.122%" y2="39.704%"> <stop offset="0%" stop-color="#79130D"> </stop> <stop offset="0%" stop-color="#79130D"> </stop> <stop offset="99%" stop-color="#9E120B"> </stop> <stop offset="100%" stop-color="#9E120B"> </stop> </lineargradient> <lineargradient id=":R3htlqcmqn9:o" x1="56.57%" x2="3.105%" y1="101.717%" y2="11.993%"> <stop offset="0%" stop-color="#8B2114"> </stop> <stop offset="0%" stop-color="#8B2114"> </stop> <stop offset="43%" stop-color="#9E100A"> </stop> <stop offset="99%" stop-color="#B3100C"> </stop> <stop offset="100%" stop-color="#B3100C"> </stop> </lineargradient> <lineargradient id=":R3htlqcmqn9:p" x1="30.87%" x2="92.471%" y1="35.599%" y2="100.694%"> <stop offset="0%" stop-color="#B31000"> </stop> <stop offset="0%" stop-color="#B31000"> </stop> <stop offset="44%" stop-color="#910F08"> </stop> <stop offset="99%" stop-color="#791C12"> </stop> <stop offset="100%" stop-color="#791C12"> </stop> </lineargradient> <radialgradient cx="32.001%" cy="40.21%" fx="32.001%" fy="40.21%" id=":R3htlqcmqn9:m" r="69.573%"> <stop offset="0%" stop-color="#A80D00"> </stop> <stop offset="0%" stop-color="#A80D00"> </stop> <stop offset="99%" stop-color="#7E0E08"> </stop> <stop offset="100%" stop-color="#7E0E08"> </stop> </radialgradient> <radialgradient cx="13.549%" cy="40.86%" fx="13.549%" fy="40.86%" id=":R3htlqcmqn9:n" r="88.386%"> <stop offset="0%" stop-color="#A30C00"> </stop> <stop offset="0%" stop-color="#A30C00"> </stop> <stop offset="99%" stop-color="#800E08"> </stop> <stop offset="100%" stop-color="#800E08"> </stop> </radialgradient> </defs> <path d="M197.467 167.764l-145.52 86.41 188.422-12.787L254.88 51.393l-57.414 116.37z" fill="url(#:R3htlqcmqn9:a)"> </path> <path d="M240.677 241.257L224.482 129.48l-44.113 58.25 60.308 53.528z" fill="url(#:R3htlqcmqn9:b)"> </path> <path d="M240.896 241.257l-118.646-9.313-69.674 21.986 188.32-12.673z" fill="url(#:R3htlqcmqn9:c)"> </path> <path d="M52.744 253.955l29.64-97.1L17.16 170.8l35.583 83.154z" fill="url(#:R3htlqcmqn9:d)"> </path> <path d="M180.358 188.05L153.085 81.226l-78.047 73.16 105.32 33.666z" fill="url(#:R3htlqcmqn9:e)"> </path> <path d="M248.693 82.73l-73.777-60.256-20.544 66.418 94.321-6.162z" fill="url(#:R3htlqcmqn9:f)"> </path> <path d="M214.191.99L170.8 24.97 143.424.669l70.767.322z" fill="url(#:R3htlqcmqn9:g)"> </path> <path d="M0 203.372l18.177-33.151-14.704-39.494L0 203.372z" fill="url(#:R3htlqcmqn9:h)"> </path> <path d="M2.496 129.48l14.794 41.963 64.283-14.422 73.39-68.207 20.712-65.787L143.063 0 87.618 20.75c-17.469 16.248-51.366 48.396-52.588 49-1.21.618-22.384 40.639-32.534 59.73z" fill="#FFF"> </path> <path d="M54.442 54.094c37.86-37.538 86.667-59.716 105.397-40.818 18.72 18.898-1.132 64.823-38.992 102.349-37.86 37.525-86.062 60.925-104.78 42.027-18.73-18.885.515-66.032 38.375-103.558z" fill="url(#:R3htlqcmqn9:i)"> </path> <path d="M52.744 253.916l29.408-97.409 97.665 31.376c-35.312 33.113-74.587 61.106-127.073 66.033z" fill="url(#:R3htlqcmqn9:j)"> </path> <path d="M155.092 88.622l25.073 99.313c29.498-31.016 55.972-64.36 68.938-105.603l-94.01 6.29z" fill="url(#:R3htlqcmqn9:k)"> </path> <path d="M248.847 82.833c10.035-30.282 12.35-73.725-34.966-81.791l-38.825 21.445 73.791 60.346z" fill="url(#:R3htlqcmqn9:l)"> </path> <path d="M0 202.935c1.39 49.979 37.448 50.724 52.808 51.162l-35.48-82.86L0 202.935z" fill="#9E1209"> </path> <path d="M155.232 88.777c22.667 13.932 68.35 41.912 69.276 42.426 1.44.81 19.695-30.784 23.838-48.64l-93.114 6.214z" fill="url(#:R3htlqcmqn9:m)"> </path> <path d="M82.113 156.507l39.313 75.848c23.246-12.607 41.45-27.967 58.121-44.42l-97.434-31.428z" fill="url(#:R3htlqcmqn9:n)"> </path> <path d="M17.174 171.34l-5.57 66.328c10.51 14.357 24.97 15.605 40.136 14.486-10.973-27.311-32.894-81.92-34.566-80.814z" fill="url(#:R3htlqcmqn9:o)"> </path> <path d="M174.826 22.654l78.1 10.96c-4.169-17.662-16.969-29.06-38.787-32.623l-39.313 21.663z" fill="url(#:R3htlqcmqn9:p)"> </path> </svg> <span> Mongoid </span> </a> <a class="leafygreen-ui-18cpm0b" href="https://www.mongodb.com/docs/drivers/rust/current/fundamentals/crud/write-operations/insert/#insert-multiple-documents" target="_self"> <svg class="leafygreen-ui-x3zji3" height="24" viewbox="0 0 30 30" width="24" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_5454_14623)"> <path d="M15.2561 3.08398C8.56014 3.08398 3.11035 8.53634 3.11035 15.2297C3.11035 21.9231 8.56271 27.3755 15.2561 27.3755C21.9495 27.3755 27.4019 21.9231 27.4019 15.2297C27.4019 8.53634 21.9495 3.08398 15.2561 3.08398ZM15.2381 4.16315C15.4458 4.16853 15.6432 4.25509 15.7881 4.40437C15.9331 4.55365 16.0142 4.75384 16.0141 4.96225C16.0141 5.17418 15.9299 5.37744 15.7801 5.5273C15.6302 5.67715 15.4269 5.76134 15.215 5.76134C15.0031 5.76134 14.7998 5.67715 14.65 5.5273C14.5001 5.37744 14.4159 5.17418 14.4159 4.96225C14.4159 4.85533 14.4373 4.7495 14.4789 4.65101C14.5205 4.55252 14.5814 4.46338 14.6581 4.38887C14.7347 4.31435 14.8256 4.25598 14.9252 4.21721C15.0249 4.17844 15.1313 4.16006 15.2381 4.16315ZM17.0676 5.47871C18.4704 5.74146 19.7992 6.30644 20.9617 7.13439C22.1242 7.96235 23.0926 9.03345 23.7995 10.2733L22.8565 12.4008C22.6947 12.7682 22.8617 13.1999 23.2265 13.3643L25.0406 14.1686C25.0968 14.7356 25.1037 15.3065 25.0611 15.8747H24.0513C23.9511 15.8747 23.91 15.9415 23.91 16.0391V16.5016C23.91 17.5911 23.2959 17.83 22.7563 17.8891C22.2424 17.9482 21.6746 17.6733 21.6026 17.3598C21.2994 15.6563 20.7958 15.294 19.9993 14.6645C20.9885 14.0375 22.0163 13.11 22.0163 11.8715C22.0163 10.5328 21.099 9.69002 20.4747 9.27634C19.5959 8.69822 18.6247 8.5826 18.3626 8.5826H7.93063C9.37312 6.97114 11.3066 5.88021 13.4318 5.47871L14.6626 6.76857C14.9401 7.05891 15.4 7.07176 15.6903 6.79169L17.0676 5.47871ZM5.71063 11.3936C5.91853 11.3996 6.11589 11.4864 6.26079 11.6356C6.40568 11.7849 6.48669 11.9847 6.4866 12.1927C6.4866 12.4046 6.40241 12.6079 6.25255 12.7577C6.10269 12.9076 5.89944 12.9918 5.6875 12.9918C5.47557 12.9918 5.27232 12.9076 5.12246 12.7577C4.9726 12.6079 4.88841 12.4046 4.88841 12.1927C4.88836 12.0858 4.90977 11.9799 4.95137 11.8814C4.99297 11.7829 5.0539 11.6938 5.13057 11.6193C5.20724 11.5448 5.29809 11.4864 5.39772 11.4476C5.49736 11.4089 5.60376 11.3905 5.71063 11.3936ZM24.7631 11.4295C24.971 11.4356 25.1683 11.5224 25.3132 11.6716C25.4581 11.8208 25.5391 12.0206 25.539 12.2286C25.539 12.4406 25.4548 12.6438 25.305 12.7937C25.1551 12.9435 24.9519 13.0277 24.7399 13.0277C24.528 13.0277 24.3247 12.9435 24.1749 12.7937C24.025 12.6438 23.9408 12.4406 23.9408 12.2286C23.9408 12.1217 23.9622 12.0159 24.0038 11.9174C24.0454 11.8189 24.1063 11.7298 24.183 11.6553C24.2597 11.5807 24.3505 11.5224 24.4502 11.4836C24.5498 11.4448 24.6562 11.4264 24.7631 11.4295ZM7.21632 11.558H8.60896V17.8377H5.79799C5.45083 16.6186 5.34264 15.3439 5.47938 14.0838L7.20091 13.3181C7.56834 13.1536 7.73535 12.7245 7.57091 12.3571L7.21632 11.558ZM13.0284 11.6248H16.3456C16.5177 11.6248 17.5558 11.8227 17.5558 12.6012C17.5558 13.2461 16.7592 13.4774 16.104 13.4774H13.0258L13.0284 11.6248ZM13.0284 16.1368H15.5696C15.8008 16.1368 16.8106 16.2036 17.1318 17.4934C17.232 17.8891 17.4556 19.179 17.6072 19.5927C17.7588 20.0552 18.3729 20.9802 19.0281 20.9802H23.1751C22.8972 21.3524 22.5933 21.7044 22.2656 22.0336L20.5774 21.6713C20.1843 21.5866 19.7963 21.8384 19.7115 22.2315L19.3107 24.102C18.0217 24.6859 16.622 24.9848 15.2069 24.9781C13.7919 24.9714 12.395 24.6595 11.1116 24.0635L10.7108 22.1929C10.626 21.7998 10.2406 21.548 9.84743 21.6328L8.19528 21.9874C7.88869 21.6711 7.6037 21.3346 7.34223 20.9802H15.3769C15.4668 20.9802 15.5285 20.9647 15.5285 20.88V18.0381C15.5285 17.9559 15.4668 17.9379 15.3769 17.9379H13.0258L13.0284 16.1368ZM9.3207 22.6452C9.5286 22.6512 9.72596 22.738 9.87085 22.8872C10.0157 23.0364 10.0968 23.2363 10.0967 23.4443C10.0967 23.6562 10.0125 23.8594 9.86262 24.0093C9.71276 24.1592 9.50951 24.2434 9.29757 24.2434C9.08564 24.2434 8.88239 24.1592 8.73253 24.0093C8.58267 23.8594 8.49848 23.6562 8.49848 23.4443C8.49843 23.3373 8.51984 23.2315 8.56144 23.133C8.60303 23.0345 8.66397 22.9454 8.74064 22.8709C8.81731 22.7964 8.90815 22.738 9.00779 22.6992C9.10743 22.6605 9.21383 22.6421 9.3207 22.6452ZM21.153 22.6811C21.3609 22.6872 21.5583 22.774 21.7031 22.9232C21.848 23.0724 21.929 23.2722 21.929 23.4802C21.929 23.6922 21.8448 23.8954 21.6949 24.0453C21.5451 24.1951 21.3418 24.2793 21.1299 24.2793C20.9179 24.2793 20.7147 24.1951 20.5648 24.0453C20.415 23.8954 20.3308 23.6922 20.3308 23.4802C20.3307 23.3733 20.3521 23.2675 20.3937 23.169C20.4353 23.0705 20.4963 22.9814 20.5729 22.9068C20.6496 22.8323 20.7404 22.774 20.8401 22.7352C20.9397 22.6964 21.0461 22.678 21.153 22.6811Z" fill="black"> </path> <path clip-rule="evenodd" d="M26.7232 15.2304C26.7232 18.2717 25.515 21.1885 23.3645 23.3391C21.2139 25.4896 18.2971 26.6978 15.2558 26.6978C12.2144 26.6978 9.29761 25.4896 7.14705 23.3391C4.99649 21.1885 3.78832 18.2717 3.78832 15.2304C3.78832 12.189 4.99649 9.27222 7.14705 7.12166C9.29761 4.9711 12.2144 3.76293 15.2558 3.76293C18.2971 3.76293 21.2139 4.9711 23.3645 7.12166C25.515 9.27222 26.7232 12.189 26.7232 15.2304ZM26.5073 14.1229L28.2957 15.2304L26.5073 16.3378L28.0439 17.7741L26.0757 18.5115L27.3039 20.2202L25.2252 20.5594L26.0988 22.4762L23.9944 22.4017L24.4775 24.4521L22.4271 23.969L22.5016 26.0734L20.5848 25.1998L20.2456 27.2785L18.5369 26.0503L17.7995 28.0185L16.3632 26.482L15.2558 28.2703L14.1483 26.482L12.712 28.0185L11.9746 26.0503L10.2659 27.2785L9.92672 25.1998L8.00992 26.0734L8.08443 23.969L6.03401 24.4521L6.51707 22.4017L4.4127 22.4762L5.28631 20.5594L3.20763 20.2202L4.43582 18.5115L2.46763 17.7741L4.00415 16.3378L2.21582 15.2304L4.00415 14.1229L2.46763 12.6866L4.43582 11.9492L3.20763 10.2405L5.28631 9.90133L4.4127 7.98453L6.51707 8.05904L6.03401 6.00862L8.08443 6.49168L8.00992 4.3873L9.92672 5.26092L10.2659 3.18223L11.9746 4.41043L12.712 2.44224L14.1483 3.97876L15.2558 2.19043L16.3632 3.97876L17.7995 2.44224L18.5369 4.41043L20.2456 3.18223L20.5848 5.26092L22.5016 4.3873L22.4271 6.49168L24.4775 6.00862L23.9944 8.05904L26.0988 7.98453L25.2252 9.90133L27.3039 10.2405L26.0757 11.9492L28.0439 12.6866L26.5073 14.1229Z" fill="black" fill-rule="evenodd" stroke-linecap="round" stroke-linejoin="round"> </path> </g> <defs> <clippath id="clip0_5454_14623"> <rect fill="black" height="30" width="30"> </rect> </clippath> </defs> </svg> <span> Rust </span> </a> <a class="leafygreen-ui-18cpm0b" href="https://www.mongodb.com/docs/languages/scala/scala-driver/current/tutorials/write-ops/#insert-multiple-documents" target="_self"> <svg class="leafygreen-ui-x3zji3" height="24" viewbox="0 0 70 70" width="24" xmlns="http://www.w3.org/2000/svg"> <defs> <lineargradient id=":R3ptlqcmqn9:aaa" x1=".006%" x2="96.837%" y1="49.998%" y2="49.998%"> <stop offset="0%" stop-color="#CD413F"> </stop> <stop offset="75.091%" stop-color="#CD4543"> </stop> <stop offset="100%" stop-color="#D04543"> </stop> </lineargradient> </defs> <g fill="none" fill-rule="nonzero"> <path d="M13 39v5c0 .843 17.73 2.255 29.28 5 5.582-1.327 9.72-2.966 9.72-5v-5c0-2.034-4.138-3.673-9.72-5C30.73 36.745 13 38.157 13 39M13 20v5c0 .843 17.73 2.255 29.28 5 5.582-1.327 9.72-2.966 9.72-5v-5c0-2.034-4.138-3.673-9.72-5C30.73 17.745 13 19.157 13 20" fill="#731818"> </path> <g fill="url(#:R3ptlqcmqn9:aaa)" transform="translate(13)"> <path d="M0 29.53v14.766c0-1.232 39-3.692 39-9.844V19.686c0 6.152-39 8.612-39 9.844M0 9.843V24.61c0-1.231 39-3.691 39-9.843V0C39 6.152 0 8.612 0 9.843M0 49.216v14.766c0-1.231 39-3.691 39-9.843V39.373c0 6.151-39 8.612-39 9.843"> </path> </g> </g> </svg> <span> Scala </span> </a> </div> <button class="leafygreen-ui-ki2t97"> Show all <svg aria-label="Chevron Down Icon" class="" fill="none" height="16" role="img" viewbox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M1.636 5.364a1 1 0 0 0 0 1.414l4.95 4.95.707.707a1 1 0 0 0 1.414 0l.707-.707 4.95-4.95a1 1 0 0 0 0-1.414l-.707-.707a1 1 0 0 0-1.414 0L8 8.899 3.757 4.657a1 1 0 0 0-1.414 0l-.707.707Z" fill="currentColor" fill-rule="evenodd"> </path> </svg> </button> </div> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Definition <a class="headerlink leafygreen-ui-1kepx47" href="#definition" 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="definition"> </div> </a> </h2> <dl class="method"> <dt> <code class="leafygreen-ui-1l06pbn"> db.collection.insertMany() </code> <a class="headerlink leafygreen-ui-1kepx47" href="#mongodb-method-db.collection.insertMany" title="Permalink to this definition"> <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="mongodb-method-db.collection.insertMany"> </div> </a> </dt> <dd> <p class="leafygreen-ui-1kp3ins"> Inserts multiple documents into a collection. </p> <table class="css-11h39yh e1nex8bq0"> <colgroup> <col class="field-name"/> <col class="field-body"/> </colgroup> <tbody> <tr class="css-x8snli"> <th> Returns <!-- --> : </th> <td> </td> </tr> </tbody> </table> <p class="leafygreen-ui-1kp3ins"> A document containing: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> An <code class="leafygreen-ui-1l06pbn"> acknowledged </code> boolean, set to <code class="leafygreen-ui-1l06pbn"> true </code> if the operation ran with <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-write-concern"> write concern </a> or <code class="leafygreen-ui-1l06pbn"> false </code> if write concern was disabled </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> An <code class="leafygreen-ui-1l06pbn"> insertedIds </code> array, containing <code class="leafygreen-ui-1l06pbn"> _id </code> values for each successfully inserted document </p> </li> </ul> </dd> </dl> </section> <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 <code class="leafygreen-ui-1l06pbn"> db.collection.insertMany() </code> 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"> Syntax <a class="headerlink leafygreen-ui-1kepx47" href="#syntax" 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="syntax"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> The <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-method-db.collection.insertMany" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> insertMany() </code> </span> </a> method has the following syntax: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.collection.insertMany(\n [ &lt;document&gt; , &lt;document&gt;, ... ],\n {\n writeConcern: &lt;document&gt;,\n ordered: &lt;boolean&gt;\n }\n)","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">insertMany</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->[ <!-- -->&lt;document 1&gt; , &lt;document 2&gt;, ... ],</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> {</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> writeConcern: &lt;document&gt;,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> ordered: &lt;boolean&gt;</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">)</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: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> Parameter </div> </div> </th> <th class="leafygreen-ui-13uteka" role="columnheader" scope="col"> <div class="leafygreen-ui-ui0te9"> <div> Type </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> <code class="leafygreen-ui-1l06pbn"> document </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> document </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> An array of documents to insert into the collection. </div> </div> </td> </tr> <tr class=""> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> writeConcern </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> document </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <p class="leafygreen-ui-1kp3ins"> Optional. A document expressing the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/write-concern/#std-label-write-concern"> write concern </a> . Omit to use the default write concern. </p> <p class="leafygreen-ui-1kp3ins"> Do not explicitly set the write concern for the operation if run in a transaction. To use write concern with transactions, see <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/transactions/#std-label-transactions-write-concern"> Transactions and Write Concern <!-- --> . </a> </p> </div> </div> </td> </tr> <tr class=""> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> ordered </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> boolean </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Optional. A boolean specifying whether the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> instance should perform an ordered or unordered insert. Defaults to <code class="leafygreen-ui-1l06pbn"> true </code> . </div> </div> </td> </tr> </tbody> </table> </div> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Behaviors <a class="headerlink leafygreen-ui-1kepx47" href="#behaviors" 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="behaviors"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> Given an array of documents, <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-method-db.collection.insertMany" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> insertMany() </code> </span> </a> inserts each document in the array into the collection. </p> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Execution of Operations <a class="headerlink leafygreen-ui-1kepx47" href="#execution-of-operations" 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="execution-of-operations"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> By default, documents are inserted in the order they are provided. </p> <p class="leafygreen-ui-1kp3ins"> If <code class="leafygreen-ui-1l06pbn"> ordered </code> is set to <code class="leafygreen-ui-1l06pbn"> true </code> and an insert fails, the server does not continue inserting records. </p> <p class="leafygreen-ui-1kp3ins"> If <code class="leafygreen-ui-1l06pbn"> ordered </code> is set to <code class="leafygreen-ui-1l06pbn"> false </code> and an insert fails, the server continues inserting records. Documents may be reordered by <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> to increase performance. Applications should not depend on ordering of inserts if using an unordered <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-method-db.collection.insertMany" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> insertMany() </code> . </span> </a> </p> <p class="leafygreen-ui-1kp3ins"> The number of operations in each group cannot exceed the value of the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/limits/#mongodb-limit-Write-Command-Batch-Limit-Size"> maxWriteBatchSize </a> of the database. The default value of <code class="leafygreen-ui-1l06pbn"> maxWriteBatchSize </code> is <code class="leafygreen-ui-1l06pbn"> 100,000 </code> . This value is shown in the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/command/hello/#mongodb-data-hello.maxWriteBatchSize"> <code class="leafygreen-ui-1l06pbn"> hello.maxWriteBatchSize </code> </a> field. </p> <p class="leafygreen-ui-1kp3ins"> This limit prevents issues with oversized error messages. If a group exceeds this <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/limits/#mongodb-limit-Write-Command-Batch-Limit-Size"> limit </a> , the client driver divides the group into smaller groups with counts less than or equal to the value of the limit. For example, with the <code class="leafygreen-ui-1l06pbn"> maxWriteBatchSize </code> value of <code class="leafygreen-ui-1l06pbn"> 100,000 </code> , if the queue consists of <code class="leafygreen-ui-1l06pbn"> 200,000 </code> operations, the driver creates 2 groups, each with <code class="leafygreen-ui-1l06pbn"> 100,000 </code> operations. </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"> The driver only divides the group into smaller groups when using the high-level API. If using <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/db.runCommand/#mongodb-method-db.runCommand"> <code class="leafygreen-ui-1l06pbn"> db.runCommand() </code> </a> directly (for example, when writing a driver), MongoDB throws an error when attempting to execute a write batch which exceeds the limit. </p> </div> </div> <p class="leafygreen-ui-1kp3ins"> If the error report for a single batch grows too large, MongoDB truncates all remaining error messages to the empty string. If there are at least two error messages with total size greater than <code class="leafygreen-ui-1l06pbn"> 1MB </code> , they are trucated. </p> <p class="leafygreen-ui-1kp3ins"> The sizes and grouping mechanics are internal performance details and are subject to change in future versions. </p> <p class="leafygreen-ui-1kp3ins"> Executing an <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/db.collection.initializeOrderedBulkOp/#mongodb-method-db.collection.initializeOrderedBulkOp"> <code class="leafygreen-ui-1l06pbn"> ordered </code> </a> list of operations on a sharded collection will generally be slower than executing an <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/db.collection.initializeUnorderedBulkOp/#mongodb-method-db.collection.initializeUnorderedBulkOp"> <code class="leafygreen-ui-1l06pbn"> unordered </code> </a> list since with an ordered list, each operation must wait for the previous operation to finish. </p> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Collection Creation <a class="headerlink leafygreen-ui-1kepx47" href="#collection-creation" 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="collection-creation"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> If the collection does not exist, then <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-method-db.collection.insertMany" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> insertMany() </code> </span> </a> creates the collection on successful write. </p> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> <code class="leafygreen-ui-1l06pbn"> _id </code> Field <a class="headerlink leafygreen-ui-1kepx47" href="#_id-field" 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="_id-field"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> If the document does not specify an <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-_id"> _id </a> field, then <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> adds the <code class="leafygreen-ui-1l06pbn"> _id </code> field and assign a unique <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/ObjectId/#mongodb-method-ObjectId"> <code class="leafygreen-ui-1l06pbn"> ObjectId() </code> </a> for the document. Most drivers create an ObjectId and insert the <code class="leafygreen-ui-1l06pbn"> _id </code> field, but the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> will create and populate the <code class="leafygreen-ui-1l06pbn"> _id </code> if the driver or application does not. </p> <p class="leafygreen-ui-1kp3ins"> If the document contains an <code class="leafygreen-ui-1l06pbn"> _id </code> field, the <code class="leafygreen-ui-1l06pbn"> _id </code> value must be unique within the collection to avoid duplicate key error. </p> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Explainability <a class="headerlink leafygreen-ui-1kepx47" href="#explainability" 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="explainability"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-method-db.collection.insertMany" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> insertMany() </code> </span> </a> is not compatible with <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/db.collection.explain/#mongodb-method-db.collection.explain"> <code class="leafygreen-ui-1l06pbn"> db.collection.explain() </code> . </a> </p> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Error Handling <a class="headerlink leafygreen-ui-1kepx47" href="#error-handling" 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="error-handling"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> Inserts throw a <code class="leafygreen-ui-1l06pbn"> BulkWriteError </code> exception. </p> <p class="leafygreen-ui-1kp3ins"> Excluding <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/write-concern/#std-label-write-concern"> write concern </a> errors, ordered operations stop after an error, while unordered operations continue to process any remaining write operations in the queue. </p> <p class="leafygreen-ui-1kp3ins"> Write concern errors are displayed in the <code class="leafygreen-ui-1l06pbn"> writeConcernErrors </code> field, while all other errors are displayed in the <code class="leafygreen-ui-1l06pbn"> writeErrors </code> field. If an error is encountered, the number of successful write operations are displayed instead of a list of inserted _ids. Ordered operations display the single error encountered while unordered operations display each error in an array. </p> <section> <h4 class="contains-headerlink leafygreen-ui-1vzlt5f"> Schema Validation Errors <a class="headerlink leafygreen-ui-1kepx47" href="#schema-validation-errors" 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="schema-validation-errors"> </div> </a> </h4> <p class="leafygreen-ui-1kp3ins"> If your collection uses <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/schema-validation/#std-label-schema-validation-overview"> schema validation </a> and has <code class="leafygreen-ui-1l06pbn"> validationAction </code> set to <code class="leafygreen-ui-1l06pbn"> error </code> , inserting an invalid document with <code class="leafygreen-ui-1l06pbn"> db.collection.insertMany() </code> throws a <code class="leafygreen-ui-1l06pbn"> writeError </code> . Documents that precede the invalid document in the <code class="leafygreen-ui-1l06pbn"> documents </code> array are written to the collection. The value of the <code class="leafygreen-ui-1l06pbn"> ordered </code> field determines if the remaining valid documents are inserted. </p> </section> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Transactions <a class="headerlink leafygreen-ui-1kepx47" href="#transactions" 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="transactions"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-method-db.collection.insertMany" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> db.collection.insertMany() </code> </span> </a> can be used inside <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/transactions/#std-label-transactions"> distributed transactions <!-- --> . </a> </p> <div class="leafygreen-ui-85da11" role="note"> <h2 class="leafygreen-ui-1ac4g5h"> Important </h2> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> In most cases, a distributed transaction incurs a greater performance cost over single document writes, and the availability of distributed transactions should not be a replacement for effective schema design. For many scenarios, the <a class="leafygreen-ui-tqgtui" href="/docs/manual/data-modeling/concepts/embedding-vs-references/#std-label-data-modeling-embedding"> denormalized data model (embedded documents and arrays) </a> will continue to be optimal for your data and use cases. That is, for many scenarios, modeling your data appropriately will minimize the need for distributed transactions. </p> <p class="leafygreen-ui-1kp3ins"> For additional transactions usage considerations (such as runtime limit and oplog size limit), see also <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/transactions-production-consideration/#std-label-production-considerations"> Production Considerations <!-- --> . </a> </p> </div> </div> <section> <h4 class="contains-headerlink leafygreen-ui-1vzlt5f"> Collection Creation in Transactions <a class="headerlink leafygreen-ui-1kepx47" href="#collection-creation-in-transactions" 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="collection-creation-in-transactions"> </div> </a> </h4> <p class="leafygreen-ui-1kp3ins"> You can create collections and indexes inside a <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/transactions/#std-label-transactions-create-collections-indexes"> distributed transaction </a> if the transaction is <strong class="css-4dei7l"> not </strong> a cross-shard write transaction. </p> <p class="leafygreen-ui-1kp3ins"> If you specify an insert on a non-existing collection in a transaction, MongoDB creates the collection implicitly. </p> <div class="leafygreen-ui-13vw3ie" role="note"> <h2 class="leafygreen-ui-1fn4p2b"> Tip </h2> <h3 class="leafygreen-ui-144d5kf"> <strong> See also: </strong> </h3> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/transactions/#std-label-transactions-create-collections-indexes"> Create Collections and Indexes in a Transaction </a> </p> </div> </div> </section> <section> <h4 class="contains-headerlink leafygreen-ui-1vzlt5f"> Write Concerns and Transactions <a class="headerlink leafygreen-ui-1kepx47" href="#write-concerns-and-transactions" 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="write-concerns-and-transactions"> </div> </a> </h4> <p class="leafygreen-ui-1kp3ins"> Do not explicitly set the write concern for the operation if run in a transaction. To use write concern with transactions, see <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/transactions/#std-label-transactions-write-concern"> Transactions and Write Concern <!-- --> . </a> </p> </section> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Performance Consideration for Random Data <a class="headerlink leafygreen-ui-1kepx47" href="#performance-consideration-for-random-data" 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="performance-consideration-for-random-data"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> If an operation inserts a large amount of random data (for example, hashed indexes) on an indexed field, insert performance may decrease. Bulk inserts of random data create random index entries, which increase the size of the index. If the index reaches the size that requires each random insert to access a different index entry, the inserts result in a high rate of WiredTiger cache eviction and replacement. When this happens, the index is no longer fully in cache and is updated on disk, which decreases performance. </p> <p class="leafygreen-ui-1kp3ins"> To improve the performance of bulk inserts of random data on indexed fields, you can either: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Drop the index, then recreate it after you insert the random data. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Insert the data into an empty unindexed collection. </p> </li> </ul> <p class="leafygreen-ui-1kp3ins"> Creating the index after the bulk insert sorts the data in memory and performs an ordered insert on all indexes. </p> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Oplog Entries <a class="headerlink leafygreen-ui-1kepx47" href="#oplog-entries" 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="oplog-entries"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> If a <code class="leafygreen-ui-1l06pbn"> db.collection.insertMany() </code> operation successfully inserts one or more documents, the operation adds an entry on the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-oplog"> oplog </a> (operations log) for each inserted document. If the operation fails, the operation does not add an entry on the oplog. </p> <span class="leafygreen-ui-1qnjd6d" id="std-label-insertMany-examples"> </span> </section> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Examples <a class="headerlink leafygreen-ui-1kepx47" href="#examples" 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="examples"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> The following examples insert documents into the <code class="leafygreen-ui-1l06pbn"> products </code> collection. </p> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Insert Several Document without Specifying an <code class="leafygreen-ui-1l06pbn"> _id </code> Field <a class="headerlink leafygreen-ui-1kepx47" href="#insert-several-document-without-specifying-an-_id-field" 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="insert-several-document-without-specifying-an-_id-field"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> The following example uses <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-method-db.collection.insertMany" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> db.collection.insertMany() </code> </span> </a> to insert documents that do not contain the <code class="leafygreen-ui-1l06pbn"> _id </code> field: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"try {\n db.products.insertMany( [\n { item: \"card\", qty: 15 },\n { item: \"envelope\", qty: 20 },\n { item: \"stamps\" , qty: 30 }\n ] );\n} catch (e) {\n print (e);\n}","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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"><span class="lg-highlight-keyword">try</span> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->db.<span class="lg-highlight-property">products</span>.<span class="lg-highlight-title lg-highlight-function">insertMany</span>( <!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">item</span>: <span class="lg-highlight-string">"card"</span>, <span class="lg-highlight-attr">qty</span>: <span class="lg-highlight-number">15</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">item</span>: <span class="lg-highlight-string">"envelope"</span>, <span class="lg-highlight-attr">qty</span>: <span class="lg-highlight-number">20</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">item</span>: <span class="lg-highlight-string">"stamps"</span> <!-- -->, <span class="lg-highlight-attr">qty</span>: <span class="lg-highlight-number">30</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> ] )<!-- -->;</td></tr><tr class=""><td class="leafygreen-ui-7razhx">} <span class="lg-highlight-keyword">catch</span> <!-- -->(<!-- -->e) <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->print <!-- -->(<!-- -->e)<!-- -->;</td></tr><tr class=""><td class="leafygreen-ui-7razhx">}</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 operation returns the following document: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{\n \"acknowledged\" : true,\n \"insertedIds\" : [\n ObjectId(\"562a94d381cb9f1cd6eb0e1a\"),\n ObjectId(\"562a94d381cb9f1cd6eb0e1b\"),\n ObjectId(\"562a94d381cb9f1cd6eb0e1c\")\n ]\n}","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"acknowledged"</span> <!-- -->: <span class="lg-highlight-literal">true</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"insertedIds"</span> <!-- -->: <!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-title lg-highlight-class">ObjectId</span>(<span class="lg-highlight-string">"562a94d381cb9f1cd6eb0e1a"</span>)<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-title lg-highlight-class">ObjectId</span>(<span class="lg-highlight-string">"562a94d381cb9f1cd6eb0e1b"</span>)<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-title lg-highlight-class">ObjectId</span>(<span class="lg-highlight-string">"562a94d381cb9f1cd6eb0e1c"</span>)</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> ]</td></tr><tr class=""><td class="leafygreen-ui-7razhx">}</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"> Because the documents did not include <code class="leafygreen-ui-1l06pbn"> _id </code> , <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> creates and adds the <code class="leafygreen-ui-1l06pbn"> _id </code> field for each document and assigns it a unique <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/ObjectId/#mongodb-method-ObjectId"> <code class="leafygreen-ui-1l06pbn"> ObjectId() </code> </a> value. </p> <p class="leafygreen-ui-1kp3ins"> The <code class="leafygreen-ui-1l06pbn"> ObjectId </code> values are specific to the machine and time when the operation is run. As such, your values may differ from those in the example. </p> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Insert Several Document Specifying an <code class="leafygreen-ui-1l06pbn"> _id </code> Field <a class="headerlink leafygreen-ui-1kepx47" href="#insert-several-document-specifying-an-_id-field" 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="insert-several-document-specifying-an-_id-field"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> The following example/operation uses <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-method-db.collection.insertMany" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> insertMany() </code> </span> </a> to insert documents that include the <code class="leafygreen-ui-1l06pbn"> _id </code> field. The value of <code class="leafygreen-ui-1l06pbn"> _id </code> must be unique within the collection to avoid a duplicate key error. </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"try {\n db.products.insertMany( [\n { _id: 10, item: \"large box\", qty: 20 },\n { _id: 11, item: \"small box\", qty: 55 },\n { _id: 12, item: \"medium box\", qty: 30 }\n ] );\n} catch (e) {\n print (e);\n}","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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"><span class="lg-highlight-keyword">try</span> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->db.<span class="lg-highlight-property">products</span>.<span class="lg-highlight-title lg-highlight-function">insertMany</span>( <!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">10</span>, <span class="lg-highlight-attr">item</span>: <span class="lg-highlight-string">"large box"</span>, <span class="lg-highlight-attr">qty</span>: <span class="lg-highlight-number">20</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">11</span>, <span class="lg-highlight-attr">item</span>: <span class="lg-highlight-string">"small box"</span>, <span class="lg-highlight-attr">qty</span>: <span class="lg-highlight-number">55</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">12</span>, <span class="lg-highlight-attr">item</span>: <span class="lg-highlight-string">"medium box"</span>, <span class="lg-highlight-attr">qty</span>: <span class="lg-highlight-number">30</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> ] )<!-- -->;</td></tr><tr class=""><td class="leafygreen-ui-7razhx">} <span class="lg-highlight-keyword">catch</span> <!-- -->(<!-- -->e) <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->print <!-- -->(<!-- -->e)<!-- -->;</td></tr><tr class=""><td class="leafygreen-ui-7razhx">}</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 operation returns the following document: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ \"acknowledged\" : true, \"insertedIds\" : [ 10, 11, 12 ] }","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">{ <span class="lg-highlight-string">"acknowledged"</span> <!-- -->: <span class="lg-highlight-literal">true</span>, <span class="lg-highlight-string">"insertedIds"</span> <!-- -->: <!-- -->[ <span class="lg-highlight-number">10</span>, <span class="lg-highlight-number">11</span>, <span class="lg-highlight-number">12</span> ] }</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"> Inserting a duplicate value for any key that is part of a <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-unique-index"> unique index </a> , such as <code class="leafygreen-ui-1l06pbn"> _id </code> , throws an exception. The following attempts to insert a document with a <code class="leafygreen-ui-1l06pbn"> _id </code> value that already exists: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"try {\n db.products.insertMany( [\n { _id: 13, item: \"envelopes\", qty: 60 },\n { _id: 13, item: \"stamps\", qty: 110 },\n { _id: 14, item: \"packing tape\", qty: 38 }\n ] );\n} catch (e) {\n print (e);\n}","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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"><span class="lg-highlight-keyword">try</span> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->db.<span class="lg-highlight-property">products</span>.<span class="lg-highlight-title lg-highlight-function">insertMany</span>( <!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">13</span>, <span class="lg-highlight-attr">item</span>: <span class="lg-highlight-string">"envelopes"</span>, <span class="lg-highlight-attr">qty</span>: <span class="lg-highlight-number">60</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">13</span>, <span class="lg-highlight-attr">item</span>: <span class="lg-highlight-string">"stamps"</span>, <span class="lg-highlight-attr">qty</span>: <span class="lg-highlight-number">110</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">14</span>, <span class="lg-highlight-attr">item</span>: <span class="lg-highlight-string">"packing tape"</span>, <span class="lg-highlight-attr">qty</span>: <span class="lg-highlight-number">38</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> ] )<!-- -->;</td></tr><tr class=""><td class="leafygreen-ui-7razhx">} <span class="lg-highlight-keyword">catch</span> <!-- -->(<!-- -->e) <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->print <!-- -->(<!-- -->e)<!-- -->;</td></tr><tr class=""><td class="leafygreen-ui-7razhx">}</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"> Since <code class="leafygreen-ui-1l06pbn"> _id: 13 </code> already exists, the following exception is thrown: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"BulkWriteError({\n \"writeErrors\" : [\n {\n \"index\" : 0,\n \"code\" : 11000,\n \"errmsg\" : \"E11000 duplicate key error collection: inventory.products index: _id_ dup key: { : 13.0 }\",\n \"op\" : {\n \"_id\" : 13,\n \"item\" : \"stamps\",\n \"qty\" : 110\n }\n }\n ],\n \"writeConcernErrors\" : [ ],\n \"nInserted\" : 1,\n \"nUpserted\" : 0,\n \"nMatched\" : 0,\n \"nModified\" : 0,\n \"nRemoved\" : 0,\n \"upserted\" : [ ]\n})","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-title lg-highlight-class">BulkWriteError</span>(<!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"writeErrors"</span> <!-- -->: <!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"index"</span> <!-- -->: <span class="lg-highlight-number">0</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"code"</span> <!-- -->: <span class="lg-highlight-number">11000</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"errmsg"</span> <!-- -->: <span class="lg-highlight-string">"E11000 duplicate key error collection: inventory.products index: _id_ dup key: { : 13.0 }"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"op"</span> <!-- -->: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">13</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"item"</span> <!-- -->: <span class="lg-highlight-string">"stamps"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"qty"</span> <!-- -->: <span class="lg-highlight-number">110</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> ]<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"writeConcernErrors"</span> <!-- -->: <!-- -->[ <!-- -->]<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"nInserted"</span> <!-- -->: <span class="lg-highlight-number">1</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"nUpserted"</span> <!-- -->: <span class="lg-highlight-number">0</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"nMatched"</span> <!-- -->: <span class="lg-highlight-number">0</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"nModified"</span> <!-- -->: <span class="lg-highlight-number">0</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"nRemoved"</span> <!-- -->: <span class="lg-highlight-number">0</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"upserted"</span> <!-- -->: <!-- -->[ <!-- -->]</td></tr><tr class=""><td class="leafygreen-ui-7razhx">})</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"> Note that one document was inserted: The first document of <code class="leafygreen-ui-1l06pbn"> _id: 13 </code> will insert successfully, but the second insert will fail. This will also stop additional documents left in the queue from being inserted. </p> <p class="leafygreen-ui-1kp3ins"> With <code class="leafygreen-ui-1l06pbn"> ordered </code> to <code class="leafygreen-ui-1l06pbn"> false </code> , the insert operation would continue with any remaining documents. </p> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Unordered Inserts <a class="headerlink leafygreen-ui-1kepx47" href="#unordered-inserts" 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="unordered-inserts"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> The following attempts to insert multiple documents with <code class="leafygreen-ui-1l06pbn"> _id </code> field and <code class="leafygreen-ui-1l06pbn"> ordered: false </code> . The array of documents contains two documents with duplicate <code class="leafygreen-ui-1l06pbn"> _id </code> fields. </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"try {\n db.products.insertMany( [\n { _id: 10, item: \"large box\", qty: 20 },\n { _id: 11, item: \"small box\", qty: 55 },\n { _id: 11, item: \"medium box\", qty: 30 },\n { _id: 12, item: \"envelope\", qty: 100},\n { _id: 13, item: \"stamps\", qty: 125 },\n { _id: 13, item: \"tape\", qty: 20},\n { _id: 14, item: \"bubble wrap\", qty: 30}\n ], { ordered: false } );\n} catch (e) {\n print (e);\n}","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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"><span class="lg-highlight-keyword">try</span> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->db.<span class="lg-highlight-property">products</span>.<span class="lg-highlight-title lg-highlight-function">insertMany</span>( <!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">10</span>, <span class="lg-highlight-attr">item</span>: <span class="lg-highlight-string">"large box"</span>, <span class="lg-highlight-attr">qty</span>: <span class="lg-highlight-number">20</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">11</span>, <span class="lg-highlight-attr">item</span>: <span class="lg-highlight-string">"small box"</span>, <span class="lg-highlight-attr">qty</span>: <span class="lg-highlight-number">55</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">11</span>, <span class="lg-highlight-attr">item</span>: <span class="lg-highlight-string">"medium box"</span>, <span class="lg-highlight-attr">qty</span>: <span class="lg-highlight-number">30</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">12</span>, <span class="lg-highlight-attr">item</span>: <span class="lg-highlight-string">"envelope"</span>, <span class="lg-highlight-attr">qty</span>: <span class="lg-highlight-number">100</span>}<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">13</span>, <span class="lg-highlight-attr">item</span>: <span class="lg-highlight-string">"stamps"</span>, <span class="lg-highlight-attr">qty</span>: <span class="lg-highlight-number">125</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">13</span>, <span class="lg-highlight-attr">item</span>: <span class="lg-highlight-string">"tape"</span>, <span class="lg-highlight-attr">qty</span>: <span class="lg-highlight-number">20</span>}<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">14</span>, <span class="lg-highlight-attr">item</span>: <span class="lg-highlight-string">"bubble wrap"</span>, <span class="lg-highlight-attr">qty</span>: <span class="lg-highlight-number">30</span>}</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> ]<!-- -->, <!-- -->{ <span class="lg-highlight-attr">ordered</span>: <span class="lg-highlight-literal">false</span> } )<!-- -->;</td></tr><tr class=""><td class="leafygreen-ui-7razhx">} <span class="lg-highlight-keyword">catch</span> <!-- -->(<!-- -->e) <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->print <!-- -->(<!-- -->e)<!-- -->;</td></tr><tr class=""><td class="leafygreen-ui-7razhx">}</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 operation throws the following exception: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"BulkWriteError({\n \"writeErrors\" : [\n {\n \"index\" : 2,\n \"code\" : 11000,\n \"errmsg\" : \"E11000 duplicate key error collection: inventory.products index: _id_ dup key: { : 11.0 }\",\n \"op\" : {\n \"_id\" : 11,\n \"item\" : \"medium box\",\n \"qty\" : 30\n }\n },\n {\n \"index\" : 5,\n \"code\" : 11000,\n \"errmsg\" : \"E11000 duplicate key error collection: inventory.products index: _id_ dup key: { : 13.0 }\",\n \"op\" : {\n \"_id\" : 13,\n \"item\" : \"tape\",\n \"qty\" : 20\n }\n }\n ],\n \"writeConcernErrors\" : [ ],\n \"nInserted\" : 5,\n \"nUpserted\" : 0,\n \"nMatched\" : 0,\n \"nModified\" : 0,\n \"nRemoved\" : 0,\n \"upserted\" : [ ]\n})","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-title lg-highlight-class">BulkWriteError</span>(<!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"writeErrors"</span> <!-- -->: <!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"index"</span> <!-- -->: <span class="lg-highlight-number">2</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"code"</span> <!-- -->: <span class="lg-highlight-number">11000</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"errmsg"</span> <!-- -->: <span class="lg-highlight-string">"E11000 duplicate key error collection: inventory.products index: _id_ dup key: { : 11.0 }"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"op"</span> <!-- -->: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">11</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"item"</span> <!-- -->: <span class="lg-highlight-string">"medium box"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"qty"</span> <!-- -->: <span class="lg-highlight-number">30</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"index"</span> <!-- -->: <span class="lg-highlight-number">5</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"code"</span> <!-- -->: <span class="lg-highlight-number">11000</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"errmsg"</span> <!-- -->: <span class="lg-highlight-string">"E11000 duplicate key error collection: inventory.products index: _id_ dup key: { : 13.0 }"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"op"</span> <!-- -->: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">13</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"item"</span> <!-- -->: <span class="lg-highlight-string">"tape"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"qty"</span> <!-- -->: <span class="lg-highlight-number">20</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> ]<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"writeConcernErrors"</span> <!-- -->: <!-- -->[ <!-- -->]<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"nInserted"</span> <!-- -->: <span class="lg-highlight-number">5</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"nUpserted"</span> <!-- -->: <span class="lg-highlight-number">0</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"nMatched"</span> <!-- -->: <span class="lg-highlight-number">0</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"nModified"</span> <!-- -->: <span class="lg-highlight-number">0</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"nRemoved"</span> <!-- -->: <span class="lg-highlight-number">0</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"upserted"</span> <!-- -->: <!-- -->[ <!-- -->]</td></tr><tr class=""><td class="leafygreen-ui-7razhx">})</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"> While the document with <code class="leafygreen-ui-1l06pbn"> item: "medium box" </code> and <code class="leafygreen-ui-1l06pbn"> item: "tape" </code> failed to insert due to duplicate <code class="leafygreen-ui-1l06pbn"> _id </code> values, <code class="leafygreen-ui-1l06pbn"> nInserted </code> shows that the remaining 5 documents were inserted. </p> <span class="leafygreen-ui-1qnjd6d" id="std-label-insertMany-using-write-concern"> </span> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Using Write Concern <a class="headerlink leafygreen-ui-1kepx47" href="#using-write-concern" 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="using-write-concern"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> Given a three member replica set, the following operation specifies a <code class="leafygreen-ui-1l06pbn"> w </code> of <code class="leafygreen-ui-1l06pbn"> majority </code> and <code class="leafygreen-ui-1l06pbn"> wtimeout </code> of <code class="leafygreen-ui-1l06pbn"> 100 </code> : </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"try {\n db.products.insertMany(\n [\n { _id: 10, item: \"large box\", qty: 20 },\n { _id: 11, item: \"small box\", qty: 55 },\n { _id: 12, item: \"medium box\", qty: 30 }\n ],\n { w: \"majority\", wtimeout: 100 }\n );\n} catch (e) {\n print (e);\n}","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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"><span class="lg-highlight-keyword">try</span> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->db.<span class="lg-highlight-property">products</span>.<span class="lg-highlight-title lg-highlight-function">insertMany</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">10</span>, <span class="lg-highlight-attr">item</span>: <span class="lg-highlight-string">"large box"</span>, <span class="lg-highlight-attr">qty</span>: <span class="lg-highlight-number">20</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">11</span>, <span class="lg-highlight-attr">item</span>: <span class="lg-highlight-string">"small box"</span>, <span class="lg-highlight-attr">qty</span>: <span class="lg-highlight-number">55</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">12</span>, <span class="lg-highlight-attr">item</span>: <span class="lg-highlight-string">"medium box"</span>, <span class="lg-highlight-attr">qty</span>: <span class="lg-highlight-number">30</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> ]<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">w</span>: <span class="lg-highlight-string">"majority"</span>, <span class="lg-highlight-attr">wtimeout</span>: <span class="lg-highlight-number">100</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> )<!-- -->;</td></tr><tr class=""><td class="leafygreen-ui-7razhx">} <span class="lg-highlight-keyword">catch</span> <!-- -->(<!-- -->e) <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->print <!-- -->(<!-- -->e)<!-- -->;</td></tr><tr class=""><td class="leafygreen-ui-7razhx">}</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"> If the primary and at least one secondary acknowledge each write operation within 100 milliseconds, it returns: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{\n \"acknowledged\" : true,\n \"insertedIds\" : [\n ObjectId(\"562a94d381cb9f1cd6eb0e1a\"),\n ObjectId(\"562a94d381cb9f1cd6eb0e1b\"),\n ObjectId(\"562a94d381cb9f1cd6eb0e1c\")\n ]\n}","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"acknowledged"</span> <!-- -->: <span class="lg-highlight-literal">true</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"insertedIds"</span> <!-- -->: <!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-title lg-highlight-class">ObjectId</span>(<span class="lg-highlight-string">"562a94d381cb9f1cd6eb0e1a"</span>)<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-title lg-highlight-class">ObjectId</span>(<span class="lg-highlight-string">"562a94d381cb9f1cd6eb0e1b"</span>)<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-title lg-highlight-class">ObjectId</span>(<span class="lg-highlight-string">"562a94d381cb9f1cd6eb0e1c"</span>)</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> ]</td></tr><tr class=""><td class="leafygreen-ui-7razhx">}</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"> If the total time required for all required nodes in the replica set to acknowledge the write operation is greater than <code class="leafygreen-ui-1l06pbn"> wtimeout </code> , the following <code class="leafygreen-ui-1l06pbn"> writeConcernError </code> is displayed when the <code class="leafygreen-ui-1l06pbn"> wtimeout </code> period has passed. </p> <p class="leafygreen-ui-1kp3ins"> This operation returns: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"WriteConcernError({\n \"code\" : 64,\n \"errmsg\" : \"waiting for replication timed out\",\n \"errInfo\" : {\n \"wtimeout\" : true,\n \"writeConcern\" : {\n \"w\" : \"majority\",\n \"wtimeout\" : 100,\n \"provenance\" : \"getLastErrorDefaults\"\n }\n }\n})","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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"><span class="lg-highlight-title lg-highlight-class">WriteConcernError</span>(<!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"code"</span> <!-- -->: <span class="lg-highlight-number">64</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"errmsg"</span> <!-- -->: <span class="lg-highlight-string">"waiting for replication timed out"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"errInfo"</span> <!-- -->: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"wtimeout"</span> <!-- -->: <span class="lg-highlight-literal">true</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"writeConcern"</span> <!-- -->: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"w"</span> <!-- -->: <span class="lg-highlight-string">"majority"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"wtimeout"</span> <!-- -->: <span class="lg-highlight-number">100</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"provenance"</span> <!-- -->: <span class="lg-highlight-string">"getLastErrorDefaults"</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">})</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-13vw3ie" role="note"> <h2 class="leafygreen-ui-1fn4p2b"> Tip </h2> <h3 class="leafygreen-ui-144d5kf"> <strong> See also: </strong> </h3> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/WriteResult/#mongodb-data-WriteResult.writeConcernError"> <code class="leafygreen-ui-1l06pbn"> WriteResult.writeConcernError </code> </a> </p> </div> </div> </section> </section> </section>
https://www.mongodb.com/docs/manual/core/indexes/index-types/index-text/create-wildcard-text-index/
<section> <h1 class="contains-headerlink leafygreen-ui-41fr9s" weight="medium"> Create a Wildcard Text Index on Self-Managed Deployments <a class="headerlink leafygreen-ui-1kepx47" href="#create-a-wildcard-text-index-on-self-managed-deployments" 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="create-a-wildcard-text-index-on-self-managed-deployments"> </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="#about-this-task" target="_self"> <span> About this Task </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#before-you-begin" target="_self"> <span> Before You Begin </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#procedure" target="_self"> <span> Procedure </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#results" target="_self"> <span> Results </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-x9koo9" href="#search-for-a-single-word" target="_self"> <span> Search for a Single Word </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-x9koo9" href="#search-for-multiple-terms" target="_self"> <span> Search for Multiple Terms </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-x9koo9" href="#search-for-an-exact-phrase" target="_self"> <span> Search for an Exact Phrase </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#learn-more" target="_self"> <span> Learn More </span> </a> </li> </ul> </div> <p class="leafygreen-ui-1kp3ins"> You can create a text index that contains every document field with string data in a collection. These text indexes are called <strong> wildcard text indexes </strong> . Wildcard text indexes support <a class="leafygreen-ui-tqgtui" href="/docs/manual/text-search/#std-label-text-search"> text search </a> on unknown, arbitrary, or dynamically generated fields. </p> <p class="leafygreen-ui-1kp3ins"> To create a wildcard text index, set the index key to the wildcard specifier ( <code class="leafygreen-ui-1l06pbn"> $** </code> ) and set the index value to <code class="leafygreen-ui-1l06pbn"> text </code> : </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.&lt;collection&gt;.createIndex( { \"$**\": \"text\" } )","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.<!-- -->&lt;<!-- -->collection<!-- -->&gt;<!-- -->.<span class="lg-highlight-title lg-highlight-function">createIndex</span>( <!-- -->{ <span class="lg-highlight-string">"$**"</span>: <span class="lg-highlight-string">"text"</span> } )</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> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> About this Task <a class="headerlink leafygreen-ui-1kepx47" href="#about-this-task" 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="about-this-task"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> Wildcard text indexes are distinct from <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/indexes/index-types/index-wildcard/#std-label-wildcard-index-core"> wildcard indexes </a> . Wildcard text indexes support queries that use the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/query/text/#mongodb-query-op.-text"> <code class="leafygreen-ui-1l06pbn"> $text </code> </a> operator, while wildcard indexes do not. </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"> <code class="leafygreen-ui-1l06pbn"> $text </code> provides text query capabilities for self-managed (non-Atlas) deployments. For data hosted on MongoDB Atlas, MongoDB offers an improved full-text query solution, <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/atlas/atlas-search/" target="_self"> <span> Atlas Search <!-- --> . </span> </a> </p> </div> </div> <p class="leafygreen-ui-1kp3ins"> After you create a wildcard text index, when you insert or update documents, the index updates to include any new string field values. As a result, wildcard text indexes negatively impact performance for inserts and updates. </p> <p class="leafygreen-ui-1kp3ins"> Only use wildcard text indexes when the fields you want to index are unknown or may change. Wildcard text indexes don't perform as well as targeted text indexes on specific fields. If your collection contains arbitrary field names that prevent targeted indexes, consider remodeling your schema to have consistent field names. To learn more about targeted indexes, see <a class="leafygreen-ui-tqgtui" href="/docs/manual/data-modeling/schema-design-process/create-indexes/#std-label-create-indexes-to-support-queries"> Create Indexes to Support Your Queries <!-- --> . </a> </p> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Before You Begin <a class="headerlink leafygreen-ui-1kepx47" href="#before-you-begin" 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="before-you-begin"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> Create a <code class="leafygreen-ui-1l06pbn"> blog </code> collection with the following documents: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.blog.insertMany( [\n {\n _id: 1,\n content: \"This morning I had a cup of coffee.\",\n about: \"beverage\",\n keywords: [ \"coffee\" ]\n },\n {\n _id: 2,\n content: \"Who likes chocolate ice cream for dessert?\",\n about: \"food\",\n keywords: [ \"poll\" ]\n },\n {\n _id: 3,\n content: \"My favorite flavors are strawberry and coffee\",\n about: \"ice cream\",\n keywords: [ \"food\", \"dessert\" ]\n }\n] )","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><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">blog</span>.<span class="lg-highlight-title lg-highlight-function">insertMany</span>( <!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">1</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">content</span>: <span class="lg-highlight-string">"This morning I had a cup of coffee."</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">about</span>: <span class="lg-highlight-string">"beverage"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">keywords</span>: <!-- -->[ <span class="lg-highlight-string">"coffee"</span> ]</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">2</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">content</span>: <span class="lg-highlight-string">"Who likes chocolate ice cream for dessert?"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">about</span>: <span class="lg-highlight-string">"food"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">keywords</span>: <!-- -->[ <span class="lg-highlight-string">"poll"</span> ]</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">3</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">content</span>: <span class="lg-highlight-string">"My favorite flavors are strawberry and coffee"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">about</span>: <span class="lg-highlight-string">"ice cream"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">keywords</span>: <!-- -->[ <span class="lg-highlight-string">"food"</span>, <span class="lg-highlight-string">"dessert"</span> ]</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">] )</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> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Procedure <a class="headerlink leafygreen-ui-1kepx47" href="#procedure" 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="procedure"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> Create a wildcard text index on the <code class="leafygreen-ui-1l06pbn"> blog </code> collection: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.blog.createIndex( { \"$**\": \"text\" } )","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">blog</span>.<span class="lg-highlight-title lg-highlight-function">createIndex</span>( <!-- -->{ <span class="lg-highlight-string">"$**"</span>: <span class="lg-highlight-string">"text"</span> } )</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> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Results <a class="headerlink leafygreen-ui-1kepx47" href="#results" 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="results"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> The wildcard text index supports text search queries on all fields in the collection. Consider the following queries: </p> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Search for a Single Word <a class="headerlink leafygreen-ui-1kepx47" href="#search-for-a-single-word" 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="search-for-a-single-word"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> Query the <code class="leafygreen-ui-1l06pbn"> blog </code> collection for the string <code class="leafygreen-ui-1l06pbn"> coffee </code> : </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.blog.find( { $text: { $search: \"coffee\" } } )","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">blog</span>.<span class="lg-highlight-title lg-highlight-function">find</span>( <!-- -->{ <span class="lg-highlight-attr">$text</span>: <!-- -->{ <span class="lg-highlight-attr">$search</span>: <span class="lg-highlight-string">"coffee"</span> } } )</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"> Output: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"[\n {\n _id: 1,\n content: 'This morning I had a cup of coffee.',\n about: 'beverage',\n keywords: [ 'coffee' ]\n },\n {\n _id: 3,\n content: 'My favorite flavors are strawberry and coffee',\n about: 'ice cream',\n keywords: [ 'food', 'dessert' ]\n }\n]","programmingLanguage":"JavaScript"} </script> <div class="css-1lju8ps"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1jheeh3"> <pre class="leafygreen-ui-1453az5" 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">[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">1</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">content</span>: <span class="lg-highlight-string">'This morning I had a cup of coffee.'</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">about</span>: <span class="lg-highlight-string">'beverage'</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">keywords</span>: <!-- -->[ <span class="lg-highlight-string">'coffee'</span> ]</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">3</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">content</span>: <span class="lg-highlight-string">'My favorite flavors are strawberry and coffee'</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">about</span>: <span class="lg-highlight-string">'ice cream'</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">keywords</span>: <!-- -->[ <span class="lg-highlight-string">'food'</span>, <span class="lg-highlight-string">'dessert'</span> ]</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">]</td></tr></tbody></table></code></pre> </div> </div> </div> <p class="leafygreen-ui-1kp3ins"> The preceding query returns all documents that contain the string <code class="leafygreen-ui-1l06pbn"> coffee </code> in any field. </p> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Search for Multiple Terms <a class="headerlink leafygreen-ui-1kepx47" href="#search-for-multiple-terms" 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="search-for-multiple-terms"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> Query the <code class="leafygreen-ui-1l06pbn"> blog </code> collection for documents that contain the string <code class="leafygreen-ui-1l06pbn"> poll </code> <strong> or </strong> <code class="leafygreen-ui-1l06pbn"> coffee </code> : </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.blog.find( { $text: { $search: \"poll coffee\" } } )","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">blog</span>.<span class="lg-highlight-title lg-highlight-function">find</span>( <!-- -->{ <span class="lg-highlight-attr">$text</span>: <!-- -->{ <span class="lg-highlight-attr">$search</span>: <span class="lg-highlight-string">"poll coffee"</span> } } )</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"> Output: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"[\n {\n _id: 1,\n content: 'This morning I had a cup of coffee.',\n about: 'beverage',\n keywords: [ 'coffee' ]\n },\n {\n _id: 3,\n content: 'My favorite flavors are strawberry and coffee',\n about: 'ice cream',\n keywords: [ 'food', 'dessert' ]\n },\n {\n _id: 2,\n content: 'Who likes chocolate ice cream for dessert?',\n about: 'food',\n keywords: [ 'poll' ]\n }\n]","programmingLanguage":"JavaScript"} </script> <div class="css-1lju8ps"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1jheeh3"> <pre class="leafygreen-ui-1453az5" 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">[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">1</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">content</span>: <span class="lg-highlight-string">'This morning I had a cup of coffee.'</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">about</span>: <span class="lg-highlight-string">'beverage'</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">keywords</span>: <!-- -->[ <span class="lg-highlight-string">'coffee'</span> ]</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">3</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">content</span>: <span class="lg-highlight-string">'My favorite flavors are strawberry and coffee'</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">about</span>: <span class="lg-highlight-string">'ice cream'</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">keywords</span>: <!-- -->[ <span class="lg-highlight-string">'food'</span>, <span class="lg-highlight-string">'dessert'</span> ]</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">2</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">content</span>: <span class="lg-highlight-string">'Who likes chocolate ice cream for dessert?'</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">about</span>: <span class="lg-highlight-string">'food'</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">keywords</span>: <!-- -->[ <span class="lg-highlight-string">'poll'</span> ]</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">]</td></tr></tbody></table></code></pre> </div> </div> </div> <p class="leafygreen-ui-1kp3ins"> The preceding query returns documents that contain the string <code class="leafygreen-ui-1l06pbn"> poll </code> or <code class="leafygreen-ui-1l06pbn"> coffee </code> in any field. </p> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Search for an Exact Phrase <a class="headerlink leafygreen-ui-1kepx47" href="#search-for-an-exact-phrase" 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="search-for-an-exact-phrase"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> Query the <code class="leafygreen-ui-1l06pbn"> blog </code> collection for documents that contain the phrase <code class="leafygreen-ui-1l06pbn"> chocolate ice cream </code> : </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.blog.find( { $text: { $search: \"\\\"chocolate ice cream\\\"\" } } )","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-1q4bxgx" tabindex="0"><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">blog</span>.<span class="lg-highlight-title lg-highlight-function">find</span>( <!-- -->{ <span class="lg-highlight-attr">$text</span>: <!-- -->{ <span class="lg-highlight-attr">$search</span>: <span class="lg-highlight-string">"</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">chocolate ice cream</span><span class="lg-highlight-string">\"</span><span class="lg-highlight-string">"</span> } } )</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"> Output: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"[\n {\n _id: 2,\n content: 'Who likes chocolate ice cream for dessert?',\n about: 'food',\n keywords: [ 'poll' ]\n }\n]","programmingLanguage":"JavaScript"} </script> <div class="css-1lju8ps"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1jheeh3"> <pre class="leafygreen-ui-1453az5" 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">[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">2</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">content</span>: <span class="lg-highlight-string">'Who likes chocolate ice cream for dessert?'</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">about</span>: <span class="lg-highlight-string">'food'</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">keywords</span>: <!-- -->[ <span class="lg-highlight-string">'poll'</span> ]</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">]</td></tr></tbody></table></code></pre> </div> </div> </div> <p class="leafygreen-ui-1kp3ins"> The preceding query returns documents that contain the exact phrase <code class="leafygreen-ui-1l06pbn"> chocolate ice cream </code> in any field. </p> </section> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Learn More <a class="headerlink leafygreen-ui-1kepx47" href="#learn-more" 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="learn-more"> </div> </a> </h2> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> To learn how to control the ranking of text query results, see <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/indexes/index-types/index-text/control-text-search-results/#std-label-specify-weights"> Assign Weights to Text Search Results on Self-Managed Deployments <!-- --> . </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> You can include a wildcard text index as part of a compound text index. To learn more about compound text indexes, see <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/indexes/index-types/index-text/create-text-index/#std-label-compound-text-index-example"> Create a Compound Text Index <!-- --> . </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> To see examples of text search queries, see <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/query/text/#mongodb-query-op.-text"> <code class="leafygreen-ui-1l06pbn"> $text </code> . </a> </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"> <code class="leafygreen-ui-1l06pbn"> $text </code> provides text query capabilities for self-managed (non-Atlas) deployments. For data hosted on MongoDB Atlas, MongoDB offers an improved full-text query solution, <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/atlas/atlas-search/" target="_self"> <span> Atlas Search <!-- --> . </span> </a> </p> </div> </div> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> To learn about text index properties such as case sensitivity, see <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/indexes/index-types/index-text/text-index-properties/#std-label-text-index-properties"> Text Index Properties on Self-Managed Deployments <!-- --> . </a> </p> </li> </ul> </section> </section>
https://www.mongodb.com/docs/manual/core/indexes/index-types/index-text/limit-number-of-items-scanned-for-text-search/
<section> <h1 class="contains-headerlink leafygreen-ui-41fr9s" weight="medium"> Limit Number of Text Index Entries Scanned on Self-Managed Deployments <a class="headerlink leafygreen-ui-1kepx47" href="#limit-number-of-text-index-entries-scanned-on-self-managed-deployments" 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="limit-number-of-text-index-entries-scanned-on-self-managed-deployments"> </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="#about-this-task" target="_self"> <span> About this Task </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#procedure" target="_self"> <span> Procedure </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#results" target="_self"> <span> Results </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-x9koo9" href="#view-number-of-documents-examined" target="_self"> <span> View Number of Documents Examined </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#learn-more" target="_self"> <span> Learn More </span> </a> </li> </ul> </div> <p class="leafygreen-ui-1kp3ins"> If you perform text search queries on a large dataset, a single-field text index may scan a large number of entries to return results, which can result in slow queries. </p> <p class="leafygreen-ui-1kp3ins"> To improve query performance, you can create a <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/indexes/index-types/index-text/create-text-index/#std-label-compound-text-index-example"> compound text index </a> and include an equality match in your text search queries. If the compound index contains the field used in your equality match, the index scans fewer entries and returns results faster. </p> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> About this Task <a class="headerlink leafygreen-ui-1kepx47" href="#about-this-task" 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="about-this-task"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> In this example, a store manager queries an <code class="leafygreen-ui-1l06pbn"> inventory </code> collection that contains these documents: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.inventory.insertMany( [\n { _id: 1, department: \"tech\", description: \"lime green computer\" },\n { _id: 2, department: \"tech\", description: \"wireless red mouse\" },\n { _id: 3, department: \"kitchen\", description: \"green placemat\" },\n { _id: 4, department: \"kitchen\", description: \"red peeler\" },\n { _id: 5, department: \"food\", description: \"green apple\" },\n { _id: 6, department: \"food\", description: \"red potato\" }\n] )","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><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">inventory</span>.<span class="lg-highlight-title lg-highlight-function">insertMany</span>( <!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">1</span>, <span class="lg-highlight-attr">department</span>: <span class="lg-highlight-string">"tech"</span>, <span class="lg-highlight-attr">description</span>: <span class="lg-highlight-string">"lime green computer"</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">2</span>, <span class="lg-highlight-attr">department</span>: <span class="lg-highlight-string">"tech"</span>, <span class="lg-highlight-attr">description</span>: <span class="lg-highlight-string">"wireless red mouse"</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">3</span>, <span class="lg-highlight-attr">department</span>: <span class="lg-highlight-string">"kitchen"</span>, <span class="lg-highlight-attr">description</span>: <span class="lg-highlight-string">"green placemat"</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">4</span>, <span class="lg-highlight-attr">department</span>: <span class="lg-highlight-string">"kitchen"</span>, <span class="lg-highlight-attr">description</span>: <span class="lg-highlight-string">"red peeler"</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">5</span>, <span class="lg-highlight-attr">department</span>: <span class="lg-highlight-string">"food"</span>, <span class="lg-highlight-attr">description</span>: <span class="lg-highlight-string">"green apple"</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">6</span>, <span class="lg-highlight-attr">department</span>: <span class="lg-highlight-string">"food"</span>, <span class="lg-highlight-attr">description</span>: <span class="lg-highlight-string">"red potato"</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">] )</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 manager performs text search queries for items within a specific department. </p> <p class="leafygreen-ui-1kp3ins"> A compound text index on the <code class="leafygreen-ui-1l06pbn"> department </code> and <code class="leafygreen-ui-1l06pbn"> description </code> fields limits the index keys scanned to only documents within the specified <code class="leafygreen-ui-1l06pbn"> department </code> . The compound text index provides improved performance compared to a single-field text index on the <code class="leafygreen-ui-1l06pbn"> description </code> field. </p> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Procedure <a class="headerlink leafygreen-ui-1kepx47" href="#procedure" 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="procedure"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> Create a compound index on the <code class="leafygreen-ui-1l06pbn"> inventory </code> collection that contains the following fields: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> An ascending or descending index key on the <code class="leafygreen-ui-1l06pbn"> department </code> field </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> A <code class="leafygreen-ui-1l06pbn"> text </code> index key on the <code class="leafygreen-ui-1l06pbn"> description </code> field </p> </li> </ul> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.inventory.createIndex(\n {\n department: 1,\n description: \"text\"\n }\n)","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">inventory</span>.<span class="lg-highlight-title lg-highlight-function">createIndex</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">department</span>: <span class="lg-highlight-number">1</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">description</span>: <span class="lg-highlight-string">"text"</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">)</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> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Results <a class="headerlink leafygreen-ui-1kepx47" href="#results" 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="results"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> After you create the compound index, text search queries only scan documents that match a specified equality condition on the <code class="leafygreen-ui-1l06pbn"> department </code> field. </p> <p class="leafygreen-ui-1kp3ins"> For example, the following query scans documents with <code class="leafygreen-ui-1l06pbn"> department </code> equal to <code class="leafygreen-ui-1l06pbn"> kitchen </code> where the <code class="leafygreen-ui-1l06pbn"> description </code> field contains the string <code class="leafygreen-ui-1l06pbn"> green </code> : </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.inventory.find( { department: \"kitchen\", $text: { $search: \"green\" } } )","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-1q4bxgx" tabindex="0"><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">inventory</span>.<span class="lg-highlight-title lg-highlight-function">find</span>( <!-- -->{ <span class="lg-highlight-attr">department</span>: <span class="lg-highlight-string">"kitchen"</span>, <span class="lg-highlight-attr">$text</span>: <!-- -->{ <span class="lg-highlight-attr">$search</span>: <span class="lg-highlight-string">"green"</span> } } )</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"> Output: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"[ { _id: 3, department: 'kitchen', description: 'green placemat' } ]","programmingLanguage":"JavaScript"} </script> <div class="css-1lju8ps"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-tyg50d"> <pre class="leafygreen-ui-1agdxuk" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">[ <!-- -->{ <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">3</span>, <span class="lg-highlight-attr">department</span>: <span class="lg-highlight-string">'kitchen'</span>, <span class="lg-highlight-attr">description</span>: <span class="lg-highlight-string">'green placemat'</span> } ]</td></tr></tbody></table></code></pre> </div> </div> </div> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> View Number of Documents Examined <a class="headerlink leafygreen-ui-1kepx47" href="#view-number-of-documents-examined" 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="view-number-of-documents-examined"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> To see how many documents were scanned to return the query, view the query's <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/explain-results/#std-label-executionStats"> <code class="leafygreen-ui-1l06pbn"> executionStats </code> : </a> </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.inventory.find(\n {\n department: \"kitchen\", $text: { $search: \"green\" }\n }\n).explain(\"executionStats\")","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">inventory</span>.<span class="lg-highlight-title lg-highlight-function">find</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">department</span>: <span class="lg-highlight-string">"kitchen"</span>, <span class="lg-highlight-attr">$text</span>: <!-- -->{ <span class="lg-highlight-attr">$search</span>: <span class="lg-highlight-string">"green"</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">).<span class="lg-highlight-title lg-highlight-function">explain</span>(<span class="lg-highlight-string">"executionStats"</span>)</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 number of index keys examined is indicated in the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/explain-results/#mongodb-data-explain.executionStats.totalKeysExamined"> <code class="leafygreen-ui-1l06pbn"> totalKeysExamined </code> </a> field. Queries that examine more index keys generally take longer to complete. </p> <p class="leafygreen-ui-1kp3ins"> With the compound index on <code class="leafygreen-ui-1l06pbn"> department </code> and <code class="leafygreen-ui-1l06pbn"> description </code> , the query only examines <strong> one </strong> index key. There is only one document in the collection where <code class="leafygreen-ui-1l06pbn"> department </code> is <code class="leafygreen-ui-1l06pbn"> kitchen </code> and the <code class="leafygreen-ui-1l06pbn"> description </code> contains the string <code class="leafygreen-ui-1l06pbn"> green </code> . </p> <p class="leafygreen-ui-1kp3ins"> However, if the query used a single-field text index only on the <code class="leafygreen-ui-1l06pbn"> description </code> field, the query would examine <strong> three </strong> index keys. There are three documents in the collection where the <code class="leafygreen-ui-1l06pbn"> description </code> field contains the string <code class="leafygreen-ui-1l06pbn"> green </code> . </p> <p class="leafygreen-ui-1kp3ins"> In a small collection like the one used in the preceding example, there isn't a noticeable difference in performance between single-field and compound text indexes. However, in larger collections, increased index entry scans can noticeably hinder performance. For best performance, create text indexes that limit the number of index entries scanned to best fit your equality matches. </p> </section> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Learn More <a class="headerlink leafygreen-ui-1kepx47" href="#learn-more" 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="learn-more"> </div> </a> </h2> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/indexes/index-types/index-text/text-index-restrictions/#std-label-text-index-compound-restrictions"> Compound text index restrictions </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/indexes/index-types/index-text/control-text-search-results/#std-label-specify-weights"> Assign Weights to Text Search Results on Self-Managed Deployments </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/indexes/index-types/index-text/text-index-properties/#std-label-text-index-properties"> Text Index Properties on Self-Managed Deployments </a> </p> </li> </ul> </section> </section>
https://www.mongodb.com/docs/manual/core/indexes/index-types/index-text/specify-text-index-language/
<section> <h1 class="contains-headerlink leafygreen-ui-41fr9s" weight="medium"> Specify the Default Language for a Text Index on Self-Managed Deployments <a class="headerlink leafygreen-ui-1kepx47" href="#specify-the-default-language-for-a-text-index-on-self-managed-deployments" 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="specify-the-default-language-for-a-text-index-on-self-managed-deployments"> </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="#before-you-begin" target="_self"> <span> Before You Begin </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#procedure" target="_self"> <span> Procedure </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#results" target="_self"> <span> Results </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#learn-more" target="_self"> <span> Learn More </span> </a> </li> </ul> </div> <p class="leafygreen-ui-1kp3ins"> By default, the <code class="leafygreen-ui-1l06pbn"> default_language </code> for text indexes is <code class="leafygreen-ui-1l06pbn"> english </code> . To improve the performance of non-English text search queries, you can specify a different default language associated with your text index. </p> <p class="leafygreen-ui-1kp3ins"> The default language associated with the indexed data determines the suffix stemming rules. The default language also determines which language-specific stop words (for example, <code class="leafygreen-ui-1l06pbn"> the </code> , <code class="leafygreen-ui-1l06pbn"> an </code> , <code class="leafygreen-ui-1l06pbn"> a </code> , and <code class="leafygreen-ui-1l06pbn"> and </code> in English) are not indexed. </p> <p class="leafygreen-ui-1kp3ins"> To specify a different language, use the <code class="leafygreen-ui-1l06pbn"> default_language </code> option when creating the text index. To see the languages available for text indexing, see <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/text-search-languages/#std-label-text-search-languages"> Text Search Languages on Self-Managed Deployments </a> . Your operation should resemble this prototype: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.&lt;collection&gt;.createIndex(\n { &lt;field&gt;: \"text\" },\n { default_language: &lt;language&gt; }\n)","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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.<!-- -->&lt;<!-- -->collection<!-- -->&gt;<!-- -->.<span class="lg-highlight-title lg-highlight-function">createIndex</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ &lt;<!-- -->field<!-- -->&gt;<!-- -->: <span class="lg-highlight-string">"text"</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">default_language</span>: &lt;<!-- -->language<!-- -->&gt; <!-- -->}</td></tr><tr class=""><td class="leafygreen-ui-7razhx">)</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"> If you specify a <code class="leafygreen-ui-1l06pbn"> default_language </code> value of <code class="leafygreen-ui-1l06pbn"> none </code> , the text index parses through each word in the field, including stop words, and ignores suffix stemming. </p> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Before You Begin <a class="headerlink leafygreen-ui-1kepx47" href="#before-you-begin" 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="before-you-begin"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> Create a <code class="leafygreen-ui-1l06pbn"> quotes </code> collection that contains the following documents with a Spanish text field: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.quotes.insertMany( [\n {\n _id: 1,\n quote : \"La suerte protege a los audaces.\"\n },\n {\n _id: 2,\n quote: \"Nada hay más surrealista que la realidad.\"\n },\n {\n _id: 3,\n quote: \"Es este un puñal que veo delante de mí?\"\n },\n {\n _id: 4,\n quote: \"Nunca dejes que la realidad te estropee una buena historia.\"\n }\n] )","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><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">quotes</span>.<span class="lg-highlight-title lg-highlight-function">insertMany</span>( <!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">1</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->quote <!-- -->: <span class="lg-highlight-string">"La suerte protege a los audaces."</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">2</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">quote</span>: <span class="lg-highlight-string">"Nada hay más surrealista que la realidad."</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">3</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">quote</span>: <span class="lg-highlight-string">"Es este un puñal que veo delante de mí?"</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">4</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">quote</span>: <span class="lg-highlight-string">"Nunca dejes que la realidad te estropee una buena historia."</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">] )</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> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Procedure <a class="headerlink leafygreen-ui-1kepx47" href="#procedure" 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="procedure"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> The following operation creates a text index on the <code class="leafygreen-ui-1l06pbn"> quote </code> field and sets the <code class="leafygreen-ui-1l06pbn"> default_language </code> to <code class="leafygreen-ui-1l06pbn"> spanish </code> : </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.quotes.createIndex(\n { quote: \"text\" },\n { default_language: \"spanish\" }\n)","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">quotes</span>.<span class="lg-highlight-title lg-highlight-function">createIndex</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">quote</span>: <span class="lg-highlight-string">"text"</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">default_language</span>: <span class="lg-highlight-string">"spanish"</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">)</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> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Results <a class="headerlink leafygreen-ui-1kepx47" href="#results" 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="results"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> The resulting index supports text search queries on the <code class="leafygreen-ui-1l06pbn"> quote </code> field with Spanish-language suffix stemming rules. For example, the following query searches for the keyword <code class="leafygreen-ui-1l06pbn"> punal </code> in the <code class="leafygreen-ui-1l06pbn"> quote </code> field: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.quotes.find(\n {\n $text: { $search: \"punal\" }\n }\n)","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">quotes</span>.<span class="lg-highlight-title lg-highlight-function">find</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">$text</span>: <!-- -->{ <span class="lg-highlight-attr">$search</span>: <span class="lg-highlight-string">"punal"</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">)</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"> Output: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"[\n {\n _id: 3,\n quote: \"Es este un puñal que veo delante de mí?\"\n }\n]","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">3</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">quote</span>: <span class="lg-highlight-string">"Es este un puñal que veo delante de mí?"</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">]</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"> Although the <code class="leafygreen-ui-1l06pbn"> $search </code> value is set to <code class="leafygreen-ui-1l06pbn"> punal </code> , the query will return the document containing the word <code class="leafygreen-ui-1l06pbn"> puñal </code> because text indexes are <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/indexes/index-types/index-text/text-index-properties/#std-label-text-index-diacritic-insensitivity"> diacritic insensitive <!-- --> . </a> </p> <p class="leafygreen-ui-1kp3ins"> The index also ignores language-specific stop words. For example, although the document with <code class="leafygreen-ui-1l06pbn"> _id: 2 </code> contains the word <code class="leafygreen-ui-1l06pbn"> hay </code> , the following query does not return any documents. <code class="leafygreen-ui-1l06pbn"> hay </code> is classified as a Spanish stop word, meaning it is not included in the text index. </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.quotes.find(\n {\n $text: { $search: \"hay\" }\n }\n)","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">quotes</span>.<span class="lg-highlight-title lg-highlight-function">find</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">$text</span>: <!-- -->{ <span class="lg-highlight-attr">$search</span>: <span class="lg-highlight-string">"hay"</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">)</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> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Learn More <a class="headerlink leafygreen-ui-1kepx47" href="#learn-more" 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="learn-more"> </div> </a> </h2> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> To create a text index for a collection containing text in multiple languages, see <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/indexes/index-types/index-text/specify-language-text-index/create-text-index-multiple-languages/#std-label-multiple-language-text-index"> Create a Text Index for a Collection Containing Multiple Languages on Self-Managed Deployments <!-- --> . </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> To learn about other text index properties, see <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/indexes/index-types/index-text/text-index-properties/#std-label-text-index-properties"> Text Index Properties on Self-Managed Deployments <!-- --> . </a> </p> </li> </ul> </section> </section>
https://www.mongodb.com/docs/manual/core/indexes/index-types/index-text/specify-language-text-index/use-any-field-to-specify-language/
<section> <h1 class="contains-headerlink leafygreen-ui-41fr9s" weight="medium"> Use Any Field to Specify Text Index Language on Self-Managed Deployments <a class="headerlink leafygreen-ui-1kepx47" href="#use-any-field-to-specify-text-index-language-on-self-managed-deployments" 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="use-any-field-to-specify-text-index-language-on-self-managed-deployments"> </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="#before-you-begin" target="_self"> <span> Before You Begin </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#procedure" target="_self"> <span> Procedure </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#results" target="_self"> <span> Results </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-x9koo9" href="#search-for-a-valid-term" target="_self"> <span> Search for a Valid Term </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-x9koo9" href="#search-for-a-stop-word" target="_self"> <span> Search for a Stop Word </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#learn-more" target="_self"> <span> Learn More </span> </a> </li> </ul> </div> <p class="leafygreen-ui-1kp3ins"> A text index's language determines the rules used to parse stem words and ignore stop words when you run text search queries. </p> <p class="leafygreen-ui-1kp3ins"> By default, if a text index does not have a <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/indexes/index-types/index-text/specify-text-index-language/#std-label-specify-text-index-language"> default language </a> , the index uses the <code class="leafygreen-ui-1l06pbn"> language </code> document field to determine the language it uses. As a result, text indexes are not limited to a single language because the value of the <code class="leafygreen-ui-1l06pbn"> language </code> field can change between documents. </p> <p class="leafygreen-ui-1kp3ins"> You can change the field that the index uses to determine its language. This is useful if your field names are not in English, and your documents do not have a field called <code class="leafygreen-ui-1l06pbn"> language </code> . </p> <p class="leafygreen-ui-1kp3ins"> To specify the text index language in a field other than <code class="leafygreen-ui-1l06pbn"> language </code> , include the <code class="leafygreen-ui-1l06pbn"> language_override </code> option when you create the index: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.&lt;collection&gt;.createIndex(\n { &lt;field&gt; : \"text\" },\n { language_override: \"&lt;field&gt;\" }\n)","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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.<!-- -->&lt;<!-- -->collection<!-- -->&gt;<!-- -->.<span class="lg-highlight-title lg-highlight-function">createIndex</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ &lt;<!-- -->field<!-- -->&gt; <!-- -->: <span class="lg-highlight-string">"text"</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">language_override</span>: <span class="lg-highlight-string">"&lt;field&gt;"</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">)</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 text index uses the field specified in the <code class="leafygreen-ui-1l06pbn"> language_override </code> option to determine the language to use for the corresponding document. </p> <p class="leafygreen-ui-1kp3ins"> For documents that don't contain the field specified in <code class="leafygreen-ui-1l06pbn"> language_override </code> , the index uses English as its language. </p> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Before You Begin <a class="headerlink leafygreen-ui-1kepx47" href="#before-you-begin" 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="before-you-begin"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> Create the <code class="leafygreen-ui-1l06pbn"> quotes </code> collection: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.quotes.insertMany(\n [\n {\n _id: 1,\n idioma: \"portuguese\",\n quote: \"A sorte protege os audazes\"\n },\n {\n _id: 2,\n idioma: \"spanish\",\n quote: \"Nada hay más surrealista que la realidad.\"\n },\n {\n _id: 3,\n idioma: \"english\",\n quote: \"is this a dagger which I see before me\"\n }\n ]\n)","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><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">quotes</span>.<span class="lg-highlight-title lg-highlight-function">insertMany</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">1</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">idioma</span>: <span class="lg-highlight-string">"portuguese"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">quote</span>: <span class="lg-highlight-string">"A sorte protege os audazes"</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">2</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">idioma</span>: <span class="lg-highlight-string">"spanish"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">quote</span>: <span class="lg-highlight-string">"Nada hay más surrealista que la realidad."</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">3</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">idioma</span>: <span class="lg-highlight-string">"english"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">quote</span>: <span class="lg-highlight-string">"is this a dagger which I see before me"</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> ]</td></tr><tr class=""><td class="leafygreen-ui-7razhx">)</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 language for each quote is specified in the <code class="leafygreen-ui-1l06pbn"> idioma </code> field. </p> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Procedure <a class="headerlink leafygreen-ui-1kepx47" href="#procedure" 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="procedure"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> Create a text index on the <code class="leafygreen-ui-1l06pbn"> quote </code> field. Specify the <code class="leafygreen-ui-1l06pbn"> language_override </code> option to cause the text index to use the <code class="leafygreen-ui-1l06pbn"> idioma </code> field for the language: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.quotes.createIndex(\n { quote : \"text\" },\n { language_override: \"idioma\" }\n)","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">quotes</span>.<span class="lg-highlight-title lg-highlight-function">createIndex</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <!-- -->quote <!-- -->: <span class="lg-highlight-string">"text"</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">language_override</span>: <span class="lg-highlight-string">"idioma"</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">)</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> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Results <a class="headerlink leafygreen-ui-1kepx47" href="#results" 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="results"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> The index supports text search queries on the <code class="leafygreen-ui-1l06pbn"> quote </code> field and uses language rules based on the language specified in the <code class="leafygreen-ui-1l06pbn"> idioma </code> field. Each document specifies a different value in the <code class="leafygreen-ui-1l06pbn"> idioma </code> field, which means that each document is searched with different language rules. </p> <p class="leafygreen-ui-1kp3ins"> Consider the following examples: </p> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Search for a Valid Term <a class="headerlink leafygreen-ui-1kepx47" href="#search-for-a-valid-term" 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="search-for-a-valid-term"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> The following query searches for the string <code class="leafygreen-ui-1l06pbn"> audazes </code> : </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.quotes.find(\n {\n $text: { $search: \"audazes\" }\n }\n)","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">quotes</span>.<span class="lg-highlight-title lg-highlight-function">find</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">$text</span>: <!-- -->{ <span class="lg-highlight-attr">$search</span>: <span class="lg-highlight-string">"audazes"</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">)</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"> Output: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"[\n { _id: 1, idioma: 'portuguese', quote: 'A sorte protege os audazes' }\n]","programmingLanguage":"JavaScript"} </script> <div class="css-1lju8ps"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-tyg50d"> <pre class="leafygreen-ui-1453az5" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">1</span>, <span class="lg-highlight-attr">idioma</span>: <span class="lg-highlight-string">'portuguese'</span>, <span class="lg-highlight-attr">quote</span>: <span class="lg-highlight-string">'A sorte protege os audazes'</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">]</td></tr></tbody></table></code></pre> </div> </div> </div> <p class="leafygreen-ui-1kp3ins"> The preceding query uses Portuguese as the language to fulfill the query. </p> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Search for a Stop Word <a class="headerlink leafygreen-ui-1kepx47" href="#search-for-a-stop-word" 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="search-for-a-stop-word"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> The following query searches for the string <code class="leafygreen-ui-1l06pbn"> hay </code> : </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.quotes.find(\n {\n $text: { $search: \"hay\" }\n }\n)","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">quotes</span>.<span class="lg-highlight-title lg-highlight-function">find</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">$text</span>: <!-- -->{ <span class="lg-highlight-attr">$search</span>: <span class="lg-highlight-string">"hay"</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">)</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 preceding query returns no results, even though the string <code class="leafygreen-ui-1l06pbn"> hay </code> appears in the <code class="leafygreen-ui-1l06pbn"> quote </code> field of document <code class="leafygreen-ui-1l06pbn"> _id: 2 </code> . </p> <p class="leafygreen-ui-1kp3ins"> Document <code class="leafygreen-ui-1l06pbn"> _id: 2 </code> specifies a language of Spanish. <code class="leafygreen-ui-1l06pbn"> hay </code> is considered a stop word in Spanish, and is therefore not incldued in the text index. </p> </section> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Learn More <a class="headerlink leafygreen-ui-1kepx47" href="#learn-more" 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="learn-more"> </div> </a> </h2> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> To see the languages available for text indexes, see <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/text-search-languages/#std-label-text-search-languages"> Text Search Languages on Self-Managed Deployments <!-- --> . </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> To learn how to specify a default language for an entire text index, see <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/indexes/index-types/index-text/specify-text-index-language/#std-label-specify-text-index-language"> Specify the Default Language for a Text Index on Self-Managed Deployments <!-- --> . </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> To see text index restrictions, see <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/indexes/index-types/index-text/text-index-restrictions/#std-label-text-index-restrictions"> Text Index Restrictions on Self-Managed Deployments <!-- --> . </a> </p> </li> </ul> </section> </section>
https://www.mongodb.com/docs/manual/core/indexes/index-types/index-text/control-text-search-results/
<section> <h1 class="contains-headerlink leafygreen-ui-41fr9s" weight="medium"> Assign Weights to Text Search Results on Self-Managed Deployments <a class="headerlink leafygreen-ui-1kepx47" href="#assign-weights-to-text-search-results-on-self-managed-deployments" 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="assign-weights-to-text-search-results-on-self-managed-deployments"> </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="#about-this-task" target="_self"> <span> About this Task </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#before-you-begin" target="_self"> <span> Before You Begin </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#procedure" target="_self"> <span> Procedure </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#results" target="_self"> <span> Results </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-x9koo9" href="#matches-in-content-and-about-fields" target="_self"> <span> Matches in <code class="css-1kekw28 e1wawog0"> content </code> and <code class="css-1kekw28 e1wawog0"> about </code> Fields </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-x9koo9" href="#matches-in-keywords-and-about-fields" target="_self"> <span> Matches in <code class="css-1kekw28 e1wawog0"> keywords </code> and <code class="css-1kekw28 e1wawog0"> about </code> Fields </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-x9koo9" href="#multiple-matches-in-a-single-document" target="_self"> <span> Multiple Matches in a Single Document </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#learn-more" target="_self"> <span> Learn More </span> </a> </li> </ul> </div> <p class="leafygreen-ui-1kp3ins"> When MongoDB returns text search results, it assigns a <strong> score </strong> to each returned document. The score indicates the relevance of the document to a given search query. You can sort returned documents by score to have the most relevant documents appear first in the result set. </p> <p class="leafygreen-ui-1kp3ins"> If you have a <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/indexes/index-types/index-compound/#std-label-index-type-compound"> compound index </a> with multiple text index keys, you can specify different <strong> weights </strong> for each indexed field. The weight of an indexed field indicates the significance of the field relative to the other indexed fields, with higher weights resulting in higher text search scores. </p> <p class="leafygreen-ui-1kp3ins"> For example, you can emphasize search matches on a <code class="leafygreen-ui-1l06pbn"> title </code> field if you know users are likely to search for titles, or if <code class="leafygreen-ui-1l06pbn"> title </code> contains more relevant search terms compared to other document fields. </p> <p class="leafygreen-ui-1kp3ins"> The default weight for indexed is 1 for the indexed fields. To adjust the weights for the indexed fields, include the weights option in the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/db.collection.createIndex/#mongodb-method-db.collection.createIndex"> <code class="leafygreen-ui-1l06pbn"> db.collection.createIndex() </code> </a> method, as seen in this example: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.&lt;collection&gt;.createIndex(\n {\n &lt;field1&gt;: \"text\",\n &lt;field2&gt;: \"text\",\n ...\n },\n {\n weights: {\n &lt;field1&gt;: &lt;weight&gt;,\n &lt;field2&gt;: &lt;weight&gt;,\n ...\n },\n name: &lt;indexname&gt;\n }\n )","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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.<!-- -->&lt;<!-- -->collection<!-- -->&gt;<!-- -->.<span class="lg-highlight-title lg-highlight-function">createIndex</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> &lt;<!-- -->field1<!-- -->&gt;<!-- -->: <span class="lg-highlight-string">"text"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> &lt;<!-- -->field2<!-- -->&gt;<!-- -->: <span class="lg-highlight-string">"text"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->...</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class="leafygreen-ui-1wr1lm6"><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">weights</span>: <!-- -->{</td></tr><tr class="leafygreen-ui-1wr1lm6"><td class="leafygreen-ui-7razhx"> &lt;<!-- -->field1<!-- -->&gt;<!-- -->: &lt;<!-- -->weight<!-- -->&gt;<!-- -->,</td></tr><tr class="leafygreen-ui-1wr1lm6"><td class="leafygreen-ui-7razhx"> <!-- -->&lt;<!-- -->field2<!-- -->&gt;<!-- -->: &lt;<!-- -->weight<!-- -->&gt;<!-- -->,</td></tr><tr class="leafygreen-ui-1wr1lm6"><td class="leafygreen-ui-7razhx"> <!-- -->...</td></tr><tr class="leafygreen-ui-1wr1lm6"><td class="leafygreen-ui-7razhx"> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">name</span>: &lt;<!-- -->indexName<!-- -->&gt;</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->}</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> )</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-85da11" role="note"> <h2 class="leafygreen-ui-1ac4g5h"> Important </h2> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> If you change the weights in your index after it is created, MongoDB needs to reindex the collection. Reindexing can negatively impact performance, especially on large collections. For more information, see <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/index-creation/#std-label-index-creation-background"> Index Builds on Populated Collections <!-- --> . </a> </p> </div> </div> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> About this Task <a class="headerlink leafygreen-ui-1kepx47" href="#about-this-task" 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="about-this-task"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> You have a <code class="leafygreen-ui-1l06pbn"> blog </code> collection that contains documents for individual blog posts. Each document contains: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> The content of the post. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> The topic that the post covers. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> A list of keywords related to the post. </p> </li> </ul> <p class="leafygreen-ui-1kp3ins"> You want to create a text index so users can perform text searches on blog posts. Your application supports searches on content, topics, and keywords. </p> <p class="leafygreen-ui-1kp3ins"> You want to prioritize matches on the <code class="leafygreen-ui-1l06pbn"> content </code> field over other document fields. Use index weights to assign greater importance to matches on <code class="leafygreen-ui-1l06pbn"> content </code> and sort query results so <code class="leafygreen-ui-1l06pbn"> content </code> matches appear first. </p> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Before You Begin <a class="headerlink leafygreen-ui-1kepx47" href="#before-you-begin" 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="before-you-begin"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> Create a <code class="leafygreen-ui-1l06pbn"> blog </code> collection with the following documents: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.blog.insertMany( [\n {\n _id: 1,\n content: \"This morning I had a cup of coffee.\",\n about: \"beverage\",\n keywords: [ \"coffee\" ]\n },\n {\n _id: 2,\n content: \"Who likes chocolate ice cream for dessert?\",\n about: \"food\",\n keywords: [ \"poll\" ]\n },\n {\n _id: 3,\n content: \"My favorite flavors are strawberry and coffee\",\n about: \"ice cream\",\n keywords: [ \"food\", \"dessert\" ]\n }\n] )","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><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">blog</span>.<span class="lg-highlight-title lg-highlight-function">insertMany</span>( <!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">1</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">content</span>: <span class="lg-highlight-string">"This morning I had a cup of coffee."</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">about</span>: <span class="lg-highlight-string">"beverage"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">keywords</span>: <!-- -->[ <span class="lg-highlight-string">"coffee"</span> ]</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">2</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">content</span>: <span class="lg-highlight-string">"Who likes chocolate ice cream for dessert?"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">about</span>: <span class="lg-highlight-string">"food"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">keywords</span>: <!-- -->[ <span class="lg-highlight-string">"poll"</span> ]</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">3</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">content</span>: <span class="lg-highlight-string">"My favorite flavors are strawberry and coffee"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">about</span>: <span class="lg-highlight-string">"ice cream"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">keywords</span>: <!-- -->[ <span class="lg-highlight-string">"food"</span>, <span class="lg-highlight-string">"dessert"</span> ]</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">] )</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> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Procedure <a class="headerlink leafygreen-ui-1kepx47" href="#procedure" 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="procedure"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> Create a <code class="leafygreen-ui-1l06pbn"> text </code> index with different weights for each indexed field: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.blog.createIndex(\n {\n content: \"text\",\n keywords: \"text\",\n about: \"text\"\n },\n {\n weights: {\n content: 10,\n keywords: 5\n },\n name: \"BlogTextIndex\"\n }\n )","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">blog</span>.<span class="lg-highlight-title lg-highlight-function">createIndex</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">content</span>: <span class="lg-highlight-string">"text"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">keywords</span>: <span class="lg-highlight-string">"text"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">about</span>: <span class="lg-highlight-string">"text"</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">weights</span>: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">content</span>: <span class="lg-highlight-number">10</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">keywords</span>: <span class="lg-highlight-number">5</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">name</span>: <span class="lg-highlight-string">"BlogTextIndex"</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> )</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 <code class="leafygreen-ui-1l06pbn"> text </code> index has the following fields and weights: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <code class="leafygreen-ui-1l06pbn"> content </code> has a weight of 10. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <code class="leafygreen-ui-1l06pbn"> keywords </code> has a weight of 5. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <code class="leafygreen-ui-1l06pbn"> about </code> has the default weight of 1. </p> </li> </ul> <p class="leafygreen-ui-1kp3ins"> These weights indicate the relative significance of the indexed fields to each other. </p> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Results <a class="headerlink leafygreen-ui-1kepx47" href="#results" 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="results"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> The following examples show how different weights for indexed fields affect result scores. Each example sorts results based on the <code class="leafygreen-ui-1l06pbn"> textScore </code> of each document. To access documents' <code class="leafygreen-ui-1l06pbn"> textScore </code> attributes, use the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/meta/#mongodb-expression-exp.-meta"> <code class="leafygreen-ui-1l06pbn"> $meta </code> </a> operator. </p> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Matches in <code class="leafygreen-ui-1l06pbn"> content </code> and <code class="leafygreen-ui-1l06pbn"> about </code> Fields <a class="headerlink leafygreen-ui-1kepx47" href="#matches-in-content-and-about-fields" 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="matches-in-content-and-about-fields"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> The following query searches documents in the <code class="leafygreen-ui-1l06pbn"> blog </code> collection for the string <code class="leafygreen-ui-1l06pbn"> ice cream </code> : </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.blog.find(\n {\n $text: { $search: \"ice cream\" }\n },\n {\n score: { $meta: \"textScore\" }\n }\n).sort( { score: { $meta: \"textScore\" } } )","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">blog</span>.<span class="lg-highlight-title lg-highlight-function">find</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">$text</span>: <!-- -->{ <span class="lg-highlight-attr">$search</span>: <span class="lg-highlight-string">"ice cream"</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">score</span>: <!-- -->{ <span class="lg-highlight-attr">$meta</span>: <span class="lg-highlight-string">"textScore"</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">).<span class="lg-highlight-title lg-highlight-function">sort</span>( <!-- -->{ <span class="lg-highlight-attr">score</span>: <!-- -->{ <span class="lg-highlight-attr">$meta</span>: <span class="lg-highlight-string">"textScore"</span> } } )</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"> Output: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"[\n {\n _id: 2,\n content: 'Who likes chocolate ice cream for dessert?',\n about: 'food',\n keywords: [ 'food', 'poll' ],\n score: 12\n },\n {\n _id: 3,\n content: 'My favorite flavors are strawberry and coffee',\n about: 'ice cream',\n keywords: [ 'food', 'dessert' ],\n score: 1.5\n }\n]","programmingLanguage":"JavaScript"} </script> <div class="css-1lju8ps"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1jheeh3"> <pre class="leafygreen-ui-1453az5" 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">[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">2</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">content</span>: <span class="lg-highlight-string">'Who likes chocolate ice cream for dessert?'</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">about</span>: <span class="lg-highlight-string">'food'</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">keywords</span>: <!-- -->[ <span class="lg-highlight-string">'food'</span>, <span class="lg-highlight-string">'poll'</span> ]<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">score</span>: <span class="lg-highlight-number">12</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">3</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">content</span>: <span class="lg-highlight-string">'My favorite flavors are strawberry and coffee'</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">about</span>: <span class="lg-highlight-string">'ice cream'</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">keywords</span>: <!-- -->[ <span class="lg-highlight-string">'food'</span>, <span class="lg-highlight-string">'dessert'</span> ]<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">score</span>: <span class="lg-highlight-number">1.5</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">]</td></tr></tbody></table></code></pre> </div> </div> </div> <p class="leafygreen-ui-1kp3ins"> The search string <code class="leafygreen-ui-1l06pbn"> ice cream </code> matches: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> The <code class="leafygreen-ui-1l06pbn"> content </code> field in the document with <code class="leafygreen-ui-1l06pbn"> _id: 2 </code> . </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> The <code class="leafygreen-ui-1l06pbn"> about </code> field in the document with <code class="leafygreen-ui-1l06pbn"> _id: 3 </code> . </p> </li> </ul> <p class="leafygreen-ui-1kp3ins"> A term match in the <code class="leafygreen-ui-1l06pbn"> content </code> field has <code class="leafygreen-ui-1l06pbn"> 10 </code> times the impact ( <code class="leafygreen-ui-1l06pbn"> 10:1 </code> weight) as a term match in the <code class="leafygreen-ui-1l06pbn"> keywords </code> field. </p> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Matches in <code class="leafygreen-ui-1l06pbn"> keywords </code> and <code class="leafygreen-ui-1l06pbn"> about </code> Fields <a class="headerlink leafygreen-ui-1kepx47" href="#matches-in-keywords-and-about-fields" 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="matches-in-keywords-and-about-fields"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> The following query searches documents in the <code class="leafygreen-ui-1l06pbn"> blog </code> collection for the string <code class="leafygreen-ui-1l06pbn"> food </code> : </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.blog.find(\n {\n $text: { $search: \"food\" }\n },\n {\n score: { $meta: \"textScore\" }\n }\n).sort( { score: { $meta: \"textScore\" } } )","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">blog</span>.<span class="lg-highlight-title lg-highlight-function">find</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">$text</span>: <!-- -->{ <span class="lg-highlight-attr">$search</span>: <span class="lg-highlight-string">"food"</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">score</span>: <!-- -->{ <span class="lg-highlight-attr">$meta</span>: <span class="lg-highlight-string">"textScore"</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">).<span class="lg-highlight-title lg-highlight-function">sort</span>( <!-- -->{ <span class="lg-highlight-attr">score</span>: <!-- -->{ <span class="lg-highlight-attr">$meta</span>: <span class="lg-highlight-string">"textScore"</span> } } )</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"> Output: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"[\n {\n _id: 3,\n content: 'My favorite flavors are strawberry and coffee',\n about: 'ice cream',\n keywords: [ 'food', 'dessert' ],\n score: 5.5\n },\n {\n _id: 2,\n content: \"Who likes chocolate ice cream for dessert?\",\n about: 'food',\n keywords: [ 'poll' ],\n score: 1.1\n }\n]","programmingLanguage":"JavaScript"} </script> <div class="css-1lju8ps"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1jheeh3"> <pre class="leafygreen-ui-1453az5" 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">[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">3</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">content</span>: <span class="lg-highlight-string">'My favorite flavors are strawberry and coffee'</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">about</span>: <span class="lg-highlight-string">'ice cream'</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">keywords</span>: <!-- -->[ <span class="lg-highlight-string">'food'</span>, <span class="lg-highlight-string">'dessert'</span> ]<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">score</span>: <span class="lg-highlight-number">5.5</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">2</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">content</span>: <span class="lg-highlight-string">"Who likes chocolate ice cream for dessert?"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">about</span>: <span class="lg-highlight-string">'food'</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">keywords</span>: <!-- -->[ <span class="lg-highlight-string">'poll'</span> ]<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">score</span>: <span class="lg-highlight-number">1.1</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">]</td></tr></tbody></table></code></pre> </div> </div> </div> <p class="leafygreen-ui-1kp3ins"> The search string <code class="leafygreen-ui-1l06pbn"> food </code> matches: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> The <code class="leafygreen-ui-1l06pbn"> keywords </code> field in the document with <code class="leafygreen-ui-1l06pbn"> _id: 3 </code> . </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> The <code class="leafygreen-ui-1l06pbn"> about </code> field in the document with <code class="leafygreen-ui-1l06pbn"> _id: 2 </code> . </p> </li> </ul> <p class="leafygreen-ui-1kp3ins"> A term match in the <code class="leafygreen-ui-1l06pbn"> keywords </code> field has <code class="leafygreen-ui-1l06pbn"> 5 </code> times the impact ( <code class="leafygreen-ui-1l06pbn"> 5:1 </code> weight) as a term match in the <code class="leafygreen-ui-1l06pbn"> about </code> field. </p> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Multiple Matches in a Single Document <a class="headerlink leafygreen-ui-1kepx47" href="#multiple-matches-in-a-single-document" 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="multiple-matches-in-a-single-document"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> The following query searches documents in the <code class="leafygreen-ui-1l06pbn"> blog </code> collection for the string <code class="leafygreen-ui-1l06pbn"> coffee </code> : </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.blog.find(\n {\n $text: { $search: \"coffee\" }\n },\n {\n score: { $meta: \"textScore\" }\n }\n).sort( { score: { $meta: \"textScore\" } } )","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">blog</span>.<span class="lg-highlight-title lg-highlight-function">find</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">$text</span>: <!-- -->{ <span class="lg-highlight-attr">$search</span>: <span class="lg-highlight-string">"coffee"</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">score</span>: <!-- -->{ <span class="lg-highlight-attr">$meta</span>: <span class="lg-highlight-string">"textScore"</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">).<span class="lg-highlight-title lg-highlight-function">sort</span>( <!-- -->{ <span class="lg-highlight-attr">score</span>: <!-- -->{ <span class="lg-highlight-attr">$meta</span>: <span class="lg-highlight-string">"textScore"</span> } } )</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"> Output: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"[\n {\n _id: 1,\n content: 'This morning I had a cup of coffee.',\n about: 'beverage',\n keywords: [ 'coffee' ],\n score: 11.666666666666666\n },\n {\n _id: 3,\n content: 'My favorite cake flavors are strawberry and coffee',\n about: 'ice cream',\n keywords: [ 'food', 'dessert' ],\n score: 6\n }\n]","programmingLanguage":"JavaScript"} </script> <div class="css-1lju8ps"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-tyg50d"> <pre class="leafygreen-ui-1453az5" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">1</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">content</span>: <span class="lg-highlight-string">'This morning I had a cup of coffee.'</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">about</span>: <span class="lg-highlight-string">'beverage'</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">keywords</span>: <!-- -->[ <span class="lg-highlight-string">'coffee'</span> ]<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">score</span>: <span class="lg-highlight-number">11.666666666666666</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">3</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">content</span>: <span class="lg-highlight-string">'My favorite cake flavors are strawberry and coffee'</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">about</span>: <span class="lg-highlight-string">'ice cream'</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">keywords</span>: <!-- -->[ <span class="lg-highlight-string">'food'</span>, <span class="lg-highlight-string">'dessert'</span> ]<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">score</span>: <span class="lg-highlight-number">6</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">]</td></tr></tbody></table></code></pre> </div> </div> </div> <p class="leafygreen-ui-1kp3ins"> The search string <code class="leafygreen-ui-1l06pbn"> coffee </code> matches: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> The <code class="leafygreen-ui-1l06pbn"> content </code> and <code class="leafygreen-ui-1l06pbn"> keywords </code> fields in the document with <code class="leafygreen-ui-1l06pbn"> _id: 1 </code> . </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> The <code class="leafygreen-ui-1l06pbn"> content </code> field in the document with <code class="leafygreen-ui-1l06pbn"> _id: 3 </code> . </p> </li> </ul> <p class="leafygreen-ui-1kp3ins"> To calculate the <code class="leafygreen-ui-1l06pbn"> score </code> when a search string matches multiple fields, MongoDB multiplies the number of matches by the weight for the corresponding field and sums the results. </p> </section> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Learn More <a class="headerlink leafygreen-ui-1kepx47" href="#learn-more" 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="learn-more"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> To learn more about text search in MongoDB, see: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/link-text-indexes/#std-label-perform-text-search-onprem"> Perform a Text Search (Self-Managed Deployments) </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/text-search-operators/#std-label-text-search-operators-onprem"> Text Search Operators (Self-Managed Deployments) </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/text-search-languages/#std-label-text-search-languages"> Text Search Languages on Self-Managed Deployments </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/meta/#mongodb-expression-exp.-meta"> <code class="leafygreen-ui-1l06pbn"> $meta </code> </a> </p> </li> </ul> <div class="leafygreen-ui-15mdk4" role="note"> <h2 class="leafygreen-ui-6n7b7d"> Note </h2> <h3 class="leafygreen-ui-144d5kf"> <strong> Atlas Search </strong> </h3> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> For data hosted on MongoDB Atlas, <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/atlas/atlas-search/" target="_self"> <span> Atlas Search </span> </a> provides more robust custom scoring than <code class="leafygreen-ui-1l06pbn"> text </code> indexes. To learn more, see the Atlas Search <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/atlas/reference/atlas-search/scoring/" target="_self"> <span> Scoring </span> </a> documentation. </p> </div> </div> </section> </section>
https://www.mongodb.com/docs/manual/tutorial/create-a-vulnerability-report/
<section> <h1 class="contains-headerlink leafygreen-ui-41fr9s" weight="medium"> Create a Vulnerability Report <a class="headerlink leafygreen-ui-1kepx47" href="#create-a-vulnerability-report" 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="create-a-vulnerability-report"> </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="#evaluation-of-a-vulnerability-report" target="_self"> <span> Evaluation of a Vulnerability Report </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#disclosure" target="_self"> <span> Disclosure </span> </a> </li> </ul> </div> <p class="leafygreen-ui-1kp3ins"> If you believe you have discovered a vulnerability in MongoDB products or have experienced a security incident related to MongoDB products, please report the issue to aid in its resolution. For more information on vulnerability reports, see the following resources: </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/security" target="_self"> <span> MongoDB Security information </span> </a> on our website </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/bug-submission-form" target="_self"> <span> Webform </span> </a> for vulnerability report submission </p> </li> </ul> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Evaluation of a Vulnerability Report <a class="headerlink leafygreen-ui-1kepx47" href="#evaluation-of-a-vulnerability-report" 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="evaluation-of-a-vulnerability-report"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> MongoDB, Inc. validates all submitted vulnerabilities through internal investigation. If needed, MongoDB representatives will reach out to the reporter for further information and to provide the results of the investigation. Please allow MongoDB representatives up to one week to acknowledge submissions. </p> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Disclosure <a class="headerlink leafygreen-ui-1kepx47" href="#disclosure" 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="disclosure"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> MongoDB, Inc. requests that you do <em> not </em> publicly disclose any information regarding the vulnerability or exploit the issue until it has had the opportunity to analyze the vulnerability, to respond to the notification, and to notify key users, customers, and partners. </p> <p class="leafygreen-ui-1kp3ins"> The amount of time required to validate a reported vulnerability depends on the complexity and severity of the issue. MongoDB, Inc. takes all required vulnerabilities very seriously and will always ensure that there is a clear and open channel of communication with the reporter. </p> <p class="leafygreen-ui-1kp3ins"> After validating an issue, MongoDB, Inc. coordinates public disclosure of the issue with the reporter in a mutually agreed timeframe and format. If required or requested, the reporter of a vulnerability will receive credit in the published security bulletin. </p> </section> </section>
https://www.mongodb.com/docs/manual/reference/connection-string/
<section> <h1 class="contains-headerlink leafygreen-ui-41fr9s" weight="medium"> Connection Strings <a class="headerlink leafygreen-ui-1kepx47" href="#connection-strings" 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="connection-strings"> </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="#find-your-mongodb-atlas-connection-string" target="_self"> <span> Find Your MongoDB Atlas Connection String </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#find-your-self-hosted-deployment-s-connection-string" target="_self"> <span> Find Your Self-Hosted Deployment's Connection String </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#connection-string-formats" target="_self"> <span> Connection String Formats </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-x9koo9" href="#srv-connection-format" target="_self"> <span> SRV Connection Format </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-x9koo9" href="#standard-connection-string-format" target="_self"> <span> Standard Connection String Format </span> </a> </li> </ul> </div> <hr class="css-1unva0n e4ru7ww0"/> <p class="leafygreen-ui-1kp3ins"> ➤ <!-- --> Use the <strong> Select your language </strong> drop-down menu in the upper-right to set the language of the following examples. </p> <hr class="css-1unva0n e4ru7ww0"/> <p class="leafygreen-ui-1kp3ins"> You can use connection strings to define connections between MongoDB instances and the following destinations: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Your applications when you connect using <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/drivers/" target="_self"> <span> drivers <!-- --> . </span> </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Tools such as <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/compass/current/" target="_self"> <span> MongoDB Compass </span> </a> and <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/mongodb-shell/" target="_self"> <span> the MongoDB Shell (mongosh) <!-- --> . </span> </a> </p> </li> </ul> <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 connection strings to connect to <!-- --> 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> <span class="leafygreen-ui-1qnjd6d" id="std-label-find-connection-string"> </span> <p class="leafygreen-ui-1kp3ins"> Complete these steps to find your connection string. </p> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Find Your MongoDB Atlas Connection String <a class="headerlink leafygreen-ui-1kepx47" href="#find-your-mongodb-atlas-connection-string" 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="find-your-mongodb-atlas-connection-string"> </div> </a> </h2> <div aria-hidden="true"> </div> <div class="leafygreen-ui-1b75luy" data-lgid="lg-tabs"> <div class="leafygreen-ui-jp7pox" id="tabs-10"> <div aria-label="Tabs to describe usage of atlas-cli/atlas-ui" aria-orientation="horizontal" class="leafygreen-ui-m8p1vb lg-ui-tab-list-0000" data-lgid="lg-tabs-tab_list" role="tablist"> <button aria-controls="_94cmiila9" aria-selected="true" class="leafygreen-ui-1l773z1" data-text="" id="_vffe0tsur" name="" role="tab" tabindex="0"> <div class="leafygreen-ui-1nxuzmg"> Atlas CLI </div> </button> <button aria-controls="_4gjjhlm6n" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_7b4i2mn0n" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Atlas UI </div> </button> </div> <div class="leafygreen-ui-ov1ktg"> <div class="leafygreen-ui-1sg2lsz"> </div> </div> </div> <div class="lg-ui-tab-panels-0000" data-lgid="lg-tabs-tab_panels"> <div> <div aria-labelledby="_r897hk369" class="" id="_3rqg76tyv" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <p class="leafygreen-ui-1kp3ins"> To find your MongoDB Atlas connection string using the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/atlas/cli/stable/" target="_self"> <span> Atlas CLI </span> </a> , <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/atlas/cli/stable/install-atlas-cli/" target="_self"> <span> install </span> </a> and <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/atlas/cli/stable/connect-atlas-cli/" target="_self"> <span> connect </span> </a> from the Atlas CLI, then run the following command. Replace <code class="leafygreen-ui-1l06pbn"> &lt;clusterName&gt; </code> with the name of the MongoDB Atlas cluster and replace <code class="leafygreen-ui-1l06pbn"> &lt;projectId&gt; </code> with the project ID. </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"atlas clusters connectionStrings describe &lt;clustername&gt; --projectId &lt;projectid&gt;"} </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 none leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">atlas clusters connectionStrings describe &lt;clusterName&gt; --projectId &lt;projectId&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"> To learn more, see <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/atlas/cli/stable/command/atlas-clusters-connectionStrings-describe/" target="_self"> <span> atlas clusters connectionStrings describe <!-- --> . </span> </a> </p> </div> </div> </div> <div> <div aria-labelledby="_a1ayvefr4" class="leafygreen-ui-38lglc" id="_aqiuve8c0" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <p class="leafygreen-ui-1kp3ins"> To find your MongoDB Atlas connection string in the Atlas UI, follow these steps: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"HowTo","steps":[{"@type":"HowToStep","text":"If it's not already displayed, select the organization that\ncontains your desired project from the Organizations menu in the\nnavigation bar.If it's not already displayed, select your project\nfrom the Projects menu in the navigation bar.If it's not already displayed, click Clusters in the\nsidebar.The Clusters page displays.","name":"In the MongoDB Atlas UI, go to the Clusters page for your project."},{"@type":"HowToStep","text":"Click Connect for the cluster to which\nyou want to connect.Click Choose a Connection Method. MongoDB Atlas\nselects Standard Connection by default. To\nconnect using a private endpoint, select\nPrivate Endpoint.","name":"Open the Connection Method dialog."},{"@type":"HowToStep","text":"To connect to your application, click Drivers. To\nconnect using tools, click the tool you want to use to access your\ndata.","name":"Choose a connection method."},{"@type":"HowToStep","text":"If you selected Drivers, select your driver and\nversion. If you selected a tool, download the tool.Select Connect To Cluster.Copy the connection string. Replace <password> and\n<username> in the connection string with the database\nuser's credentials.","name":"Follow instructions for the connection method you selected."}],"name":"Find Your MongoDB Atlas Connection String - Atlas UI","image":"https://webimages.mongodb.com/_com_assets/cms/kuyj2focmkbxv7gh3-stacked_default_slate_blue.svg?auto=format%252Ccompress"} </script> <div class="css-4nyere eccljxs0"> <div class="css-1nuklj8 e1ckbxcu1"> <div class="css-18fui5z e1ckbxcu0"> <div class="css-19lsqsq e1ckbxcu2"> 1 </div> </div> <div class="css-1ed38mk"> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> In the MongoDB Atlas UI, go to the <span class="guilabel css-h15tq0"> Clusters </span> page for your project. <a class="headerlink leafygreen-ui-1kepx47" href="#in-the-mongodb-atlas-ui--go-to-the-clusters-page-for-your-project." 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="in-the-mongodb-atlas-ui--go-to-the-clusters-page-for-your-project."> </div> </a> </h3> <ol class="leafygreen-ui-rioki0" type="a"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> If it's not already displayed, select the organization that contains your desired project from the <i class="mms-icon-office mms-icon"> </i> <span class="guilabel css-h15tq0"> Organizations </span> menu <!-- --> in the navigation bar. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> If it's not already displayed, select your project from the <span class="guilabel css-h15tq0"> Projects </span> menu in the navigation bar. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> If it's not already displayed, click <span class="guilabel css-h15tq0"> Clusters </span> in the sidebar. </p> <p class="leafygreen-ui-1kp3ins"> The <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://cloud.mongodb.com/go?l=https%3A%2F%2Fcloud.mongodb.com%2Fv2%2F%3Cproject%3E%23%2Fclusters" target="_self"> <span> Clusters </span> </a> page displays. </p> </li> </ol> </section> </div> </div> <div class="css-1nuklj8 e1ckbxcu1"> <div class="css-18fui5z e1ckbxcu0"> <div class="css-19lsqsq e1ckbxcu2"> 2 </div> </div> <div class="css-1ed38mk"> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Open the <span class="guilabel css-h15tq0"> Connection Method </span> dialog. <a class="headerlink leafygreen-ui-1kepx47" href="#open-the-connection-method-dialog." 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="open-the-connection-method-dialog."> </div> </a> </h3> <ol class="leafygreen-ui-rioki0" type="a"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Click <span class="guilabel css-h15tq0"> Connect </span> for the cluster to which you want to connect. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Click <span class="guilabel css-h15tq0"> Choose a Connection Method </span> . MongoDB Atlas selects <span class="guilabel css-h15tq0"> Standard Connection </span> by default. To connect using a <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/atlas/security-private-endpoint/" target="_self"> <span> private endpoint </span> </a> , select <span class="guilabel css-h15tq0"> Private Endpoint </span> . </p> </li> </ol> </section> </div> </div> <div class="css-1nuklj8 e1ckbxcu1"> <div class="css-18fui5z e1ckbxcu0"> <div class="css-19lsqsq e1ckbxcu2"> 3 </div> </div> <div class="css-1ed38mk"> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Choose a connection method. <a class="headerlink leafygreen-ui-1kepx47" href="#choose-a-connection-method." 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="choose-a-connection-method."> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> To connect to your application, click <span class="guilabel css-h15tq0"> Drivers </span> . To connect using tools, click the tool you want to use to access your data. </p> </section> </div> </div> <div class="css-1nuklj8 e1ckbxcu1"> <div class="css-18fui5z e1ckbxcu0"> <div class="css-19lsqsq e1ckbxcu2"> 4 </div> </div> <div class="css-1ed38mk"> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Follow instructions for the connection method you selected. <a class="headerlink leafygreen-ui-1kepx47" href="#follow-instructions-for-the-connection-method-you-selected." 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="follow-instructions-for-the-connection-method-you-selected."> </div> </a> </h3> <ol class="leafygreen-ui-rioki0" type="a"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> If you selected <span class="guilabel css-h15tq0"> Drivers </span> , select your driver and version. If you selected a tool, download the tool. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Select <span class="guilabel css-h15tq0"> Connect To Cluster </span> . </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Copy the connection string. Replace <code class="leafygreen-ui-1l06pbn"> &lt;password&gt; </code> and <code class="leafygreen-ui-1l06pbn"> &lt;username&gt; </code> in the connection string with the database user's credentials. </p> </li> </ol> </section> </div> </div> </div> </div> </div> </div> </div> </div> <p class="leafygreen-ui-1kp3ins"> Your MongoDB Atlas connection string resembles the following example: </p> <div aria-hidden="true"> </div> <div class="leafygreen-ui-f2qztv" data-lgid="lg-tabs"> <div class="leafygreen-ui-jp7pox" id="tabs-11"> <div aria-label="Tabs to describe usage of drivers" aria-orientation="horizontal" class="leafygreen-ui-m8p1vb lg-ui-tab-list-0000" data-lgid="lg-tabs-tab_list" role="tablist"> <button aria-controls="_remc561wi" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_f7z7fv8tc" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> MongoDB Shell </div> </button> <button aria-controls="_55pmof99i" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_lfk3jvzz0" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Compass </div> </button> <button aria-controls="_k9jmw13or" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_v0tjpxs5s" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> C# </div> </button> <button aria-controls="_yz48y4iyv" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_si8v05jjt" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Go </div> </button> <button aria-controls="_kmeoslbn4" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_btogvo9ea" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Java (Async) </div> </button> <button aria-controls="_j51vzffyu" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_iypcy420p" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Java (Sync) </div> </button> <button aria-controls="_wnbvehk1s" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_m3n59y4gi" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Motor </div> </button> <button aria-controls="_xg3i69q0a" aria-selected="true" class="leafygreen-ui-1l773z1" data-text="" id="_phzqzqvfo" name="" role="tab" tabindex="0"> <div class="leafygreen-ui-1nxuzmg"> Node.js </div> </button> <button aria-controls="_plj8z2d2t" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_zqgrmpsw0" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Perl </div> </button> <button aria-controls="_od3ua8l3q" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_hmv4ubmko" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> PHP </div> </button> <button aria-controls="_ngqliysrj" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_twtghfucm" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Python </div> </button> <button aria-controls="_8fjnqmqib" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_nxix4ausj" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Ruby </div> </button> <button aria-controls="_ulsxshtc7" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_kjae82jfb" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Rust </div> </button> <button aria-controls="_1kpra9cqt" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_mlgfdd9vm" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Scala </div> </button> </div> <div class="leafygreen-ui-ov1ktg"> <div class="leafygreen-ui-1sg2lsz"> </div> </div> </div> <div class="lg-ui-tab-panels-0000" data-lgid="lg-tabs-tab_panels"> <div> <div aria-labelledby="_uqgx29usx" class="leafygreen-ui-38lglc" id="_ipmyf2t6s" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"mongosh \"mongodb+srv://cluster0.example.mongodb.net myFirstDatabase\" --apiVersion 1 --username myDatabaseUser","programmingLanguage":"Bash"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <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">mongosh <span class="lg-highlight-string">"mongodb+srv://cluster0.example.mongodb.net myFirstDatabase"</span> --apiVersion <span class="lg-highlight-number">1</span> --username myDatabaseUser</td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-28-menu" aria-describedby="select-28-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-29" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:rii:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":rii:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rii:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rii:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_vp3ilpvvk" class="leafygreen-ui-38lglc" id="_hfvz2le9m" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"mongodb+srv://myDatabaseUser:D1fficultP%[email protected]/","programmingLanguage":"Bash"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <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">mongodb<!-- -->+<!-- --><span class="lg-highlight-attr">srv</span>:<span class="lg-highlight-comment">//myDatabaseUser:D1fficultP%[email protected]/</span></td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-31-menu" aria-describedby="select-31-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-32" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:rij:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":rij:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rij:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rij:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_98oo6vshp" class="leafygreen-ui-38lglc" id="_xc32m4g27" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"mongodb+srv://myDatabaseUser:D1fficultP%[email protected]/","programmingLanguage":"Bash"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <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">mongodb<!-- -->+<!-- --><span class="lg-highlight-attr">srv</span>:<span class="lg-highlight-comment">//myDatabaseUser:D1fficultP%[email protected]/</span></td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-34-menu" aria-describedby="select-34-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-35" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:rik:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":rik:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rik:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rik:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_nums3fd4o" class="leafygreen-ui-38lglc" id="_b7uu3p206" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"mongodb+srv://myDatabaseUser:D1fficultP%[email protected]/","programmingLanguage":"Bash"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <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">mongodb<!-- -->+<!-- --><span class="lg-highlight-attr">srv</span>:<span class="lg-highlight-comment">//myDatabaseUser:D1fficultP%[email protected]/</span></td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-37-menu" aria-describedby="select-37-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-38" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:ril:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":ril:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":ril:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":ril:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_qb9f3r3yb" class="leafygreen-ui-38lglc" id="_0ls3kf8tg" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"mongodb+srv://myDatabaseUser:D1fficultP%[email protected]/?retryWrites=true&amp;w=majority","programmingLanguage":"Bash"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <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">mongodb<!-- -->+<!-- --><span class="lg-highlight-attr">srv</span>:<span class="lg-highlight-comment">//myDatabaseUser:D1fficultP%[email protected]/?retryWrites=true&amp;w=majority</span></td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-40-menu" aria-describedby="select-40-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-41" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:rim:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":rim:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rim:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rim:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_0gj7kxoob" class="leafygreen-ui-38lglc" id="_3f2gcvkgc" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"mongodb+srv://myDatabaseUser:D1fficultP%[email protected]/?retryWrites=true&amp;w=majority","programmingLanguage":"Bash"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <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">mongodb<!-- -->+<!-- --><span class="lg-highlight-attr">srv</span>:<span class="lg-highlight-comment">//myDatabaseUser:D1fficultP%[email protected]/?retryWrites=true&amp;w=majority</span></td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-43-menu" aria-describedby="select-43-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-44" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:rin:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":rin:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rin:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rin:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_8x28t7t6m" class="leafygreen-ui-38lglc" id="_k1w8xheh5" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"mongodb+srv://myDatabaseUser:D1fficultP%[email protected]/","programmingLanguage":"Bash"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <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">mongodb<!-- -->+<!-- --><span class="lg-highlight-attr">srv</span>:<span class="lg-highlight-comment">//myDatabaseUser:D1fficultP%[email protected]/</span></td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-46-menu" aria-describedby="select-46-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-47" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:rio:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":rio:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rio:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rio:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_14o7hqoya" class="" id="_2q80ogj8a" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"mongodb+srv://myDatabaseUser:D1fficultP%[email protected]/?retryWrites=true&amp;w=majority","programmingLanguage":"Bash"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <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">mongodb<!-- -->+<!-- --><span class="lg-highlight-attr">srv</span>:<span class="lg-highlight-comment">//myDatabaseUser:D1fficultP%[email protected]/?retryWrites=true&amp;w=majority</span></td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-49-menu" aria-describedby="select-49-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-50" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:rip:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":rip:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rip:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rip:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_48slry9s6" class="leafygreen-ui-38lglc" id="_ge0if83ur" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"mongodb+srv://myDatabaseUser:D1fficultP%[email protected]/?retryWrites=true&amp;w=majority","programmingLanguage":"Bash"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <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">mongodb<!-- -->+<!-- --><span class="lg-highlight-attr">srv</span>:<span class="lg-highlight-comment">//myDatabaseUser:D1fficultP%[email protected]/?retryWrites=true&amp;w=majority</span></td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-52-menu" aria-describedby="select-52-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-53" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:riq:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":riq:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":riq:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":riq:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_mpqw2fdlz" class="leafygreen-ui-38lglc" id="_n3e7tr8bq" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"mongodb+srv://myDatabaseUser:D1fficultP%[email protected]/?retryWrites=true&amp;w=majority","programmingLanguage":"Bash"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <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">mongodb<!-- -->+<!-- --><span class="lg-highlight-attr">srv</span>:<span class="lg-highlight-comment">//myDatabaseUser:D1fficultP%[email protected]/?retryWrites=true&amp;w=majority</span></td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-55-menu" aria-describedby="select-55-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-56" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:rir:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":rir:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rir:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rir:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_f6frwrj7s" class="leafygreen-ui-38lglc" id="_xhpooa771" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"mongodb+srv://myDatabaseUser:D1fficultP%[email protected]/?retryWrites=true&amp;w=majority","programmingLanguage":"Bash"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <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">mongodb<!-- -->+<!-- --><span class="lg-highlight-attr">srv</span>:<span class="lg-highlight-comment">//myDatabaseUser:D1fficultP%[email protected]/?retryWrites=true&amp;w=majority</span></td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-58-menu" aria-describedby="select-58-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-59" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:ris:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":ris:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":ris:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":ris:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_s6ux1s7c1" class="leafygreen-ui-38lglc" id="_5ippjuso2" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"mongodb+srv://myDatabaseUser:D1fficultP%[email protected]/?retryWrites=true&amp;w=majority","programmingLanguage":"Bash"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <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">mongodb<!-- -->+<!-- --><span class="lg-highlight-attr">srv</span>:<span class="lg-highlight-comment">//myDatabaseUser:D1fficultP%[email protected]/?retryWrites=true&amp;w=majority</span></td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-61-menu" aria-describedby="select-61-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-62" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:rit:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":rit:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rit:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rit:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_xmfhzasq9" class="leafygreen-ui-38lglc" id="_f8kel1tjy" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"mongodb+srv://myDatabaseUser:D1fficultP%[email protected]/","programmingLanguage":"Bash"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <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">mongodb<!-- -->+<!-- --><span class="lg-highlight-attr">srv</span>:<span class="lg-highlight-comment">//myDatabaseUser:D1fficultP%[email protected]/</span></td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-64-menu" aria-describedby="select-64-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-65" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:riu:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":riu:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":riu:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":riu:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_xxvrtsufe" class="leafygreen-ui-38lglc" id="_xx4j5fjbw" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"mongodb+srv://myDatabaseUser:D1fficultP%[email protected]/?retryWrites=true&amp;w=majority","programmingLanguage":"Bash"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <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">mongodb<!-- -->+<!-- --><span class="lg-highlight-attr">srv</span>:<span class="lg-highlight-comment">//myDatabaseUser:D1fficultP%[email protected]/?retryWrites=true&amp;w=majority</span></td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-67-menu" aria-describedby="select-67-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-68" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:riv:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":riv:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":riv:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":riv:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> </div> </div> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Find Your Self-Hosted Deployment's Connection String <a class="headerlink leafygreen-ui-1kepx47" href="#find-your-self-hosted-deployment-s-connection-string" 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="find-your-self-hosted-deployment-s-connection-string"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> If you are connected to your self-hosted MongoDB Enterprise or MongoDB Community deployment, run <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/db.getMongo/#mongodb-method-db.getMongo"> <code class="leafygreen-ui-1l06pbn"> db.getMongo() </code> </a> method to return the connection string. </p> <p class="leafygreen-ui-1kp3ins"> If you are not connected to your deployment, you can determine your connection string based on the connection type you want to use. See <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-connections-dns-seedlist" target="_self"> <span> SRV Connection Format </span> </a> to learn the SRV connection string syntax or <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-connections-standard-connection-string-format" target="_self"> <span> Standard Connection String Format </span> </a> to learn the standard connection string syntax. </p> <p class="leafygreen-ui-1kp3ins"> Your self-hosted connection string resembles the following examples: </p> <div aria-hidden="true"> </div> <div class="leafygreen-ui-1b75luy" data-lgid="lg-tabs"> <div class="leafygreen-ui-jp7pox" id="tabs-21"> <div aria-label="Tabs to describe usage of srv/standard" aria-orientation="horizontal" class="leafygreen-ui-m8p1vb lg-ui-tab-list-0000" data-lgid="lg-tabs-tab_list" role="tablist"> <button aria-controls="_7ywz0s1xc" aria-selected="true" class="leafygreen-ui-1l773z1" data-text="" id="_sz88g9ygf" name="" role="tab" tabindex="0"> <div class="leafygreen-ui-1nxuzmg"> SRV Connection String </div> </button> <button aria-controls="_k4mhlkugk" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_brgoh16vy" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Standard Connection String </div> </button> </div> <div class="leafygreen-ui-ov1ktg"> <div class="leafygreen-ui-1sg2lsz"> </div> </div> </div> <div class="lg-ui-tab-panels-0000" data-lgid="lg-tabs-tab_panels"> <div> <div aria-labelledby="_u1pgyuvry" class="" id="_oceaoxm0m" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <div aria-hidden="true"> </div> <div class="leafygreen-ui-1b75luy" data-lgid="lg-tabs"> <div class="leafygreen-ui-jp7pox" id="tabs-16"> <div aria-label="Tabs to describe usage of repl/sharded/standalone" aria-orientation="horizontal" class="leafygreen-ui-m8p1vb lg-ui-tab-list-0000" data-lgid="lg-tabs-tab_list" role="tablist"> <button aria-controls="_4sicylg3h" aria-selected="true" class="leafygreen-ui-1l773z1" data-text="" id="_itikfuugj" name="" role="tab" tabindex="0"> <div class="leafygreen-ui-1nxuzmg"> Replica Set </div> </button> <button aria-controls="_qsbcxryce" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_shielg414" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Sharded Cluster </div> </button> <button aria-controls="_p6wqcj34y" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_h3tbe9guo" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Standalone </div> </button> </div> <div class="leafygreen-ui-ov1ktg"> <div class="leafygreen-ui-1sg2lsz"> </div> </div> </div> <div class="lg-ui-tab-panels-0000" data-lgid="lg-tabs-tab_panels"> <div> <div aria-labelledby="_bayg6q5jf" class="" id="_xxpq9lzap" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <p class="leafygreen-ui-1kp3ins"> The following replica set connection string includes these elements: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> The <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/connection-string-options/#mongodb-urioption-urioption.replicaSet"> <code class="leafygreen-ui-1l06pbn"> replicaSet </code> </a> option </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> The hostname(s) of the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> instance(s) as listed in the replica set configuration </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> It authenticates as user <code class="leafygreen-ui-1l06pbn"> myDatabaseUser </code> with the password <code class="leafygreen-ui-1l06pbn"> D1fficultP%40ssw0rd </code> to <a class="leafygreen-ui-tqgtui" href="/docs/manual/tutorial/enable-authentication/#std-label-enable-access-control"> enforce access control </a> </p> </li> </ul> <div aria-hidden="true"> </div> <div class="leafygreen-ui-f2qztv" data-lgid="lg-tabs"> <div class="leafygreen-ui-jp7pox" id="tabs-13"> <div aria-label="Tabs to describe usage of drivers" aria-orientation="horizontal" class="leafygreen-ui-m8p1vb lg-ui-tab-list-0000" data-lgid="lg-tabs-tab_list" role="tablist"> <button aria-controls="_qt2zra0ng" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_ydqlqh8vj" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> MongoDB Shell </div> </button> <button aria-controls="_ra8yyj5pj" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_51dmk1c7e" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Compass </div> </button> <button aria-controls="_xi0hj5m7r" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_iylygcbg7" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> C# </div> </button> <button aria-controls="_xmrydmz4m" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_t20qhcghq" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Go </div> </button> <button aria-controls="_iasgobfm9" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_dpu6hn8vd" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Java (Async) </div> </button> <button aria-controls="_dytzm715r" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_8s4vm8pau" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Java (Sync) </div> </button> <button aria-controls="_dmb6023tx" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_u9fqkga0o" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Motor </div> </button> <button aria-controls="_52yuvpo87" aria-selected="true" class="leafygreen-ui-1l773z1" data-text="" id="_dot82a118" name="" role="tab" tabindex="0"> <div class="leafygreen-ui-1nxuzmg"> Node.js </div> </button> <button aria-controls="_mdiltgx3o" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_yt2bhospb" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Perl </div> </button> <button aria-controls="_da7lsl6t7" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_m3e1gbjfi" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> PHP </div> </button> <button aria-controls="_yvkwd1wgk" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_l40e4kj9k" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Python </div> </button> <button aria-controls="_muwb214mg" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_j71yfpxvx" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Ruby </div> </button> <button aria-controls="_1sh13xvq7" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_ccbucfwzw" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Rust </div> </button> <button aria-controls="_eonopj9u2" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_700krjudu" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Scala </div> </button> </div> <div class="leafygreen-ui-ov1ktg"> <div class="leafygreen-ui-1sg2lsz"> </div> </div> </div> <div class="lg-ui-tab-panels-0000" data-lgid="lg-tabs-tab_panels"> <div> <div aria-labelledby="_1urwbxuv3" class="leafygreen-ui-38lglc" id="_stckgf82y" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"mongosh \"mongodb+srv://mongodb0.example.com/?authSource=admin&amp;replicaSet=myRepl\" --apiVersion 1 --username myDatabaseUser","programmingLanguage":"Bash"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <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">mongosh <span class="lg-highlight-string">"mongodb+srv://mongodb0.example.com/?authSource=admin&amp;replicaSet=myRepl"</span> --apiVersion <span class="lg-highlight-number">1</span> --username myDatabaseUser</td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-70-menu" aria-describedby="select-70-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-71" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:rj0:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":rj0:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rj0:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rj0:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_4ipv9fo44" class="leafygreen-ui-38lglc" id="_0zlyuivxm" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"mongodb+srv://myDatabaseUser:D1fficultP%[email protected]/?authSource=admin&amp;replicaSet=myRepl","programmingLanguage":"Bash"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <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">mongodb<!-- -->+<!-- --><span class="lg-highlight-attr">srv</span>:<span class="lg-highlight-comment">//myDatabaseUser:D1fficultP%[email protected]/?authSource=admin&amp;replicaSet=myRepl</span></td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-73-menu" aria-describedby="select-73-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-74" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:rj1:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":rj1:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rj1:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rj1:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_2lxw5zy8c" class="leafygreen-ui-38lglc" id="_pf762l6cz" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"mongodb+srv://myDatabaseUser:D1fficultP%[email protected]/?authSource=admin&amp;replicaSet=myRepl","programmingLanguage":"Bash"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <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">mongodb<!-- -->+<!-- --><span class="lg-highlight-attr">srv</span>:<span class="lg-highlight-comment">//myDatabaseUser:D1fficultP%[email protected]/?authSource=admin&amp;replicaSet=myRepl</span></td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-76-menu" aria-describedby="select-76-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-77" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:rj2:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":rj2:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rj2:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rj2:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_7mzhyio81" class="leafygreen-ui-38lglc" id="_tus1wzfaq" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"mongodb+srv://myDatabaseUser:D1fficultP%[email protected]/?authSource=admin&amp;replicaSet=myRepl","programmingLanguage":"Bash"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <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">mongodb<!-- -->+<!-- --><span class="lg-highlight-attr">srv</span>:<span class="lg-highlight-comment">//myDatabaseUser:D1fficultP%[email protected]/?authSource=admin&amp;replicaSet=myRepl</span></td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-79-menu" aria-describedby="select-79-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-80" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:rj3:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":rj3:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rj3:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rj3:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_9weynrbta" class="leafygreen-ui-38lglc" id="_z6yyw03h2" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"mongodb+srv://myDatabaseUser:D1fficultP%[email protected]/?authSource=admin&amp;replicaSet=myRepl","programmingLanguage":"Bash"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <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">mongodb<!-- -->+<!-- --><span class="lg-highlight-attr">srv</span>:<span class="lg-highlight-comment">//myDatabaseUser:D1fficultP%[email protected]/?authSource=admin&amp;replicaSet=myRepl</span></td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-82-menu" aria-describedby="select-82-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-83" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:rj4:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":rj4:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rj4:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rj4:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_6qpj1sdjw" class="leafygreen-ui-38lglc" id="_pfshcx9b3" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"mongodb+srv://myDatabaseUser:D1fficultP%[email protected]/?authSource=admin&amp;replicaSet=myRepl","programmingLanguage":"Bash"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <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">mongodb<!-- -->+<!-- --><span class="lg-highlight-attr">srv</span>:<span class="lg-highlight-comment">//myDatabaseUser:D1fficultP%[email protected]/?authSource=admin&amp;replicaSet=myRepl</span></td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-85-menu" aria-describedby="select-85-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-86" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:rj5:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":rj5:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rj5:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rj5:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_k87jf9xlk" class="leafygreen-ui-38lglc" id="_7ir7gupsn" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"mongodb+srv://myDatabaseUser:D1fficultP%[email protected]:27017,mongodb1.example.com:27017,mongodb2.example.com:27017/?authSource=admin&amp;replicaSet=myRepl","programmingLanguage":"Bash"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <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">mongodb<!-- -->+<!-- --><span class="lg-highlight-attr">srv</span>:<span class="lg-highlight-comment">//myDatabaseUser:D1fficultP%[email protected]:27017,mongodb1.example.com:27017,mongodb2.example.com:27017/?authSource=admin&amp;replicaSet=myRepl</span></td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-88-menu" aria-describedby="select-88-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-89" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:rj6:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":rj6:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rj6:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rj6:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_buawqa0xe" class="" id="_y0460g7co" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"mongodb+srv://myDatabaseUser:D1fficultP%[email protected]/?authSource=admin&amp;replicaSet=myRepl","programmingLanguage":"Bash"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <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">mongodb<!-- -->+<!-- --><span class="lg-highlight-attr">srv</span>:<span class="lg-highlight-comment">//myDatabaseUser:D1fficultP%[email protected]/?authSource=admin&amp;replicaSet=myRepl</span></td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-91-menu" aria-describedby="select-91-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-92" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:rj7:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":rj7:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rj7:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rj7:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_snx1e9ech" class="leafygreen-ui-38lglc" id="_q7fwjz14a" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"mongodb+srv://myDatabaseUser:D1fficultP%[email protected]/?authSource=admin&amp;replicaSet=myRepl","programmingLanguage":"Bash"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <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">mongodb<!-- -->+<!-- --><span class="lg-highlight-attr">srv</span>:<span class="lg-highlight-comment">//myDatabaseUser:D1fficultP%[email protected]/?authSource=admin&amp;replicaSet=myRepl</span></td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-94-menu" aria-describedby="select-94-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-95" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:rj8:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":rj8:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rj8:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rj8:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_rfz10qt2b" class="leafygreen-ui-38lglc" id="_vxuhhu9f4" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"mongodb+srv://myDatabaseUser:D1fficultP%[email protected]/?authSource=admin&amp;replicaSet=myRepl","programmingLanguage":"Bash"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <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">mongodb<!-- -->+<!-- --><span class="lg-highlight-attr">srv</span>:<span class="lg-highlight-comment">//myDatabaseUser:D1fficultP%[email protected]/?authSource=admin&amp;replicaSet=myRepl</span></td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-97-menu" aria-describedby="select-97-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-98" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:rj9:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":rj9:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rj9:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rj9:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_9eccf8pex" class="leafygreen-ui-38lglc" id="_k4k2h1xsk" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"mongodb+srv://myDatabaseUser:D1fficultP%[email protected]/?authSource=admin&amp;replicaSet=myRepl","programmingLanguage":"Bash"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <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">mongodb<!-- -->+<!-- --><span class="lg-highlight-attr">srv</span>:<span class="lg-highlight-comment">//myDatabaseUser:D1fficultP%[email protected]/?authSource=admin&amp;replicaSet=myRepl</span></td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-100-menu" aria-describedby="select-100-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-101" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:rja:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":rja:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rja:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rja:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_pf1dz9f9m" class="leafygreen-ui-38lglc" id="_op4qmdve5" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"mongodb+srv://myDatabaseUser:D1fficultP%[email protected]/?authSource=admin&amp;replicaSet=myRepl","programmingLanguage":"Bash"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <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">mongodb<!-- -->+<!-- --><span class="lg-highlight-attr">srv</span>:<span class="lg-highlight-comment">//myDatabaseUser:D1fficultP%[email protected]/?authSource=admin&amp;replicaSet=myRepl</span></td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-103-menu" aria-describedby="select-103-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-104" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:rjb:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":rjb:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rjb:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rjb:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_w15wfgf9e" class="leafygreen-ui-38lglc" id="_cnicixw7p" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"mongodb+srv://myDatabaseUser:D1fficultP%[email protected]/?authSource=admin&amp;replicaSet=myRepl","programmingLanguage":"Bash"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <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">mongodb<!-- -->+<!-- --><span class="lg-highlight-attr">srv</span>:<span class="lg-highlight-comment">//myDatabaseUser:D1fficultP%[email protected]/?authSource=admin&amp;replicaSet=myRepl</span></td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-106-menu" aria-describedby="select-106-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-107" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:rjc:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":rjc:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rjc:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rjc:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_1eol5ohdh" class="leafygreen-ui-38lglc" id="_b8v9jweol" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"mongodb+srv://myDatabaseUser:D1fficultP%[email protected]/?authSource=admin&amp;replicaSet=myRepl","programmingLanguage":"Bash"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <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">mongodb<!-- -->+<!-- --><span class="lg-highlight-attr">srv</span>:<span class="lg-highlight-comment">//myDatabaseUser:D1fficultP%[email protected]/?authSource=admin&amp;replicaSet=myRepl</span></td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-109-menu" aria-describedby="select-109-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-110" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:rjd:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":rjd:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rjd:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rjd:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> </div> </div> <p class="leafygreen-ui-1kp3ins"> If the username or password includes the following characters, those characters must be converted using <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://tools.ietf.org/html/rfc3986#section-2.1" rel="noopener noreferrer"> <span> percent encoding <!-- --> : </span> <svg alt="" aria-hidden="true" class="leafygreen-ui-1ie5kuq" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M13.823 2.4491C13.8201 2.30008 13.6999 2.17994 13.5509 2.17704L9.5062 2.09836C9.25654 2.09351 9.12821 2.39519 9.30482 2.5718L10.3856 3.65257L7.93433 6.10383C7.87964 6.15852 7.83047 6.21665 7.78683 6.27752L5.99909 8.06525C5.46457 8.59977 5.46457 9.4664 5.99909 10.0009C6.53361 10.5354 7.40023 10.5354 7.93475 10.0009L9.72249 8.21317C9.78336 8.16953 9.84148 8.12037 9.89618 8.06567L12.3474 5.61441L13.4282 6.69518C13.6048 6.87179 13.9065 6.74347 13.9016 6.4938L13.823 2.4491Z" fill="currentColor"> </path> <path d="M7.25 3.12893C7.66421 3.12893 8 3.46472 8 3.87893C8 4.29315 7.66421 4.62893 7.25 4.62893H4C3.72386 4.62893 3.5 4.85279 3.5 5.12893V11.9929C3.5 12.2691 3.72386 12.4929 4 12.4929H10.864C11.1401 12.4929 11.364 12.2691 11.364 11.9929V8.75C11.364 8.33579 11.6998 8 12.114 8C12.5282 8 12.864 8.33579 12.864 8.75V11.9929C12.864 13.0975 11.9686 13.9929 10.864 13.9929H4C2.89543 13.9929 2 13.0975 2 11.9929V5.12893C2 4.02436 2.89543 3.12893 4 3.12893H7.25Z" fill="currentColor"> </path> </svg> </a> </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"$ : / ? # [ ] @"} </script> <div class="css-1lju8ps"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1jheeh3"> <pre class="leafygreen-ui-1agdxuk" tabindex="-1"><code class="lg-highlight-hljs-light none leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">$ : / ? # [ ] @</td></tr></tbody></table></code></pre> </div> </div> </div> </div> </div> </div> <div> <div aria-labelledby="_fnc5up8zy" class="leafygreen-ui-38lglc" id="_fy0zjwmwx" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <p class="leafygreen-ui-1kp3ins"> The following sharded cluster connection string includes the these elements: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> The <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongos/#mongodb-binary-bin.mongos"> <code class="leafygreen-ui-1l06pbn"> mongos </code> </a> hosts in the connection string </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> It authenticates as user <code class="leafygreen-ui-1l06pbn"> myDatabaseUser </code> with the password <code class="leafygreen-ui-1l06pbn"> D1fficultP%40ssw0rd </code> to <a class="leafygreen-ui-tqgtui" href="/docs/manual/tutorial/enable-authentication/#std-label-enable-access-control"> enforce access control </a> </p> </li> </ul> <div aria-hidden="true"> </div> <div class="leafygreen-ui-f2qztv" data-lgid="lg-tabs"> <div class="leafygreen-ui-jp7pox" id="tabs-14"> <div aria-label="Tabs to describe usage of drivers" aria-orientation="horizontal" class="leafygreen-ui-m8p1vb lg-ui-tab-list-0000" data-lgid="lg-tabs-tab_list" role="tablist"> <button aria-controls="_279ms5xy6" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_ohadbegb8" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> MongoDB Shell </div> </button> <button aria-controls="_bw1w2xzzc" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_xbc7cj9zo" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Compass </div> </button> <button aria-controls="_zwek2m56s" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_4jr4fud5l" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> C# </div> </button> <button aria-controls="_u6v87b43o" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_7p3xgbxtn" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Go </div> </button> <button aria-controls="_mmp0kie7v" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_7lnofsyl5" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Java (Async) </div> </button> <button aria-controls="_qp8d7wr5g" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_kcf5wvwhf" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Java (Sync) </div> </button> <button aria-controls="_xv8lky6wq" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_bb8cgdw9r" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Motor </div> </button> <button aria-controls="_dvgt4ecjq" aria-selected="true" class="leafygreen-ui-1l773z1" data-text="" id="_bo3lzis4i" name="" role="tab" tabindex="0"> <div class="leafygreen-ui-1nxuzmg"> Node.js </div> </button> <button aria-controls="_xcsyckit8" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_lc2p8ety6" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Perl </div> </button> <button aria-controls="_snq6cw9jt" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_q8oc5qxxj" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> PHP </div> </button> <button aria-controls="_fbvnyguh9" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_r4i6dchof" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Python </div> </button> <button aria-controls="_2js7axouy" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_sk7ji22hi" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Ruby </div> </button> <button aria-controls="_cvju7py0p" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_xwcelwixg" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Rust </div> </button> <button aria-controls="_mfylsc8o2" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_4f4pfo0lf" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Scala </div> </button> </div> <div class="leafygreen-ui-ov1ktg"> <div class="leafygreen-ui-1sg2lsz"> </div> </div> </div> <div class="lg-ui-tab-panels-0000" data-lgid="lg-tabs-tab_panels"> <div> <div aria-labelledby="_0xmzqetvs" class="leafygreen-ui-38lglc" id="_k8wpcbs5z" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"mongosh \"mongodb+srv://mongos0.example.com/?authSource=admin\" --apiVersion 1 --username myDatabaseUser","programmingLanguage":"Bash"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <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">mongosh <span class="lg-highlight-string">"mongodb+srv://mongos0.example.com/?authSource=admin"</span> --apiVersion <span class="lg-highlight-number">1</span> --username myDatabaseUser</td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-112-menu" aria-describedby="select-112-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-113" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:rje:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":rje:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rje:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rje:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_dvrwwmtxj" class="leafygreen-ui-38lglc" id="_rnm6zisxo" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"mongodb+srv://myDatabaseUser:D1fficultP%[email protected]/?authSource=admin","programmingLanguage":"Bash"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <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">mongodb<!-- -->+<!-- --><span class="lg-highlight-attr">srv</span>:<span class="lg-highlight-comment">//myDatabaseUser:D1fficultP%[email protected]/?authSource=admin</span></td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-115-menu" aria-describedby="select-115-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-116" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:rjf:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":rjf:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rjf:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rjf:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_v7satcnjs" class="leafygreen-ui-38lglc" id="_4nla97olw" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"mongodb+srv://myDatabaseUser:D1fficultP%[email protected]/?authSource=admin","programmingLanguage":"Bash"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <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">mongodb<!-- -->+<!-- --><span class="lg-highlight-attr">srv</span>:<span class="lg-highlight-comment">//myDatabaseUser:D1fficultP%[email protected]/?authSource=admin</span></td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-118-menu" aria-describedby="select-118-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-119" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:rjg:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":rjg:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rjg:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rjg:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_e6dwtfz55" class="leafygreen-ui-38lglc" id="_bomqsil2j" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"mongodb+srv://myDatabaseUser:D1fficultP%[email protected]/?authSource=admin","programmingLanguage":"Bash"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <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">mongodb<!-- -->+<!-- --><span class="lg-highlight-attr">srv</span>:<span class="lg-highlight-comment">//myDatabaseUser:D1fficultP%[email protected]/?authSource=admin</span></td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-121-menu" aria-describedby="select-121-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-122" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:rjh:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":rjh:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rjh:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rjh:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_z36z3hbx6" class="leafygreen-ui-38lglc" id="_b0djfvxro" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"mongodb+srv://myDatabaseUser:D1fficultP%[email protected]/?authSource=admin","programmingLanguage":"Bash"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <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">mongodb<!-- -->+<!-- --><span class="lg-highlight-attr">srv</span>:<span class="lg-highlight-comment">//myDatabaseUser:D1fficultP%[email protected]/?authSource=admin</span></td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-124-menu" aria-describedby="select-124-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-125" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:rji:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":rji:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rji:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rji:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_ym1bunjo6" class="leafygreen-ui-38lglc" id="_tvtz4s6z4" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"mongodb+srv://myDatabaseUser:D1fficultP%[email protected]/?authSource=admin","programmingLanguage":"Bash"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <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">mongodb<!-- -->+<!-- --><span class="lg-highlight-attr">srv</span>:<span class="lg-highlight-comment">//myDatabaseUser:D1fficultP%[email protected]/?authSource=admin</span></td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-127-menu" aria-describedby="select-127-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-128" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:rjj:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":rjj:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rjj:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rjj:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_i4zh76ges" class="leafygreen-ui-38lglc" id="_havquz4kr" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"mongodb+srv://myDatabaseUser:D1fficultP%[email protected]:27017,mongos1.example.com:27017,mongos2.example.com:27017/?authSource=admin","programmingLanguage":"Bash"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <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">mongodb<!-- -->+<!-- --><span class="lg-highlight-attr">srv</span>:<span class="lg-highlight-comment">//myDatabaseUser:D1fficultP%[email protected]:27017,mongos1.example.com:27017,mongos2.example.com:27017/?authSource=admin</span></td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-130-menu" aria-describedby="select-130-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-131" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:rjk:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":rjk:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rjk:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rjk:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_pd2oma5zi" class="" id="_lksyx4xk5" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"mongodb+srv://myDatabaseUser:D1fficultP%[email protected]/?authSource=admin","programmingLanguage":"Bash"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <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">mongodb<!-- -->+<!-- --><span class="lg-highlight-attr">srv</span>:<span class="lg-highlight-comment">//myDatabaseUser:D1fficultP%[email protected]/?authSource=admin</span></td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-133-menu" aria-describedby="select-133-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-134" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:rjl:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":rjl:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rjl:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rjl:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_hnx0zujkl" class="leafygreen-ui-38lglc" id="_cfgj0bryl" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"mongodb+srv://myDatabaseUser:D1fficultP%[email protected]/?authSource=admin","programmingLanguage":"Bash"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <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">mongodb<!-- -->+<!-- --><span class="lg-highlight-attr">srv</span>:<span class="lg-highlight-comment">//myDatabaseUser:D1fficultP%[email protected]/?authSource=admin</span></td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-136-menu" aria-describedby="select-136-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-137" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:rjm:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":rjm:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rjm:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rjm:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_qsxld30db" class="leafygreen-ui-38lglc" id="_uy27h796b" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"mongodb+srv://myDatabaseUser:D1fficultP%[email protected]/?authSource=admin","programmingLanguage":"Bash"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <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">mongodb<!-- -->+<!-- --><span class="lg-highlight-attr">srv</span>:<span class="lg-highlight-comment">//myDatabaseUser:D1fficultP%[email protected]/?authSource=admin</span></td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-139-menu" aria-describedby="select-139-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-140" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:rjn:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":rjn:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rjn:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rjn:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_sxz7p81wo" class="leafygreen-ui-38lglc" id="_2ecjj8vfy" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"mongodb+srv://myDatabaseUser:D1fficultP%[email protected]/?authSource=admin","programmingLanguage":"Bash"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <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">mongodb<!-- -->+<!-- --><span class="lg-highlight-attr">srv</span>:<span class="lg-highlight-comment">//myDatabaseUser:D1fficultP%[email protected]/?authSource=admin</span></td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-142-menu" aria-describedby="select-142-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-143" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:rjo:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":rjo:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rjo:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rjo:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_anh56kms8" class="leafygreen-ui-38lglc" id="_7cxnnod0n" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"mongodb+srv://myDatabaseUser:D1fficultP%[email protected]/?authSource=admin","programmingLanguage":"Bash"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <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">mongodb<!-- -->+<!-- --><span class="lg-highlight-attr">srv</span>:<span class="lg-highlight-comment">//myDatabaseUser:D1fficultP%[email protected]/?authSource=admin</span></td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-145-menu" aria-describedby="select-145-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-146" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:rjp:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":rjp:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rjp:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rjp:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_63jefwad3" class="leafygreen-ui-38lglc" id="_8os3tiagy" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"mongodb+srv://myDatabaseUser:D1fficultP%[email protected]/?authSource=admin","programmingLanguage":"Bash"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <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">mongodb<!-- -->+<!-- --><span class="lg-highlight-attr">srv</span>:<span class="lg-highlight-comment">//myDatabaseUser:D1fficultP%[email protected]/?authSource=admin</span></td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-148-menu" aria-describedby="select-148-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-149" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:rjq:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":rjq:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rjq:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rjq:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_pmk4hy5nf" class="leafygreen-ui-38lglc" id="_53g49nfcn" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"mongodb+srv://myDatabaseUser:D1fficultP%[email protected]/?authSource=admin","programmingLanguage":"Bash"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <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">mongodb<!-- -->+<!-- --><span class="lg-highlight-attr">srv</span>:<span class="lg-highlight-comment">//myDatabaseUser:D1fficultP%[email protected]/?authSource=admin</span></td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-151-menu" aria-describedby="select-151-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-152" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:rjr:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":rjr:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rjr:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rjr:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> </div> </div> <p class="leafygreen-ui-1kp3ins"> If the username or password includes the following characters, those characters must be converted using <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://tools.ietf.org/html/rfc3986#section-2.1" rel="noopener noreferrer"> <span> percent encoding <!-- --> : </span> <svg alt="" aria-hidden="true" class="leafygreen-ui-1ie5kuq" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M13.823 2.4491C13.8201 2.30008 13.6999 2.17994 13.5509 2.17704L9.5062 2.09836C9.25654 2.09351 9.12821 2.39519 9.30482 2.5718L10.3856 3.65257L7.93433 6.10383C7.87964 6.15852 7.83047 6.21665 7.78683 6.27752L5.99909 8.06525C5.46457 8.59977 5.46457 9.4664 5.99909 10.0009C6.53361 10.5354 7.40023 10.5354 7.93475 10.0009L9.72249 8.21317C9.78336 8.16953 9.84148 8.12037 9.89618 8.06567L12.3474 5.61441L13.4282 6.69518C13.6048 6.87179 13.9065 6.74347 13.9016 6.4938L13.823 2.4491Z" fill="currentColor"> </path> <path d="M7.25 3.12893C7.66421 3.12893 8 3.46472 8 3.87893C8 4.29315 7.66421 4.62893 7.25 4.62893H4C3.72386 4.62893 3.5 4.85279 3.5 5.12893V11.9929C3.5 12.2691 3.72386 12.4929 4 12.4929H10.864C11.1401 12.4929 11.364 12.2691 11.364 11.9929V8.75C11.364 8.33579 11.6998 8 12.114 8C12.5282 8 12.864 8.33579 12.864 8.75V11.9929C12.864 13.0975 11.9686 13.9929 10.864 13.9929H4C2.89543 13.9929 2 13.0975 2 11.9929V5.12893C2 4.02436 2.89543 3.12893 4 3.12893H7.25Z" fill="currentColor"> </path> </svg> </a> </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"$ : / ? # [ ] @"} </script> <div class="css-1lju8ps"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1jheeh3"> <pre class="leafygreen-ui-1agdxuk" tabindex="-1"><code class="lg-highlight-hljs-light none leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">$ : / ? # [ ] @</td></tr></tbody></table></code></pre> </div> </div> </div> </div> </div> </div> <div> <div aria-labelledby="_ovq9tqj4u" class="leafygreen-ui-38lglc" id="_6wcd2zpij" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <p class="leafygreen-ui-1kp3ins"> The following standalone connection string authenticates as user <code class="leafygreen-ui-1l06pbn"> myDatabaseUser </code> with the password <code class="leafygreen-ui-1l06pbn"> D1fficultP%40ssw0rd </code> to <a class="leafygreen-ui-tqgtui" href="/docs/manual/tutorial/enable-authentication/#std-label-enable-access-control"> enforce access control <!-- --> : </a> </p> <div aria-hidden="true"> </div> <div class="leafygreen-ui-f2qztv" data-lgid="lg-tabs"> <div class="leafygreen-ui-jp7pox" id="tabs-15"> <div aria-label="Tabs to describe usage of drivers" aria-orientation="horizontal" class="leafygreen-ui-m8p1vb lg-ui-tab-list-0000" data-lgid="lg-tabs-tab_list" role="tablist"> <button aria-controls="_rcexfoq45" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_eqsy6u39h" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> MongoDB Shell </div> </button> <button aria-controls="_u92t0jy4f" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_m7dy8nzdw" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Compass </div> </button> <button aria-controls="_yt5urdrhq" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_llb63nfd4" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> C# </div> </button> <button aria-controls="_b6thp64hw" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_nygbt4e0g" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Go </div> </button> <button aria-controls="_c0jo1tr6m" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_h3w5br4gv" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Java (Async) </div> </button> <button aria-controls="_xn1it1to6" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_kswm5asgx" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Java (Sync) </div> </button> <button aria-controls="_haz9kt2yh" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_lw9a3vqt8" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Motor </div> </button> <button aria-controls="_033ujr55p" aria-selected="true" class="leafygreen-ui-1l773z1" data-text="" id="_88j5ae67k" name="" role="tab" tabindex="0"> <div class="leafygreen-ui-1nxuzmg"> Node.js </div> </button> <button aria-controls="_4yznu2571" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_sqtgpiqpx" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Perl </div> </button> <button aria-controls="_ptnm0qchh" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_rxsrfxoig" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> PHP </div> </button> <button aria-controls="_bcjjj5ip3" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_7ycfljl41" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Python </div> </button> <button aria-controls="_i5blgj78f" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_77oy5sv8e" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Ruby </div> </button> <button aria-controls="_0m4oijoed" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_y51nixjma" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Rust </div> </button> <button aria-controls="_g65xcyn7m" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_air2qp3qg" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Scala </div> </button> </div> <div class="leafygreen-ui-ov1ktg"> <div class="leafygreen-ui-1sg2lsz"> </div> </div> </div> <div class="lg-ui-tab-panels-0000" data-lgid="lg-tabs-tab_panels"> <div> <div aria-labelledby="_zye5m6moe" class="leafygreen-ui-38lglc" id="_fnx3gqxtf" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"mongosh \"mongodb+srv://mongodb0.example.com/?authSource=admin\" --apiVersion 1 --username myDatabaseUser","programmingLanguage":"Bash"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <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">mongosh <span class="lg-highlight-string">"mongodb+srv://mongodb0.example.com/?authSource=admin"</span> --apiVersion <span class="lg-highlight-number">1</span> --username myDatabaseUser</td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-154-menu" aria-describedby="select-154-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-155" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:rjs:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":rjs:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rjs:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rjs:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_o7ak63vpf" class="leafygreen-ui-38lglc" id="_6zwgmlqhv" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"mongodb+srv://myDatabaseUser:D1fficultP%[email protected]/?authSource=admin","programmingLanguage":"Bash"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <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">mongodb<!-- -->+<!-- --><span class="lg-highlight-attr">srv</span>:<span class="lg-highlight-comment">//myDatabaseUser:D1fficultP%[email protected]/?authSource=admin</span></td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-157-menu" aria-describedby="select-157-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-158" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:rjt:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":rjt:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rjt:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rjt:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_wpsdyb8e2" class="leafygreen-ui-38lglc" id="_v2xshjg1l" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"mongodb+srv://myDatabaseUser:D1fficultP%[email protected]/?authSource=admin","programmingLanguage":"Bash"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <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">mongodb<!-- -->+<!-- --><span class="lg-highlight-attr">srv</span>:<span class="lg-highlight-comment">//myDatabaseUser:D1fficultP%[email protected]/?authSource=admin</span></td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-160-menu" aria-describedby="select-160-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-161" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:rju:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":rju:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rju:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rju:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_wij5bse6j" class="leafygreen-ui-38lglc" id="_ui9m0bfj7" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"mongodb+srv://myDatabaseUser:D1fficultP%[email protected]/?authSource=admin","programmingLanguage":"Bash"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <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">mongodb<!-- -->+<!-- --><span class="lg-highlight-attr">srv</span>:<span class="lg-highlight-comment">//myDatabaseUser:D1fficultP%[email protected]/?authSource=admin</span></td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-163-menu" aria-describedby="select-163-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-164" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:rjv:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":rjv:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rjv:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rjv:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_6oxvm5knz" class="leafygreen-ui-38lglc" id="_02cwngric" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"mongodb+srv://myDatabaseUser:D1fficultP%[email protected]/?authSource=admin","programmingLanguage":"Bash"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <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">mongodb<!-- -->+<!-- --><span class="lg-highlight-attr">srv</span>:<span class="lg-highlight-comment">//myDatabaseUser:D1fficultP%[email protected]/?authSource=admin</span></td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-166-menu" aria-describedby="select-166-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-167" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:rk0:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":rk0:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rk0:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rk0:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_unsqo1oyk" class="leafygreen-ui-38lglc" id="_uioxe2v37" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"mongodb+srv://myDatabaseUser:D1fficultP%[email protected]/?authSource=admin","programmingLanguage":"Bash"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <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">mongodb<!-- -->+<!-- --><span class="lg-highlight-attr">srv</span>:<span class="lg-highlight-comment">//myDatabaseUser:D1fficultP%[email protected]/?authSource=admin</span></td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-169-menu" aria-describedby="select-169-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-170" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:rk1:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":rk1:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rk1:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rk1:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_1k86zkw1p" class="leafygreen-ui-38lglc" id="_oazeohk8a" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"mongodb+srv://myDatabaseUser:D1fficultP%[email protected]:27017/?authSource=admin","programmingLanguage":"Bash"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <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">mongodb<!-- -->+<!-- --><span class="lg-highlight-attr">srv</span>:<span class="lg-highlight-comment">//myDatabaseUser:D1fficultP%[email protected]:27017/?authSource=admin</span></td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-172-menu" aria-describedby="select-172-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-173" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:rk2:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":rk2:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rk2:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rk2:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_wg9mxm27t" class="" id="_fcbj5tjrc" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"mongodb+srv://myDatabaseUser:D1fficultP%[email protected]/?authSource=admin","programmingLanguage":"Bash"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <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">mongodb<!-- -->+<!-- --><span class="lg-highlight-attr">srv</span>:<span class="lg-highlight-comment">//myDatabaseUser:D1fficultP%[email protected]/?authSource=admin</span></td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-175-menu" aria-describedby="select-175-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-176" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:rk3:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":rk3:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rk3:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rk3:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_hcxx0hcp2" class="leafygreen-ui-38lglc" id="_rneg0dhtc" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"mongodb+srv://myDatabaseUser:D1fficultP%[email protected]/?authSource=admin","programmingLanguage":"Bash"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <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">mongodb<!-- -->+<!-- --><span class="lg-highlight-attr">srv</span>:<span class="lg-highlight-comment">//myDatabaseUser:D1fficultP%[email protected]/?authSource=admin</span></td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-178-menu" aria-describedby="select-178-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-179" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:rk4:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":rk4:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rk4:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rk4:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_5wzm9xvnq" class="leafygreen-ui-38lglc" id="_d8r4h6woq" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"mongodb+srv://myDatabaseUser:D1fficultP%[email protected]/?authSource=admin","programmingLanguage":"Bash"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <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">mongodb<!-- -->+<!-- --><span class="lg-highlight-attr">srv</span>:<span class="lg-highlight-comment">//myDatabaseUser:D1fficultP%[email protected]/?authSource=admin</span></td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-181-menu" aria-describedby="select-181-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-182" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:rk5:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":rk5:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rk5:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rk5:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_ofljbxctv" class="leafygreen-ui-38lglc" id="_jtsekzpye" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"mongodb+srv://myDatabaseUser:D1fficultP%[email protected]/?authSource=admin","programmingLanguage":"Bash"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <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">mongodb<!-- -->+<!-- --><span class="lg-highlight-attr">srv</span>:<span class="lg-highlight-comment">//myDatabaseUser:D1fficultP%[email protected]/?authSource=admin</span></td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-184-menu" aria-describedby="select-184-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-185" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:rk6:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":rk6:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rk6:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rk6:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_d8kvstltd" class="leafygreen-ui-38lglc" id="_gsr9biy5y" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"mongodb+srv://myDatabaseUser:D1fficultP%[email protected]/?authSource=admin","programmingLanguage":"Bash"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <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">mongodb<!-- -->+<!-- --><span class="lg-highlight-attr">srv</span>:<span class="lg-highlight-comment">//myDatabaseUser:D1fficultP%[email protected]/?authSource=admin</span></td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-187-menu" aria-describedby="select-187-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-188" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:rk7:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":rk7:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rk7:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rk7:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_rk0l3gnfa" class="leafygreen-ui-38lglc" id="_6clsbqzub" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"mongodb+srv://myDatabaseUser:D1fficultP%[email protected]/?authSource=admin","programmingLanguage":"Bash"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <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">mongodb<!-- -->+<!-- --><span class="lg-highlight-attr">srv</span>:<span class="lg-highlight-comment">//myDatabaseUser:D1fficultP%[email protected]/?authSource=admin</span></td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-190-menu" aria-describedby="select-190-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-191" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:rk8:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":rk8:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rk8:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rk8:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_fs9d87f1c" class="leafygreen-ui-38lglc" id="_ymspew0wn" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"mongodb+srv://myDatabaseUser:D1fficultP%[email protected]/?authSource=admin","programmingLanguage":"Bash"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <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">mongodb<!-- -->+<!-- --><span class="lg-highlight-attr">srv</span>:<span class="lg-highlight-comment">//myDatabaseUser:D1fficultP%[email protected]/?authSource=admin</span></td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-193-menu" aria-describedby="select-193-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-194" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:rk9:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":rk9:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rk9:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rk9:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> </div> </div> <p class="leafygreen-ui-1kp3ins"> If the username or password includes the following characters, those characters must be converted using <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://tools.ietf.org/html/rfc3986#section-2.1" rel="noopener noreferrer"> <span> percent encoding <!-- --> : </span> <svg alt="" aria-hidden="true" class="leafygreen-ui-1ie5kuq" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M13.823 2.4491C13.8201 2.30008 13.6999 2.17994 13.5509 2.17704L9.5062 2.09836C9.25654 2.09351 9.12821 2.39519 9.30482 2.5718L10.3856 3.65257L7.93433 6.10383C7.87964 6.15852 7.83047 6.21665 7.78683 6.27752L5.99909 8.06525C5.46457 8.59977 5.46457 9.4664 5.99909 10.0009C6.53361 10.5354 7.40023 10.5354 7.93475 10.0009L9.72249 8.21317C9.78336 8.16953 9.84148 8.12037 9.89618 8.06567L12.3474 5.61441L13.4282 6.69518C13.6048 6.87179 13.9065 6.74347 13.9016 6.4938L13.823 2.4491Z" fill="currentColor"> </path> <path d="M7.25 3.12893C7.66421 3.12893 8 3.46472 8 3.87893C8 4.29315 7.66421 4.62893 7.25 4.62893H4C3.72386 4.62893 3.5 4.85279 3.5 5.12893V11.9929C3.5 12.2691 3.72386 12.4929 4 12.4929H10.864C11.1401 12.4929 11.364 12.2691 11.364 11.9929V8.75C11.364 8.33579 11.6998 8 12.114 8C12.5282 8 12.864 8.33579 12.864 8.75V11.9929C12.864 13.0975 11.9686 13.9929 10.864 13.9929H4C2.89543 13.9929 2 13.0975 2 11.9929V5.12893C2 4.02436 2.89543 3.12893 4 3.12893H7.25Z" fill="currentColor"> </path> </svg> </a> </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"$ : / ? # [ ] @"} </script> <div class="css-1lju8ps"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1jheeh3"> <pre class="leafygreen-ui-1agdxuk" tabindex="-1"><code class="lg-highlight-hljs-light none leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">$ : / ? # [ ] @</td></tr></tbody></table></code></pre> </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> <div> <div aria-labelledby="_sbynq6f0g" class="leafygreen-ui-38lglc" id="_kdscuv6d9" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <div aria-hidden="true"> </div> <div class="leafygreen-ui-1b75luy" data-lgid="lg-tabs"> <div class="leafygreen-ui-jp7pox" id="tabs-20"> <div aria-label="Tabs to describe usage of repl/sharded/standalone" aria-orientation="horizontal" class="leafygreen-ui-m8p1vb lg-ui-tab-list-0000" data-lgid="lg-tabs-tab_list" role="tablist"> <button aria-controls="_kmn8fs6p7" aria-selected="true" class="leafygreen-ui-1l773z1" data-text="" id="_2xogkaznr" name="" role="tab" tabindex="0"> <div class="leafygreen-ui-1nxuzmg"> Replica Set </div> </button> <button aria-controls="_5zhvxv2ma" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_nb060u0id" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Sharded Cluster </div> </button> <button aria-controls="_tkvnz56s7" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_bsf0k59xx" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Standalone </div> </button> </div> <div class="leafygreen-ui-ov1ktg"> <div class="leafygreen-ui-1sg2lsz"> </div> </div> </div> <div class="lg-ui-tab-panels-0000" data-lgid="lg-tabs-tab_panels"> <div> <div aria-labelledby="_7bgvvlpqz" class="" id="_xs87llole" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <p class="leafygreen-ui-1kp3ins"> The following replica set connection string includes these elements: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> The <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/connection-string-options/#mongodb-urioption-urioption.replicaSet"> <code class="leafygreen-ui-1l06pbn"> replicaSet </code> </a> option </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> The hostname(s) of the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> instance(s) as listed in the replica set configuration </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> A username and password to <a class="leafygreen-ui-tqgtui" href="/docs/manual/tutorial/enable-authentication/"> enforce access control <!-- --> : </a> </p> </li> </ul> <div aria-hidden="true"> </div> <div class="leafygreen-ui-f2qztv" data-lgid="lg-tabs"> <div class="leafygreen-ui-jp7pox" id="tabs-17"> <div aria-label="Tabs to describe usage of drivers" aria-orientation="horizontal" class="leafygreen-ui-m8p1vb lg-ui-tab-list-0000" data-lgid="lg-tabs-tab_list" role="tablist"> <button aria-controls="_ykcarq06k" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_noty7u83m" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> MongoDB Shell </div> </button> <button aria-controls="_qgosehn7d" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_97rndhunp" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Compass </div> </button> <button aria-controls="_fqimbnx4t" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_udli6j1jd" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> C# </div> </button> <button aria-controls="_vb1w96y1e" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_95p5hyz4c" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Go </div> </button> <button aria-controls="_g4b0lpa1z" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_9emx5zva6" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Java (Async) </div> </button> <button aria-controls="_oun8r1s68" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_u0mqcv6xg" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Java (Sync) </div> </button> <button aria-controls="_jpoofffpp" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_w6c3gnqsl" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Motor </div> </button> <button aria-controls="_v0q1bk43u" aria-selected="true" class="leafygreen-ui-1l773z1" data-text="" id="_9s4vtfggg" name="" role="tab" tabindex="0"> <div class="leafygreen-ui-1nxuzmg"> Node.js </div> </button> <button aria-controls="_5xb2oyx7u" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_0rntynkp4" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Perl </div> </button> <button aria-controls="_bfzbqhnxm" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_o2bdi3u4j" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> PHP </div> </button> <button aria-controls="_md3gt6dzj" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_ttn6vdys7" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Python </div> </button> <button aria-controls="_j2jled6iy" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_dnu8ykpkr" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Ruby </div> </button> <button aria-controls="_anfzyfow1" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_f8c2oqpet" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Rust </div> </button> <button aria-controls="_ubddwsh4j" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_ax69rivx1" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Scala </div> </button> </div> <div class="leafygreen-ui-ov1ktg"> <div class="leafygreen-ui-1sg2lsz"> </div> </div> </div> <div class="lg-ui-tab-panels-0000" data-lgid="lg-tabs-tab_panels"> <div> <div aria-labelledby="_to6imihg6" class="leafygreen-ui-38lglc" id="_ksyoiq1z9" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"mongosh \"mongodb://mongodb0.example.com:27017,mongodb1.example.com:27017,mongodb2.example.com:27017/?authSource=admin&amp;replicaSet=myRepl\" --apiVersion 1 --username myDatabaseUser","programmingLanguage":"Bash"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <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">mongosh <span class="lg-highlight-string">"mongodb://mongodb0.example.com:27017,mongodb1.example.com:27017,mongodb2.example.com:27017/?authSource=admin&amp;replicaSet=myRepl"</span> --apiVersion <span class="lg-highlight-number">1</span> --username myDatabaseUser</td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-196-menu" aria-describedby="select-196-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-197" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:rka:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":rka:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rka:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rka:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_jgy25fg68" class="leafygreen-ui-38lglc" id="_m8x4dlrgp" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"mongodb://myDatabaseUser:D1fficultP%[email protected]:27017,mongodb1.example.com:27017,mongodb2.example.com:27017/?authSource=admin&amp;replicaSet=myRepl","programmingLanguage":"Bash"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <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"><!-- --><span class="lg-highlight-attr">mongodb</span>:<!-- --><span class="lg-highlight-comment">//myDatabaseUser:D1fficultP%[email protected]:27017,mongodb1.example.com:27017,mongodb2.example.com:27017/?authSource=admin&amp;replicaSet=myRepl</span></td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-199-menu" aria-describedby="select-199-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-200" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:rkb:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":rkb:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rkb:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rkb:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_q8emn49ax" class="leafygreen-ui-38lglc" id="_9f49czl6c" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"mongodb://myDatabaseUser:D1fficultP%[email protected]:27017,mongodb1.example.com:27017,mongodb2.example.com:27017/?authSource=admin&amp;replicaSet=myRepl","programmingLanguage":"Bash"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <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"><!-- --><span class="lg-highlight-attr">mongodb</span>:<!-- --><span class="lg-highlight-comment">//myDatabaseUser:D1fficultP%[email protected]:27017,mongodb1.example.com:27017,mongodb2.example.com:27017/?authSource=admin&amp;replicaSet=myRepl</span></td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-202-menu" aria-describedby="select-202-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-203" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:rkc:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":rkc:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rkc:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rkc:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_iz9rwdwwf" class="leafygreen-ui-38lglc" id="_a8zwhmhnb" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"mongodb://myDatabaseUser:D1fficultP%[email protected]:27017,mongodb1.example.com:27017,mongodb2.example.com:27017/?authSource=admin&amp;replicaSet=myRepl","programmingLanguage":"Bash"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <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"><!-- --><span class="lg-highlight-attr">mongodb</span>:<!-- --><span class="lg-highlight-comment">//myDatabaseUser:D1fficultP%[email protected]:27017,mongodb1.example.com:27017,mongodb2.example.com:27017/?authSource=admin&amp;replicaSet=myRepl</span></td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-205-menu" aria-describedby="select-205-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-206" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:rkd:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":rkd:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rkd:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rkd:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_ua9y9s6vq" class="leafygreen-ui-38lglc" id="_xla780e5c" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"mongodb://myDatabaseUser:D1fficultP%[email protected]:27017,mongodb1.example.com:27017,mongodb2.example.com:27017/?authSource=admin&amp;replicaSet=myRepl","programmingLanguage":"Bash"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <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"><!-- --><span class="lg-highlight-attr">mongodb</span>:<!-- --><span class="lg-highlight-comment">//myDatabaseUser:D1fficultP%[email protected]:27017,mongodb1.example.com:27017,mongodb2.example.com:27017/?authSource=admin&amp;replicaSet=myRepl</span></td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-208-menu" aria-describedby="select-208-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-209" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:rke:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":rke:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rke:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rke:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_w05a2bwad" class="leafygreen-ui-38lglc" id="_h3u6k9umh" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"mongodb://myDatabaseUser:D1fficultP%[email protected]:27017,mongodb1.example.com:27017,mongodb2.example.com:27017/?authSource=admin&amp;replicaSet=myRepl","programmingLanguage":"Bash"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <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"><!-- --><span class="lg-highlight-attr">mongodb</span>:<!-- --><span class="lg-highlight-comment">//myDatabaseUser:D1fficultP%[email protected]:27017,mongodb1.example.com:27017,mongodb2.example.com:27017/?authSource=admin&amp;replicaSet=myRepl</span></td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-211-menu" aria-describedby="select-211-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-212" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:rkf:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":rkf:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rkf:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rkf:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_kyl0x8lvv" class="leafygreen-ui-38lglc" id="_4qvzc2cnr" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"mongodb://myDatabaseUser:D1fficultP%[email protected]:27017,mongodb1.example.com:27017,mongodb2.example.com:27017/?authSource=admin&amp;replicaSet=myRepl","programmingLanguage":"Bash"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <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"><!-- --><span class="lg-highlight-attr">mongodb</span>:<!-- --><span class="lg-highlight-comment">//myDatabaseUser:D1fficultP%[email protected]:27017,mongodb1.example.com:27017,mongodb2.example.com:27017/?authSource=admin&amp;replicaSet=myRepl</span></td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-214-menu" aria-describedby="select-214-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-215" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:rkg:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":rkg:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rkg:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rkg:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_z0jrw3z61" class="" id="_71myfkn0y" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"mongodb://myDatabaseUser:D1fficultP%[email protected]:27017,mongodb1.example.com:27017,mongodb2.example.com:27017/?authSource=admin&amp;replicaSet=myRepl","programmingLanguage":"Bash"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <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"><!-- --><span class="lg-highlight-attr">mongodb</span>:<!-- --><span class="lg-highlight-comment">//myDatabaseUser:D1fficultP%[email protected]:27017,mongodb1.example.com:27017,mongodb2.example.com:27017/?authSource=admin&amp;replicaSet=myRepl</span></td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-217-menu" aria-describedby="select-217-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-218" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:rkh:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":rkh:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rkh:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rkh:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_jw0j70a3d" class="leafygreen-ui-38lglc" id="_lezn34uhi" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"mongodb://myDatabaseUser:D1fficultP%[email protected]:27017,mongodb1.example.com:27017,mongodb2.example.com:27017/?authSource=admin&amp;replicaSet=myRepl","programmingLanguage":"Bash"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <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"><!-- --><span class="lg-highlight-attr">mongodb</span>:<!-- --><span class="lg-highlight-comment">//myDatabaseUser:D1fficultP%[email protected]:27017,mongodb1.example.com:27017,mongodb2.example.com:27017/?authSource=admin&amp;replicaSet=myRepl</span></td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-220-menu" aria-describedby="select-220-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-221" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:rki:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":rki:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rki:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rki:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_vq773nudv" class="leafygreen-ui-38lglc" id="_gb138yjg7" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"mongodb://myDatabaseUser:D1fficultP%[email protected]:27017,mongodb1.example.com:27017,mongodb2.example.com:27017/?authSource=admin&amp;replicaSet=myRepl","programmingLanguage":"Bash"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <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"><!-- --><span class="lg-highlight-attr">mongodb</span>:<!-- --><span class="lg-highlight-comment">//myDatabaseUser:D1fficultP%[email protected]:27017,mongodb1.example.com:27017,mongodb2.example.com:27017/?authSource=admin&amp;replicaSet=myRepl</span></td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-223-menu" aria-describedby="select-223-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-224" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:rkj:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":rkj:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rkj:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rkj:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_d5vc3wmit" class="leafygreen-ui-38lglc" id="_l2mmt305r" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"mongodb://myDatabaseUser:D1fficultP%[email protected]:27017,mongodb1.example.com:27017,mongodb2.example.com:27017/?authSource=admin&amp;replicaSet=myRepl","programmingLanguage":"Bash"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <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"><!-- --><span class="lg-highlight-attr">mongodb</span>:<!-- --><span class="lg-highlight-comment">//myDatabaseUser:D1fficultP%[email protected]:27017,mongodb1.example.com:27017,mongodb2.example.com:27017/?authSource=admin&amp;replicaSet=myRepl</span></td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-226-menu" aria-describedby="select-226-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-227" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:rkk:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":rkk:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rkk:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rkk:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_6mgw3bfa8" class="leafygreen-ui-38lglc" id="_7lxzztjo6" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"mongodb://myDatabaseUser:D1fficultP%[email protected]:27017,mongodb1.example.com:27017,mongodb2.example.com:27017/?authSource=admin&amp;replicaSet=myRepl","programmingLanguage":"Bash"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <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"><!-- --><span class="lg-highlight-attr">mongodb</span>:<!-- --><span class="lg-highlight-comment">//myDatabaseUser:D1fficultP%[email protected]:27017,mongodb1.example.com:27017,mongodb2.example.com:27017/?authSource=admin&amp;replicaSet=myRepl</span></td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-229-menu" aria-describedby="select-229-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-230" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:rkl:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":rkl:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rkl:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rkl:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_zgolh4e5h" class="leafygreen-ui-38lglc" id="_6358frb87" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"mongodb://myDatabaseUser:D1fficultP%[email protected]:27017,mongodb1.example.com:27017,mongodb2.example.com:27017/?authSource=admin&amp;replicaSet=myRepl","programmingLanguage":"Bash"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <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"><!-- --><span class="lg-highlight-attr">mongodb</span>:<!-- --><span class="lg-highlight-comment">//myDatabaseUser:D1fficultP%[email protected]:27017,mongodb1.example.com:27017,mongodb2.example.com:27017/?authSource=admin&amp;replicaSet=myRepl</span></td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-232-menu" aria-describedby="select-232-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-233" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:rkm:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":rkm:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rkm:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rkm:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_flxfc2b7f" class="leafygreen-ui-38lglc" id="_lk3xkb33q" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"mongodb://myDatabaseUser:D1fficultP%[email protected]:27017,mongodb1.example.com:27017,mongodb2.example.com:27017/?authSource=admin&amp;replicaSet=myRepl","programmingLanguage":"Bash"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <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"><!-- --><span class="lg-highlight-attr">mongodb</span>:<!-- --><span class="lg-highlight-comment">//myDatabaseUser:D1fficultP%[email protected]:27017,mongodb1.example.com:27017,mongodb2.example.com:27017/?authSource=admin&amp;replicaSet=myRepl</span></td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-235-menu" aria-describedby="select-235-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-236" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:rkn:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":rkn:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rkn:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rkn:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> </div> </div> <p class="leafygreen-ui-1kp3ins"> If the username or password includes the following characters, those characters must be converted using <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://tools.ietf.org/html/rfc3986#section-2.1" rel="noopener noreferrer"> <span> percent encoding <!-- --> : </span> <svg alt="" aria-hidden="true" class="leafygreen-ui-1ie5kuq" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M13.823 2.4491C13.8201 2.30008 13.6999 2.17994 13.5509 2.17704L9.5062 2.09836C9.25654 2.09351 9.12821 2.39519 9.30482 2.5718L10.3856 3.65257L7.93433 6.10383C7.87964 6.15852 7.83047 6.21665 7.78683 6.27752L5.99909 8.06525C5.46457 8.59977 5.46457 9.4664 5.99909 10.0009C6.53361 10.5354 7.40023 10.5354 7.93475 10.0009L9.72249 8.21317C9.78336 8.16953 9.84148 8.12037 9.89618 8.06567L12.3474 5.61441L13.4282 6.69518C13.6048 6.87179 13.9065 6.74347 13.9016 6.4938L13.823 2.4491Z" fill="currentColor"> </path> <path d="M7.25 3.12893C7.66421 3.12893 8 3.46472 8 3.87893C8 4.29315 7.66421 4.62893 7.25 4.62893H4C3.72386 4.62893 3.5 4.85279 3.5 5.12893V11.9929C3.5 12.2691 3.72386 12.4929 4 12.4929H10.864C11.1401 12.4929 11.364 12.2691 11.364 11.9929V8.75C11.364 8.33579 11.6998 8 12.114 8C12.5282 8 12.864 8.33579 12.864 8.75V11.9929C12.864 13.0975 11.9686 13.9929 10.864 13.9929H4C2.89543 13.9929 2 13.0975 2 11.9929V5.12893C2 4.02436 2.89543 3.12893 4 3.12893H7.25Z" fill="currentColor"> </path> </svg> </a> </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"$ : / ? # [ ] @"} </script> <div class="css-1lju8ps"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1jheeh3"> <pre class="leafygreen-ui-1agdxuk" tabindex="-1"><code class="lg-highlight-hljs-light none leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">$ : / ? # [ ] @</td></tr></tbody></table></code></pre> </div> </div> </div> </div> </div> </div> <div> <div aria-labelledby="_j51p1fgkc" class="leafygreen-ui-38lglc" id="_kt45tvtxo" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <p class="leafygreen-ui-1kp3ins"> The following sharded cluster connection string includes the these elements: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> The <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongos/#mongodb-binary-bin.mongos"> <code class="leafygreen-ui-1l06pbn"> mongos </code> </a> hosts in the connection string </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> A username and password to <a class="leafygreen-ui-tqgtui" href="/docs/manual/tutorial/enable-authentication/"> enforce access control </a> </p> </li> </ul> <div aria-hidden="true"> </div> <div class="leafygreen-ui-f2qztv" data-lgid="lg-tabs"> <div class="leafygreen-ui-jp7pox" id="tabs-18"> <div aria-label="Tabs to describe usage of drivers" aria-orientation="horizontal" class="leafygreen-ui-m8p1vb lg-ui-tab-list-0000" data-lgid="lg-tabs-tab_list" role="tablist"> <button aria-controls="_rsjzlma7j" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_5gpb31ibr" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> MongoDB Shell </div> </button> <button aria-controls="_q08ho7exc" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_4vw3jpqfu" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Compass </div> </button> <button aria-controls="_9j7w548yt" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_3estq1d8b" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> C# </div> </button> <button aria-controls="_exbxy2i8c" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_64xkr98zv" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Go </div> </button> <button aria-controls="_b6ydovaet" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_9ofnt6fuv" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Java (Async) </div> </button> <button aria-controls="_n2wf93196" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_33an6gzgu" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Java (Sync) </div> </button> <button aria-controls="_g1kekdc5o" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_tmeuiai7o" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Motor </div> </button> <button aria-controls="_cw6zfp89y" aria-selected="true" class="leafygreen-ui-1l773z1" data-text="" id="_4ztzn91z5" name="" role="tab" tabindex="0"> <div class="leafygreen-ui-1nxuzmg"> Node.js </div> </button> <button aria-controls="_h9wvqeu8n" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_97vvv4r2a" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Perl </div> </button> <button aria-controls="_9w7oqzxj6" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_dzowv18v6" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> PHP </div> </button> <button aria-controls="_2wlqndf3e" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_fdr5p83k6" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Python </div> </button> <button aria-controls="_n77tnifka" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_eulmisegt" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Ruby </div> </button> <button aria-controls="_g0d8uekwu" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_6hpnnoowm" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Rust </div> </button> <button aria-controls="_ocn5phsg6" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_ofvw4y37c" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Scala </div> </button> </div> <div class="leafygreen-ui-ov1ktg"> <div class="leafygreen-ui-1sg2lsz"> </div> </div> </div> <div class="lg-ui-tab-panels-0000" data-lgid="lg-tabs-tab_panels"> <div> <div aria-labelledby="_5ue1p6ec4" class="leafygreen-ui-38lglc" id="_c751vc9fe" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"mongosh \"mongodb://mongos0.example.com:27017,mongos1.example.com:27017,mongos2.example.com:27017/?authSource=admin\" --apiVersion 1 --username myDatabaseUser","programmingLanguage":"Bash"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <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">mongosh <span class="lg-highlight-string">"mongodb://mongos0.example.com:27017,mongos1.example.com:27017,mongos2.example.com:27017/?authSource=admin"</span> --apiVersion <span class="lg-highlight-number">1</span> --username myDatabaseUser</td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-238-menu" aria-describedby="select-238-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-239" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:rko:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":rko:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rko:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rko:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_l6sapb1ga" class="leafygreen-ui-38lglc" id="_m57x75srz" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"mongodb://myDatabaseUser:D1fficultP%[email protected]:27017,mongos1.example.com:27017,mongos2.example.com:27017/?authSource=admin","programmingLanguage":"Bash"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <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"><!-- --><span class="lg-highlight-attr">mongodb</span>:<!-- --><span class="lg-highlight-comment">//myDatabaseUser:D1fficultP%[email protected]:27017,mongos1.example.com:27017,mongos2.example.com:27017/?authSource=admin</span></td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-241-menu" aria-describedby="select-241-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-242" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:rkp:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":rkp:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rkp:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rkp:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_5pk5shq5u" class="leafygreen-ui-38lglc" id="_9lv0gu5mk" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"mongodb://myDatabaseUser:D1fficultP%[email protected]:27017,mongos1.example.com:27017,mongos2.example.com:27017/?authSource=admin","programmingLanguage":"Bash"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <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"><!-- --><span class="lg-highlight-attr">mongodb</span>:<!-- --><span class="lg-highlight-comment">//myDatabaseUser:D1fficultP%[email protected]:27017,mongos1.example.com:27017,mongos2.example.com:27017/?authSource=admin</span></td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-244-menu" aria-describedby="select-244-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-245" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:rkq:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":rkq:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rkq:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rkq:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_fradzduw1" class="leafygreen-ui-38lglc" id="_8ly1fmz11" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"mongodb://myDatabaseUser:D1fficultP%[email protected]:27017,mongos1.example.com:27017,mongos2.example.com:27017/?authSource=admin","programmingLanguage":"Bash"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <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"><!-- --><span class="lg-highlight-attr">mongodb</span>:<!-- --><span class="lg-highlight-comment">//myDatabaseUser:D1fficultP%[email protected]:27017,mongos1.example.com:27017,mongos2.example.com:27017/?authSource=admin</span></td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-247-menu" aria-describedby="select-247-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-248" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:rkr:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":rkr:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rkr:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rkr:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_qeain9una" class="leafygreen-ui-38lglc" id="_x0inem4u0" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"mongodb://myDatabaseUser:D1fficultP%[email protected]:27017,mongos1.example.com:27017,mongos2.example.com:27017/?authSource=admin","programmingLanguage":"Bash"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <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"><!-- --><span class="lg-highlight-attr">mongodb</span>:<!-- --><span class="lg-highlight-comment">//myDatabaseUser:D1fficultP%[email protected]:27017,mongos1.example.com:27017,mongos2.example.com:27017/?authSource=admin</span></td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-250-menu" aria-describedby="select-250-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-251" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:rks:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":rks:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rks:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rks:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_ng88bgs7v" class="leafygreen-ui-38lglc" id="_3xxbeyxdo" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"mongodb://myDatabaseUser:D1fficultP%[email protected]:27017,mongos1.example.com:27017,mongos2.example.com:27017/?authSource=admin","programmingLanguage":"Bash"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <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"><!-- --><span class="lg-highlight-attr">mongodb</span>:<!-- --><span class="lg-highlight-comment">//myDatabaseUser:D1fficultP%[email protected]:27017,mongos1.example.com:27017,mongos2.example.com:27017/?authSource=admin</span></td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-253-menu" aria-describedby="select-253-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-254" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:rkt:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":rkt:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rkt:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rkt:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_ynyryzcxn" class="leafygreen-ui-38lglc" id="_6ctu22br8" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"mongodb://myDatabaseUser:D1fficultP%[email protected]:27017,mongos1.example.com:27017,mongos2.example.com:27017/?authSource=admin","programmingLanguage":"Bash"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <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"><!-- --><span class="lg-highlight-attr">mongodb</span>:<!-- --><span class="lg-highlight-comment">//myDatabaseUser:D1fficultP%[email protected]:27017,mongos1.example.com:27017,mongos2.example.com:27017/?authSource=admin</span></td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-256-menu" aria-describedby="select-256-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-257" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:rku:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":rku:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rku:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rku:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_3e59ln8aw" class="" id="_xbzqmvnud" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"mongodb://myDatabaseUser:D1fficultP%[email protected]:27017,mongos1.example.com:27017,mongos2.example.com:27017/?authSource=admin","programmingLanguage":"Bash"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <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"><!-- --><span class="lg-highlight-attr">mongodb</span>:<!-- --><span class="lg-highlight-comment">//myDatabaseUser:D1fficultP%[email protected]:27017,mongos1.example.com:27017,mongos2.example.com:27017/?authSource=admin</span></td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-259-menu" aria-describedby="select-259-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-260" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:rkv:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":rkv:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rkv:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rkv:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_z93g37a73" class="leafygreen-ui-38lglc" id="_i9ekljxb9" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"mongodb://myDatabaseUser:D1fficultP%[email protected]:27017,mongos1.example.com:27017,mongos2.example.com:27017/?authSource=admin","programmingLanguage":"Bash"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <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"><!-- --><span class="lg-highlight-attr">mongodb</span>:<!-- --><span class="lg-highlight-comment">//myDatabaseUser:D1fficultP%[email protected]:27017,mongos1.example.com:27017,mongos2.example.com:27017/?authSource=admin</span></td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-262-menu" aria-describedby="select-262-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-263" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:rl0:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":rl0:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rl0:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rl0:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_s08b6t225" class="leafygreen-ui-38lglc" id="_48vwkg0f3" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"mongodb://myDatabaseUser:D1fficultP%[email protected]:27017,mongos1.example.com:27017,mongos2.example.com:27017/?authSource=admin","programmingLanguage":"Bash"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <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"><!-- --><span class="lg-highlight-attr">mongodb</span>:<!-- --><span class="lg-highlight-comment">//myDatabaseUser:D1fficultP%[email protected]:27017,mongos1.example.com:27017,mongos2.example.com:27017/?authSource=admin</span></td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-265-menu" aria-describedby="select-265-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-266" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:rl1:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":rl1:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rl1:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rl1:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_dxjq00smm" class="leafygreen-ui-38lglc" id="_cx8fzzo06" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"mongodb://myDatabaseUser:D1fficultP%[email protected]:27017,mongos1.example.com:27017,mongos2.example.com:27017/?authSource=admin","programmingLanguage":"Bash"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <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"><!-- --><span class="lg-highlight-attr">mongodb</span>:<!-- --><span class="lg-highlight-comment">//myDatabaseUser:D1fficultP%[email protected]:27017,mongos1.example.com:27017,mongos2.example.com:27017/?authSource=admin</span></td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-268-menu" aria-describedby="select-268-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-269" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:rl2:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":rl2:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rl2:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rl2:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_ymg3fiuei" class="leafygreen-ui-38lglc" id="_q9ykxq01z" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"mongodb://myDatabaseUser:D1fficultP%[email protected]:27017,mongos1.example.com:27017,mongos2.example.com:27017/?authSource=admin","programmingLanguage":"Bash"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <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"><!-- --><span class="lg-highlight-attr">mongodb</span>:<!-- --><span class="lg-highlight-comment">//myDatabaseUser:D1fficultP%[email protected]:27017,mongos1.example.com:27017,mongos2.example.com:27017/?authSource=admin</span></td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-271-menu" aria-describedby="select-271-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-272" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:rl3:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":rl3:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rl3:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rl3:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_agbm20ir5" class="leafygreen-ui-38lglc" id="_leohtipp6" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"mongodb://myDatabaseUser:D1fficultP%[email protected]:27017,mongos1.example.com:27017,mongos2.example.com:27017/?authSource=admin","programmingLanguage":"Bash"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <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"><!-- --><span class="lg-highlight-attr">mongodb</span>:<!-- --><span class="lg-highlight-comment">//myDatabaseUser:D1fficultP%[email protected]:27017,mongos1.example.com:27017,mongos2.example.com:27017/?authSource=admin</span></td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-274-menu" aria-describedby="select-274-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-275" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:rl4:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":rl4:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rl4:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rl4:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_rcp4gk54f" class="leafygreen-ui-38lglc" id="_ehrnxs7c0" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"mongodb://myDatabaseUser:D1fficultP%[email protected]:27017,mongos1.example.com:27017,mongos2.example.com:27017/?authSource=admin","programmingLanguage":"Bash"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <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"><!-- --><span class="lg-highlight-attr">mongodb</span>:<!-- --><span class="lg-highlight-comment">//myDatabaseUser:D1fficultP%[email protected]:27017,mongos1.example.com:27017,mongos2.example.com:27017/?authSource=admin</span></td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-277-menu" aria-describedby="select-277-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-278" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:rl5:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":rl5:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rl5:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rl5:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> </div> </div> <p class="leafygreen-ui-1kp3ins"> If the username or password includes the following characters, those characters must be converted using <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://tools.ietf.org/html/rfc3986#section-2.1" rel="noopener noreferrer"> <span> percent encoding <!-- --> : </span> <svg alt="" aria-hidden="true" class="leafygreen-ui-1ie5kuq" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M13.823 2.4491C13.8201 2.30008 13.6999 2.17994 13.5509 2.17704L9.5062 2.09836C9.25654 2.09351 9.12821 2.39519 9.30482 2.5718L10.3856 3.65257L7.93433 6.10383C7.87964 6.15852 7.83047 6.21665 7.78683 6.27752L5.99909 8.06525C5.46457 8.59977 5.46457 9.4664 5.99909 10.0009C6.53361 10.5354 7.40023 10.5354 7.93475 10.0009L9.72249 8.21317C9.78336 8.16953 9.84148 8.12037 9.89618 8.06567L12.3474 5.61441L13.4282 6.69518C13.6048 6.87179 13.9065 6.74347 13.9016 6.4938L13.823 2.4491Z" fill="currentColor"> </path> <path d="M7.25 3.12893C7.66421 3.12893 8 3.46472 8 3.87893C8 4.29315 7.66421 4.62893 7.25 4.62893H4C3.72386 4.62893 3.5 4.85279 3.5 5.12893V11.9929C3.5 12.2691 3.72386 12.4929 4 12.4929H10.864C11.1401 12.4929 11.364 12.2691 11.364 11.9929V8.75C11.364 8.33579 11.6998 8 12.114 8C12.5282 8 12.864 8.33579 12.864 8.75V11.9929C12.864 13.0975 11.9686 13.9929 10.864 13.9929H4C2.89543 13.9929 2 13.0975 2 11.9929V5.12893C2 4.02436 2.89543 3.12893 4 3.12893H7.25Z" fill="currentColor"> </path> </svg> </a> </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"$ : / ? # [ ] @"} </script> <div class="css-1lju8ps"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1jheeh3"> <pre class="leafygreen-ui-1agdxuk" tabindex="-1"><code class="lg-highlight-hljs-light none leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">$ : / ? # [ ] @</td></tr></tbody></table></code></pre> </div> </div> </div> </div> </div> </div> <div> <div aria-labelledby="_fb3yqig8q" class="leafygreen-ui-38lglc" id="_1wgro1pj5" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <p class="leafygreen-ui-1kp3ins"> The following standalone connection string <a class="leafygreen-ui-tqgtui" href="/docs/manual/tutorial/enable-authentication/"> enforces access control <!-- --> : </a> </p> <div aria-hidden="true"> </div> <div class="leafygreen-ui-f2qztv" data-lgid="lg-tabs"> <div class="leafygreen-ui-jp7pox" id="tabs-19"> <div aria-label="Tabs to describe usage of drivers" aria-orientation="horizontal" class="leafygreen-ui-m8p1vb lg-ui-tab-list-0000" data-lgid="lg-tabs-tab_list" role="tablist"> <button aria-controls="_5ywcwsy84" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_gnout20k5" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> MongoDB Shell </div> </button> <button aria-controls="_wic5y0apq" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_2t8agaejh" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Compass </div> </button> <button aria-controls="_eoag58wo3" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_06089arya" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> C# </div> </button> <button aria-controls="_4fosqgj8k" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_5xr9wehvi" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Go </div> </button> <button aria-controls="_ugwjpo0e7" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_1ozn6j989" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Java (Async) </div> </button> <button aria-controls="_vluu2glxm" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_08d5gij95" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Java (Sync) </div> </button> <button aria-controls="_j340bislo" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_oxc77ohql" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Motor </div> </button> <button aria-controls="_4vi7zvz32" aria-selected="true" class="leafygreen-ui-1l773z1" data-text="" id="_z0ex8n4fc" name="" role="tab" tabindex="0"> <div class="leafygreen-ui-1nxuzmg"> Node.js </div> </button> <button aria-controls="_7lm49ja97" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_u9hbndql4" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Perl </div> </button> <button aria-controls="_162w4rvv6" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_d10ro6whr" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> PHP </div> </button> <button aria-controls="_sz7pvtinj" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_kk0f46k1d" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Python </div> </button> <button aria-controls="_iu9jox9ve" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_lkdibgl2h" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Ruby </div> </button> <button aria-controls="_kbzixqw00" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_ke9qfa8yg" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Rust </div> </button> <button aria-controls="_ll3mtjifv" aria-selected="false" class="leafygreen-ui-1ogxb8f" data-text="" id="_l5e69voc5" name="" role="tab" tabindex="-1"> <div class="leafygreen-ui-1nxuzmg"> Scala </div> </button> </div> <div class="leafygreen-ui-ov1ktg"> <div class="leafygreen-ui-1sg2lsz"> </div> </div> </div> <div class="lg-ui-tab-panels-0000" data-lgid="lg-tabs-tab_panels"> <div> <div aria-labelledby="_x5n7at64m" class="leafygreen-ui-38lglc" id="_qts8uycrb" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"mongosh \"mongodb://@mongodb0.example.com:27017/?authSource=admin\" --apiVersion 1 --username myDatabaseUser","programmingLanguage":"Bash"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <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">mongosh <span class="lg-highlight-string">"mongodb://@mongodb0.example.com:27017/?authSource=admin"</span> --apiVersion <span class="lg-highlight-number">1</span> --username myDatabaseUser</td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-280-menu" aria-describedby="select-280-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-281" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:rl6:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":rl6:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rl6:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rl6:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_4xepxzz3n" class="leafygreen-ui-38lglc" id="_1qa22bfn9" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"mongodb://myDatabaseUser:D1fficultP%[email protected]:27017/?authSource=admin","programmingLanguage":"Bash"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <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"><!-- --><span class="lg-highlight-attr">mongodb</span>:<!-- --><span class="lg-highlight-comment">//myDatabaseUser:D1fficultP%[email protected]:27017/?authSource=admin</span></td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-283-menu" aria-describedby="select-283-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-284" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:rl7:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":rl7:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rl7:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rl7:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_5qflq3404" class="leafygreen-ui-38lglc" id="_3i2nthfg8" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"mongodb://myDatabaseUser:D1fficultP%[email protected]:27017/?authSource=admin","programmingLanguage":"Bash"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <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"><!-- --><span class="lg-highlight-attr">mongodb</span>:<!-- --><span class="lg-highlight-comment">//myDatabaseUser:D1fficultP%[email protected]:27017/?authSource=admin</span></td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-286-menu" aria-describedby="select-286-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-287" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:rl8:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":rl8:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rl8:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rl8:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_w69h1wjjj" class="leafygreen-ui-38lglc" id="_enrk5asjb" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"mongodb://myDatabaseUser:D1fficultP%[email protected]:27017/?authSource=admin","programmingLanguage":"Bash"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <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"><!-- --><span class="lg-highlight-attr">mongodb</span>:<!-- --><span class="lg-highlight-comment">//myDatabaseUser:D1fficultP%[email protected]:27017/?authSource=admin</span></td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-289-menu" aria-describedby="select-289-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-290" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:rl9:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":rl9:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rl9:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rl9:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_pw4jt0yv5" class="leafygreen-ui-38lglc" id="_afm63e8zy" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"mongodb://myDatabaseUser:D1fficultP%[email protected]:27017/?authSource=admin","programmingLanguage":"Bash"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <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"><!-- --><span class="lg-highlight-attr">mongodb</span>:<!-- --><span class="lg-highlight-comment">//myDatabaseUser:D1fficultP%[email protected]:27017/?authSource=admin</span></td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-292-menu" aria-describedby="select-292-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-293" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:rla:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":rla:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rla:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rla:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_zwzy529nv" class="leafygreen-ui-38lglc" id="_bwysiwnad" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"mongodb://myDatabaseUser:D1fficultP%[email protected]:27017/?authSource=admin","programmingLanguage":"Bash"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <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"><!-- --><span class="lg-highlight-attr">mongodb</span>:<!-- --><span class="lg-highlight-comment">//myDatabaseUser:D1fficultP%[email protected]:27017/?authSource=admin</span></td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-295-menu" aria-describedby="select-295-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-296" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:rlb:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":rlb:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rlb:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rlb:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_tpnqgthrq" class="leafygreen-ui-38lglc" id="_bveeefzrn" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"mongodb://myDatabaseUser:D1fficultP%[email protected]:27017/?authSource=admin","programmingLanguage":"Bash"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <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"><!-- --><span class="lg-highlight-attr">mongodb</span>:<!-- --><span class="lg-highlight-comment">//myDatabaseUser:D1fficultP%[email protected]:27017/?authSource=admin</span></td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-298-menu" aria-describedby="select-298-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-299" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:rlc:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":rlc:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rlc:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rlc:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_4cibevarj" class="" id="_d2in1hdqd" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"mongodb://myDatabaseUser:D1fficultP%[email protected]:27017/?authSource=admin","programmingLanguage":"Bash"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <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"><!-- --><span class="lg-highlight-attr">mongodb</span>:<!-- --><span class="lg-highlight-comment">//myDatabaseUser:D1fficultP%[email protected]:27017/?authSource=admin</span></td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-301-menu" aria-describedby="select-301-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-302" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:rld:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":rld:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rld:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rld:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_zwrybt033" class="leafygreen-ui-38lglc" id="_rr5cg011s" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"mongodb://myDatabaseUser:D1fficultP%[email protected]:27017/?authSource=admin","programmingLanguage":"Bash"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <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"><!-- --><span class="lg-highlight-attr">mongodb</span>:<!-- --><span class="lg-highlight-comment">//myDatabaseUser:D1fficultP%[email protected]:27017/?authSource=admin</span></td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-304-menu" aria-describedby="select-304-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-305" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:rle:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":rle:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rle:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rle:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_14ax3bq4f" class="leafygreen-ui-38lglc" id="_4rw0ll1i8" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"mongodb://myDatabaseUser:D1fficultP%[email protected]:27017/?authSource=admin","programmingLanguage":"Bash"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <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"><!-- --><span class="lg-highlight-attr">mongodb</span>:<!-- --><span class="lg-highlight-comment">//myDatabaseUser:D1fficultP%[email protected]:27017/?authSource=admin</span></td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-307-menu" aria-describedby="select-307-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-308" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:rlf:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":rlf:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rlf:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rlf:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_1aqgavso5" class="leafygreen-ui-38lglc" id="_nimg6proz" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"mongodb://myDatabaseUser:D1fficultP%[email protected]:27017/?authSource=admin","programmingLanguage":"Bash"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <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"><!-- --><span class="lg-highlight-attr">mongodb</span>:<!-- --><span class="lg-highlight-comment">//myDatabaseUser:D1fficultP%[email protected]:27017/?authSource=admin</span></td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-310-menu" aria-describedby="select-310-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-311" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:rlg:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":rlg:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rlg:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rlg:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_5ix3eccle" class="leafygreen-ui-38lglc" id="_08n0qfrcn" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"mongodb://myDatabaseUser:D1fficultP%[email protected]:27017/?authSource=admin","programmingLanguage":"Bash"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <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"><!-- --><span class="lg-highlight-attr">mongodb</span>:<!-- --><span class="lg-highlight-comment">//myDatabaseUser:D1fficultP%[email protected]:27017/?authSource=admin</span></td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-313-menu" aria-describedby="select-313-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-314" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:rlh:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":rlh:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rlh:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rlh:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_6a1gt8vjc" class="leafygreen-ui-38lglc" id="_tijeu4tun" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"mongodb://myDatabaseUser:D1fficultP%[email protected]:27017/?authSource=admin","programmingLanguage":"Bash"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <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"><!-- --><span class="lg-highlight-attr">mongodb</span>:<!-- --><span class="lg-highlight-comment">//myDatabaseUser:D1fficultP%[email protected]:27017/?authSource=admin</span></td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-316-menu" aria-describedby="select-316-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-317" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:rli:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":rli:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rli:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rli:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> <div> <div aria-labelledby="_ws9e74stt" class="leafygreen-ui-38lglc" id="_23d3qhfpy" role="tabpanel"> <div class="leafygreen-ui-1kdmo88"> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"mongodb://myDatabaseUser:D1fficultP%[email protected]:27017/?authSource=admin","programmingLanguage":"Bash"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-9lvdmr"> <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"><!-- --><span class="lg-highlight-attr">mongodb</span>:<!-- --><span class="lg-highlight-comment">//myDatabaseUser:D1fficultP%[email protected]:27017/?authSource=admin</span></td></tr></tbody></table></code></pre> <div class="leafygreen-ui-hcrzu6" data-testid="leafygreen-code-panel"> <div class="leafygreen-ui-148abs6"> <div class="leafygreen-ui-omjz13" data-lgid="lg-select"> <button aria-controls="select-319-menu" aria-describedby="select-319-description" aria-disabled="false" aria-expanded="false" aria-invalid="false" aria-labelledby="Language Picker" class="lg-ui-button-0000 leafygreen-ui-dvfj9v" data-lgid="lg-button" data-testid="leafygreen-ui-select-menubutton" id="select-320" type="button" value="Node.js"> <div class="leafygreen-ui-v038xi"> </div> <div class="leafygreen-ui-16tr4y"> <svg aria-hidden="true" class="leafygreen-ui-18si895" fill="none" role="presentation" viewbox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0_2131_12968)"> <mask height="19" id="mask0_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask0_2131_12968)"> <mask height="19" id="mask1_2131_12968" maskunits="userSpaceOnUse" width="30" x="0" y="6"> <path d="M30 6.04395H0V24.3825H30V6.04395Z" fill="white"> </path> </mask> <g mask="url(#mask1_2131_12968)"> <path d="M14.8241 24.3823C14.7224 24.3823 14.6274 24.3552 14.5393 24.3078L13.6374 23.7731C13.5018 23.6986 13.5696 23.6715 13.6103 23.658C13.7934 23.597 13.8273 23.5835 14.0172 23.4751C14.0375 23.4616 14.0646 23.4684 14.085 23.4819L14.7767 23.8949C14.8038 23.9084 14.8377 23.9084 14.858 23.8949L17.5637 22.3311C17.5909 22.3176 17.6044 22.2905 17.6044 22.2567V19.136C17.6044 19.1021 17.5909 19.075 17.5637 19.0615L14.858 17.5045C14.8309 17.4909 14.797 17.4909 14.7767 17.5045L12.071 19.0615C12.0439 19.075 12.0302 19.1089 12.0302 19.136V22.2567C12.0302 22.2838 12.0439 22.3176 12.071 22.3311L12.8101 22.7576C13.2102 22.9607 13.4611 22.7237 13.4611 22.4868V19.4067C13.4611 19.3661 13.495 19.3255 13.5425 19.3255H13.8884C13.929 19.3255 13.9697 19.3593 13.9697 19.4067V22.4868C13.9697 23.0217 13.6781 23.333 13.1695 23.333C13.0136 23.333 12.8915 23.333 12.5457 23.1638L11.8336 22.7576C11.6574 22.6561 11.5488 22.4665 11.5488 22.2635V19.1427C11.5488 18.9396 11.6574 18.7501 11.8336 18.6485L14.5393 17.0848C14.7089 16.99 14.9394 16.99 15.109 17.0848L17.8146 18.6485C17.9909 18.7501 18.0995 18.9396 18.0995 19.1427V22.2635C18.0995 22.4665 17.9909 22.6561 17.8146 22.7576L15.109 24.3214C15.0276 24.3552 14.9259 24.3823 14.8241 24.3823Z" fill="black"> </path> <path d="M15.6643 22.2362C14.4775 22.2362 14.2334 21.6946 14.2334 21.2343C14.2334 21.1936 14.2673 21.153 14.3147 21.153H14.6674C14.7081 21.153 14.742 21.1801 14.742 21.2207C14.7963 21.5795 14.9522 21.7555 15.671 21.7555C16.2407 21.7555 16.4847 21.6269 16.4847 21.3223C16.4847 21.1462 16.4169 21.0177 15.5286 20.9297C14.7895 20.8552 14.3284 20.6928 14.3284 20.1038C14.3284 19.5555 14.7895 19.2305 15.5625 19.2305C16.4305 19.2305 16.8577 19.5284 16.912 20.1782C16.912 20.1986 16.9052 20.2189 16.8916 20.2392C16.8781 20.2527 16.8577 20.2663 16.8374 20.2663H16.4779C16.4441 20.2663 16.4101 20.2392 16.4034 20.2053C16.322 19.833 16.1118 19.7111 15.5557 19.7111C14.9319 19.7111 14.8573 19.9278 14.8573 20.0902C14.8573 20.2866 14.9454 20.3475 15.7863 20.4558C16.6204 20.5641 17.0137 20.7198 17.0137 21.302C17.0137 21.8977 16.5187 22.2362 15.6643 22.2362Z" fill="black"> </path> <path d="M19.5706 18.9597C19.5706 19.244 19.3333 19.481 19.0485 19.481C18.7636 19.481 18.5264 19.2507 18.5264 18.9597C18.5264 18.6618 18.7704 18.4385 19.0485 18.4385C19.3265 18.4385 19.5706 18.6686 19.5706 18.9597ZM18.6077 18.9597C18.6077 19.2034 18.8044 19.3997 19.0417 19.3997C19.2859 19.3997 19.4825 19.1967 19.4825 18.9597C19.4825 18.716 19.2859 18.5264 19.0417 18.5264C18.8111 18.5264 18.6077 18.716 18.6077 18.9597ZM18.8519 18.6686H19.0553C19.1231 18.6686 19.2587 18.6686 19.2587 18.8243C19.2587 18.9326 19.1909 18.9529 19.1502 18.9664C19.2316 18.9732 19.2384 19.0274 19.2451 19.1019C19.2519 19.1493 19.2587 19.2304 19.2722 19.2575H19.1502C19.1502 19.2304 19.1298 19.0815 19.1298 19.0748C19.1231 19.0409 19.1095 19.0274 19.0688 19.0274H18.9672V19.2643H18.8519V18.6686ZM18.9603 18.9258H19.0485C19.1231 18.9258 19.1366 18.8716 19.1366 18.8446C19.1366 18.7634 19.0824 18.7634 19.0485 18.7634H18.9535V18.9258H18.9603Z" fill="black"> </path> <path clip-rule="evenodd" d="M6.43536 12.1766C6.43536 12.0548 6.36754 11.9397 6.25904 11.8788L3.39059 10.2202C3.34313 10.1932 3.28887 10.1796 3.23463 10.1729C3.22785 10.1729 3.20751 10.1729 3.20751 10.1729C3.15325 10.1729 3.09901 10.1932 3.05154 10.2202L0.176311 11.872C0.067812 11.9329 0 12.048 0 12.1766L0.00678119 16.6174C0.00678119 16.6783 0.0406871 16.7393 0.0949364 16.7663C0.149187 16.8002 0.216998 16.8002 0.264466 16.7663L1.97332 15.7915C2.08183 15.7306 2.14964 15.6155 2.14964 15.4936V13.4154C2.14964 13.2936 2.21745 13.1785 2.32595 13.1176L3.05154 12.6979C3.10579 12.664 3.16682 12.6505 3.22785 12.6505C3.28887 12.6505 3.34991 12.664 3.39738 12.6979L4.12297 13.1176C4.23147 13.1785 4.29927 13.2936 4.29927 13.4154V15.4936C4.29927 15.6155 4.36709 15.7306 4.47559 15.7915L6.17089 16.7663C6.22513 16.8002 6.29295 16.8002 6.3472 16.7663C6.40144 16.7393 6.43536 16.6783 6.43536 16.6174V12.1766Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M20.2551 6.06425C20.201 6.03718 20.1332 6.03718 20.0857 6.06425C20.0314 6.0981 19.9975 6.15226 19.9975 6.21318V10.6133C19.9975 10.654 19.9771 10.6946 19.9364 10.7217C19.8958 10.742 19.8551 10.742 19.8144 10.7217L19.0956 10.3087C18.9871 10.2478 18.8582 10.2478 18.7498 10.3087L15.8746 11.9673C15.766 12.0282 15.6982 12.1433 15.6982 12.2651V15.5754C15.6982 15.6973 15.766 15.8123 15.8746 15.8732L18.7498 17.5318C18.8582 17.5927 18.9871 17.5927 19.0956 17.5318L21.9708 15.8732C22.0793 15.8123 22.1471 15.6973 22.1471 15.5754V7.32338C22.1471 7.19476 22.0793 7.07968 21.9708 7.01875L20.2551 6.06425ZM19.9907 14.4855C19.9907 14.5194 19.9771 14.5464 19.9501 14.56L18.9667 15.1286C18.9397 15.1421 18.9057 15.1421 18.8786 15.1286L17.8953 14.56C17.8682 14.5464 17.8547 14.5126 17.8547 14.4855V13.3482C17.8547 13.3144 17.8682 13.2873 17.8953 13.2738L18.8786 12.7051C18.9057 12.6916 18.9397 12.6916 18.9667 12.7051L19.9501 13.2738C19.9771 13.2873 19.9907 13.3212 19.9907 13.3482V14.4855Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M29.8235 13.3214C29.932 13.2605 29.9931 13.1454 29.9931 13.0235V12.218C29.9931 12.0961 29.9253 11.981 29.8235 11.9201L26.9687 10.2683C26.8602 10.2074 26.7314 10.2074 26.6228 10.2683L23.7476 11.9269C23.6391 11.9878 23.5713 12.1029 23.5713 12.2247V15.535C23.5713 15.6569 23.6391 15.772 23.7476 15.8328L26.6025 17.4575C26.7109 17.5185 26.8398 17.5185 26.9415 17.4575L28.6707 16.4963C28.725 16.4692 28.7589 16.4083 28.7589 16.3474C28.7589 16.2864 28.725 16.2255 28.6707 16.1984L25.782 14.5399C25.7277 14.506 25.6938 14.4519 25.6938 14.391V13.3552C25.6938 13.2943 25.7277 13.2334 25.782 13.2063L26.6839 12.6918C26.7381 12.658 26.8059 12.658 26.8602 12.6918L27.7621 13.2063C27.8163 13.2402 27.8502 13.2943 27.8502 13.3552V14.1676C27.8502 14.2285 27.8841 14.2894 27.9384 14.3165C27.9927 14.3504 28.0605 14.3504 28.1147 14.3165L29.8235 13.3214Z" fill="black" fill-rule="evenodd"> </path> <path clip-rule="evenodd" d="M26.7521 13.1654C26.7724 13.1519 26.7996 13.1519 26.8199 13.1654L27.3692 13.4836C27.3895 13.4971 27.4031 13.5174 27.4031 13.5445V14.1809C27.4031 14.2079 27.3895 14.2282 27.3692 14.2418L26.8199 14.5599C26.7996 14.5735 26.7724 14.5735 26.7521 14.5599L26.2028 14.2418C26.1825 14.2282 26.1689 14.2079 26.1689 14.1809V13.5445C26.1689 13.5174 26.1825 13.4971 26.2028 13.4836L26.7521 13.1654Z" fill="#5FA04E" fill-rule="evenodd"> </path> <path d="M11.2331 10.2292C11.1227 10.1671 10.9917 10.1671 10.8814 10.2292L7.97807 11.9053C7.86772 11.9673 7.80566 12.0846 7.80566 12.2088V15.5679C7.80566 15.692 7.87462 15.8092 7.97807 15.8714L10.8814 17.5474C10.9917 17.6095 11.1227 17.6095 11.2331 17.5474L14.1364 15.8714C14.2467 15.8092 14.3088 15.692 14.3088 15.5679V12.2088C14.3088 12.0846 14.2398 11.9673 14.1364 11.9053L11.2331 10.2292Z" fill="black"> </path> <path d="M14.1432 11.9059L11.2261 10.2298C11.1985 10.216 11.164 10.2022 11.1365 10.1953L7.875 15.7825C7.90258 15.817 7.94609 15.8673 7.98056 15.888L10.8813 17.548C10.9641 17.5963 11.0606 17.6101 11.1503 17.5825L14.219 11.968C14.1983 11.9404 14.1708 11.9197 14.1432 11.9059Z" fill="black"> </path> <path d="M14.136 15.8715C14.2187 15.8231 14.2933 15.7327 14.2933 15.6236L11.1154 10.1879C11.0326 10.1741 10.943 10.181 10.8671 10.2293L7.9707 11.8985L11.0947 17.5958C11.1361 17.5889 11.1843 17.5751 11.2257 17.5544L14.136 15.8715Z" fill="url(#:rlj:paint2)"> </path> </g> </g> </g> <defs> <lineargradient gradientunits="userSpaceOnUse" id=":rlj:paint0" x1="12.2396" x2="9.61385" y1="11.4775" y2="16.8331"> <stop stop-color="#3F873F"> </stop> <stop offset="0.3296" stop-color="#3F8B3D"> </stop> <stop offset="0.6367" stop-color="#3E9638"> </stop> <stop offset="0.9341" stop-color="#3DA92E"> </stop> <stop offset="1" stop-color="#3DAE2B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rlj:paint1" x1="10.6159" x2="17.9826" y1="14.2811" y2="8.83932"> <stop offset="0.1376" stop-color="#3F873F"> </stop> <stop offset="0.4016" stop-color="#52A044"> </stop> <stop offset="0.7129" stop-color="#64B749"> </stop> <stop offset="0.9081" stop-color="#6ABF4B"> </stop> </lineargradient> <lineargradient gradientunits="userSpaceOnUse" id=":rlj:paint2" x1="7.69907" x2="14.4172" y1="13.8874" y2="13.8874"> <stop offset="0.0919165" stop-color="#6ABF4B"> </stop> <stop offset="0.2871" stop-color="#64B749"> </stop> <stop offset="0.5984" stop-color="#52A044"> </stop> <stop offset="0.8624" stop-color="#3F873F"> </stop> </lineargradient> <clippath id="clip0_2131_12968"> <rect fill="white" height="18.427" transform="translate(0 6)" width="30"> </rect> </clippath> </defs> </svg> <div class="leafygreen-ui-obh8q1"> <div class="lg-ui-select-menu-0000 leafygreen-ui-17aj16e" data-lgid="lg-select-button_text"> Node.js </div> </div> <svg alt="" aria-hidden="true" class="leafygreen-ui-fn50nl" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M8.67903 10.7962C8.45271 11.0679 8.04729 11.0679 7.82097 10.7962L4.63962 6.97649C4.3213 6.59428 4.5824 6 5.06866 6L11.4313 6C11.9176 6 12.1787 6.59428 11.8604 6.97649L8.67903 10.7962Z" fill="currentColor"> </path> </svg> </div> </button> <div aria-live="polite" aria-relevant="all" class="leafygreen-ui-11ydt2g" data-lgid="lg-form_field-feedback" data-testid="lg-form_field-feedback"> </div> </div> </div> <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> </div> </div> </div> </div> <p class="leafygreen-ui-1kp3ins"> If the username or password includes the following characters, those characters must be converted using <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://tools.ietf.org/html/rfc3986#section-2.1" rel="noopener noreferrer"> <span> percent encoding <!-- --> : </span> <svg alt="" aria-hidden="true" class="leafygreen-ui-1ie5kuq" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M13.823 2.4491C13.8201 2.30008 13.6999 2.17994 13.5509 2.17704L9.5062 2.09836C9.25654 2.09351 9.12821 2.39519 9.30482 2.5718L10.3856 3.65257L7.93433 6.10383C7.87964 6.15852 7.83047 6.21665 7.78683 6.27752L5.99909 8.06525C5.46457 8.59977 5.46457 9.4664 5.99909 10.0009C6.53361 10.5354 7.40023 10.5354 7.93475 10.0009L9.72249 8.21317C9.78336 8.16953 9.84148 8.12037 9.89618 8.06567L12.3474 5.61441L13.4282 6.69518C13.6048 6.87179 13.9065 6.74347 13.9016 6.4938L13.823 2.4491Z" fill="currentColor"> </path> <path d="M7.25 3.12893C7.66421 3.12893 8 3.46472 8 3.87893C8 4.29315 7.66421 4.62893 7.25 4.62893H4C3.72386 4.62893 3.5 4.85279 3.5 5.12893V11.9929C3.5 12.2691 3.72386 12.4929 4 12.4929H10.864C11.1401 12.4929 11.364 12.2691 11.364 11.9929V8.75C11.364 8.33579 11.6998 8 12.114 8C12.5282 8 12.864 8.33579 12.864 8.75V11.9929C12.864 13.0975 11.9686 13.9929 10.864 13.9929H4C2.89543 13.9929 2 13.0975 2 11.9929V5.12893C2 4.02436 2.89543 3.12893 4 3.12893H7.25Z" fill="currentColor"> </path> </svg> </a> </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"$ : / ? # [ ] @"} </script> <div class="css-1lju8ps"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1jheeh3"> <pre class="leafygreen-ui-1agdxuk" tabindex="-1"><code class="lg-highlight-hljs-light none leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">$ : / ? # [ ] @</td></tr></tbody></table></code></pre> </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> <p class="leafygreen-ui-1kp3ins"> For a full list of connection string options, see <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-connections-dns-seedlist" target="_self"> <span> SRV Connection Format </span> </a> or <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-connections-standard-connection-string-format" target="_self"> <span> Standard Connection String Format </span> </a> . For more examples, see <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/connection-string-examples/#std-label-connections-connection-examples"> Connection String Examples <!-- --> . </a> </p> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Connection String Formats <a class="headerlink leafygreen-ui-1kepx47" href="#connection-string-formats" 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="connection-string-formats"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> You can specify the MongoDB connection string by using one of the following formats: </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="#std-label-connections-dns-seedlist" target="_self"> <span> SRV Connection Format </span> </a> : A connection string with a hostname that corresponds to a DNS SRV record. Your driver or <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/mongodb-shell/#mongodb-binary-bin.mongosh" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongosh </code> </span> </a> queries the record to determine which hosts are running the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> or <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongos/#mongodb-binary-bin.mongos"> <code class="leafygreen-ui-1l06pbn"> mongos </code> </a> instances. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-connections-standard-connection-string-format" target="_self"> <span> Standard Connection String Format </span> </a> : A connection string that specifies all hosts that are running the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> or <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongos/#mongodb-binary-bin.mongos"> <code class="leafygreen-ui-1l06pbn"> mongos </code> </a> instances. </p> </li> </ul> <p class="leafygreen-ui-1kp3ins"> MongoDB Atlas clusters use <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-connections-dns-seedlist" target="_self"> <span> SRV connection format </span> </a> unless you connect to an <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/atlas/online-archive/manage-online-archive/" target="_self"> <span> online archive <!-- --> . </span> </a> </p> <span class="leafygreen-ui-1qnjd6d" id="std-label-connections-dns-seedlist"> </span> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> SRV Connection Format <a class="headerlink leafygreen-ui-1kepx47" href="#srv-connection-format" 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="srv-connection-format"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> MongoDB supports a <span class="leafygreen-ui-vm4wms" tabindex="0"> DNS </span> -constructed <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-seed-list"> seed list </a> . Using DNS to construct the available servers list allows more flexibility of deployment and the ability to change the servers in rotation without reconfiguring clients. </p> <p class="leafygreen-ui-1kp3ins"> The SRV URI connection scheme has the following form: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"mongodb+srv://[username:password@]host[/[defaultauthdb][?options]]"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-1q4bxgx" tabindex="0"><code class="lg-highlight-hljs-light none leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">mongodb+srv://[username:password@]host[/[defaultauthdb][?options]]</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"> For more examples, see <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/connection-string-examples/#std-label-connections-connection-examples"> Connection String Examples <!-- --> . </a> </p> <section> <h4 class="contains-headerlink leafygreen-ui-1vzlt5f"> Connection String Components <a class="headerlink leafygreen-ui-1kepx47" href="#connection-string-components" 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="connection-string-components"> </div> </a> </h4> <p class="leafygreen-ui-1kp3ins"> A connection string includes the following components: </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> Component </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> <code class="leafygreen-ui-1l06pbn"> mongodb:// </code> or <code class="leafygreen-ui-1l06pbn"> mongodb+srv:// </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> A required prefix to identify that this is a string in the standard connection format ( <code class="leafygreen-ui-1l06pbn"> mongodb:// </code> ) or SRV connection format ( <code class="leafygreen-ui-1l06pbn"> mongodb+srv:// </code> ). To learn more about each format, see <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-connections-standard-connection-string-format" target="_self"> <span> Standard Connection String Format </span> </a> and <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-connections-dns-seedlist" target="_self"> <span> SRV Connection Format <!-- --> . </span> </a> </div> </div> </td> </tr> <tr class="leafygreen-ui-15dvrnp"> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> username:password@ </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <p class="leafygreen-ui-1kp3ins"> Optional. Authentication credentials. </p> <p class="leafygreen-ui-1kp3ins"> If specified, the client will attempt to authenticate the user to the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/connection-string-options/#mongodb-urioption-urioption.authSource"> <code class="leafygreen-ui-1l06pbn"> authSource </code> </a> . If <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/connection-string-options/#mongodb-urioption-urioption.authSource"> <code class="leafygreen-ui-1l06pbn"> authSource </code> </a> is unspecified, the client will attempt to authenticate the user to the <code class="leafygreen-ui-1l06pbn"> defaultauthdb </code> . And if the <code class="leafygreen-ui-1l06pbn"> defaultauthdb </code> is unspecified, to the <code class="leafygreen-ui-1l06pbn"> admin </code> database. </p> <p class="leafygreen-ui-1kp3ins"> If the username or password includes the following characters, those characters must be converted using <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://tools.ietf.org/html/rfc3986#section-2.1" rel="noopener noreferrer"> <span> percent encoding <!-- --> : </span> <svg alt="" aria-hidden="true" class="leafygreen-ui-1ie5kuq" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M13.823 2.4491C13.8201 2.30008 13.6999 2.17994 13.5509 2.17704L9.5062 2.09836C9.25654 2.09351 9.12821 2.39519 9.30482 2.5718L10.3856 3.65257L7.93433 6.10383C7.87964 6.15852 7.83047 6.21665 7.78683 6.27752L5.99909 8.06525C5.46457 8.59977 5.46457 9.4664 5.99909 10.0009C6.53361 10.5354 7.40023 10.5354 7.93475 10.0009L9.72249 8.21317C9.78336 8.16953 9.84148 8.12037 9.89618 8.06567L12.3474 5.61441L13.4282 6.69518C13.6048 6.87179 13.9065 6.74347 13.9016 6.4938L13.823 2.4491Z" fill="currentColor"> </path> <path d="M7.25 3.12893C7.66421 3.12893 8 3.46472 8 3.87893C8 4.29315 7.66421 4.62893 7.25 4.62893H4C3.72386 4.62893 3.5 4.85279 3.5 5.12893V11.9929C3.5 12.2691 3.72386 12.4929 4 12.4929H10.864C11.1401 12.4929 11.364 12.2691 11.364 11.9929V8.75C11.364 8.33579 11.6998 8 12.114 8C12.5282 8 12.864 8.33579 12.864 8.75V11.9929C12.864 13.0975 11.9686 13.9929 10.864 13.9929H4C2.89543 13.9929 2 13.0975 2 11.9929V5.12893C2 4.02436 2.89543 3.12893 4 3.12893H7.25Z" fill="currentColor"> </path> </svg> </a> </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"$ : / ? # [ ] @"} </script> <div class="css-1lju8ps"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1jheeh3"> <pre class="leafygreen-ui-1agdxuk" tabindex="-1"><code class="lg-highlight-hljs-light none leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">$ : / ? # [ ] @</td></tr></tbody></table></code></pre> </div> </div> </div> <p class="leafygreen-ui-1kp3ins"> See also <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/connection-string-options/#mongodb-urioption-urioption.authSource"> <code class="leafygreen-ui-1l06pbn"> authSource </code> . </a> </p> </div> </div> </td> </tr> <tr class="leafygreen-ui-15dvrnp"> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> host[:port] </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <p class="leafygreen-ui-1kp3ins"> The host (and optional port number) where the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> instance (or <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongos/#mongodb-binary-bin.mongos"> <code class="leafygreen-ui-1l06pbn"> mongos </code> </a> instance for a sharded cluster) is running. You can specify a hostname, IP address, or UNIX domain socket. Specify as many hosts as appropriate for your deployment topology: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> For a standalone, specify the hostname of the standalone <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> instance. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> For a replica set, specify the hostname(s) of the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> instance(s) as listed in the replica set configuration. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> For a sharded cluster, specify the hostname(s) of the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongos/#mongodb-binary-bin.mongos"> <code class="leafygreen-ui-1l06pbn"> mongos </code> </a> instance(s). </p> </li> </ul> <p class="leafygreen-ui-1kp3ins"> If the port number is not specified, the default port <code class="leafygreen-ui-1l06pbn"> 27017 </code> is used. </p> <p class="leafygreen-ui-1kp3ins"> If you use the SRV URI connection format, you can specify only one host and no port. Otherwise, the driver or <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/mongodb-shell/#mongodb-binary-bin.mongosh" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongosh </code> </span> </a> raises a parse error and does not perform DNS resolution. </p> </div> </div> </td> </tr> <tr class="leafygreen-ui-15dvrnp"> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> /defaultauthdb </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <p class="leafygreen-ui-1kp3ins"> Optional. The authentication database to use if the connection string includes <code class="leafygreen-ui-1l06pbn"> username:password@ </code> authentication credentials but the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/connection-string-options/#mongodb-urioption-urioption.authSource"> <code class="leafygreen-ui-1l06pbn"> authSource </code> </a> option is unspecified. </p> <p class="leafygreen-ui-1kp3ins"> If both <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/connection-string-options/#mongodb-urioption-urioption.authSource"> <code class="leafygreen-ui-1l06pbn"> authSource </code> </a> and <code class="leafygreen-ui-1l06pbn"> defaultauthdb </code> are unspecified, the client will attempt to authenticate the specified user to the <code class="leafygreen-ui-1l06pbn"> admin </code> database. </p> </div> </div> </td> </tr> <tr class="leafygreen-ui-15dvrnp"> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> ?&lt;options&gt; </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <p class="leafygreen-ui-1kp3ins"> Optional. A query string that specifies connection specific options as <code class="leafygreen-ui-1l06pbn"> &lt;name&gt;=&lt;value&gt; </code> pairs. See <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/connection-string-options/#std-label-connections-connection-options"> Connection String Options </a> for a full description of these options. </p> <p class="leafygreen-ui-1kp3ins"> If the connection string does not specify a database/ you must specify a slash ( <code class="leafygreen-ui-1l06pbn"> / </code> ) between the last <code class="leafygreen-ui-1l06pbn"> host </code> and the question mark ( <code class="leafygreen-ui-1l06pbn"> ? </code> ) that begins the string of options. </p> </div> </div> </td> </tr> </tbody> </table> </div> </section> <p class="leafygreen-ui-1kp3ins"> In order to leverage the DNS seed list, use the same syntax as a <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-connections-standard-connection-string-format" target="_self"> <span> standard connection string </span> </a> with a prefix of <code class="leafygreen-ui-1l06pbn"> mongodb+srv </code> rather than the standard <code class="leafygreen-ui-1l06pbn"> mongodb </code> . The <code class="leafygreen-ui-1l06pbn"> +srv </code> indicates to the client that the hostname that follows corresponds to a DNS SRV record. The driver or <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/mongodb-shell/#mongodb-binary-bin.mongosh" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongosh </code> </span> </a> will then query the DNS for the record to determine which hosts are running the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> or <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongos/#mongodb-binary-bin.mongos"> <code class="leafygreen-ui-1l06pbn"> mongos </code> </a> instances. </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"> Use of the <code class="leafygreen-ui-1l06pbn"> +srv </code> connection string modifier automatically sets the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/connection-string-options/#mongodb-urioption-urioption.tls"> <code class="leafygreen-ui-1l06pbn"> tls </code> </a> (or the equivalent <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/connection-string-options/#mongodb-urioption-urioption.ssl"> <code class="leafygreen-ui-1l06pbn"> ssl </code> </a> ) option to <code class="leafygreen-ui-1l06pbn"> true </code> for the connection. You can override this behavior by explicitly setting the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/connection-string-options/#mongodb-urioption-urioption.tls"> <code class="leafygreen-ui-1l06pbn"> tls </code> </a> (or the equivalent <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/connection-string-options/#mongodb-urioption-urioption.ssl"> <code class="leafygreen-ui-1l06pbn"> ssl </code> </a> ) option to <code class="leafygreen-ui-1l06pbn"> false </code> with <code class="leafygreen-ui-1l06pbn"> tls=false </code> (or <code class="leafygreen-ui-1l06pbn"> ssl=false </code> ) in the query string. </p> </div> </div> <p class="leafygreen-ui-1kp3ins"> When using the <code class="leafygreen-ui-1l06pbn"> +srv </code> format, you must specify the <code class="leafygreen-ui-1l06pbn"> hostname </code> , <code class="leafygreen-ui-1l06pbn"> domain </code> , and <code class="leafygreen-ui-1l06pbn"> top-level domain (TLD) </code> in the following format: <code class="leafygreen-ui-1l06pbn"> &lt;hostname&gt;.&lt;domain&gt;.&lt;TLD&gt;. </code> This table shows how the placeholders correspond to example values: </p> <div class="leafygreen-ui-skkc39" tabindex="0"> <table class="leafygreen-ui-hr8lsv"> <colgroup> <col style="width:50%"/> <col style="width:50%"/> </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> Placeholder </div> </div> </th> <th class="leafygreen-ui-13uteka" role="columnheader" scope="col"> <div class="leafygreen-ui-ui0te9"> <div> Example </div> </div> </th> </tr> </thead> <tbody> <tr class=""> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> &lt;hostname&gt; </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> server </code> </div> </div> </td> </tr> <tr class=""> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> &lt;domain&gt; </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> example </code> </div> </div> </td> </tr> <tr class=""> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> &lt;TLD&gt; </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> com </code> </div> </div> </td> </tr> <tr class=""> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> &lt;hostname&gt;.&lt;domain&gt;.&lt;TLD&gt; </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> server.example.com </code> </div> </div> </td> </tr> </tbody> </table> </div> <p class="leafygreen-ui-1kp3ins"> This example shows a DNS <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-seed-list"> seed list </a> connection string that correctly uses the <code class="leafygreen-ui-1l06pbn"> &lt;hostname&gt;.&lt;domain&gt;.&lt;TLD&gt; </code> format. It authenticates as user <code class="leafygreen-ui-1l06pbn"> myDatabaseUser </code> with the password <code class="leafygreen-ui-1l06pbn"> D1fficultP%40ssw0rd </code> : </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"mongodb+srv://myDatabaseUser:D1fficultP%[email protected]/"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-1q4bxgx" tabindex="0"><code class="lg-highlight-hljs-light none leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">mongodb+srv://myDatabaseUser:D1fficultP%[email protected]/</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 corresponding DNS configuration resembles: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"Record TTL Class Priority Weight Port Target\n_mongodb._tcp.server.example.com. 86400 IN SRV 0 5 27317 mongodb1.example.com.\n_mongodb._tcp.server.example.com. 86400 IN SRV 0 5 27017 mongodb2.example.com."} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><code class="lg-highlight-hljs-light none leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">Record TTL Class Priority Weight Port Target</td></tr><tr class=""><td class="leafygreen-ui-7razhx">_mongodb._tcp.server.example.com. 86400 IN SRV 0 5 27317 mongodb1.example.com.</td></tr><tr class=""><td class="leafygreen-ui-7razhx">_mongodb._tcp.server.example.com. 86400 IN SRV 0 5 27017 mongodb2.example.com.</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"> Individual SRV records must be in <code class="leafygreen-ui-1l06pbn"> _mongodb._tcp.&lt;hostname&gt;.&lt;domain&gt;.&lt;TLD&gt; </code> format. </p> <p class="leafygreen-ui-1kp3ins"> When a client connects to a member of the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-seed-list"> seed list </a> , the client retrieves a list of replica set members it can connect to. Clients often use DNS aliases in their seed lists which means the host may return a server list that differs from the original seed list. If this happens, clients will use the hostnames provided by the replica set rather than the hostnames listed in the seed list to ensure that replica set members can be reached via the hostnames in the resulting replica set config. </p> <div class="leafygreen-ui-85da11" role="note"> <h2 class="leafygreen-ui-1ac4g5h"> Important </h2> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> The hostnames returned in SRV records must share the same parent domain (in this example, <code class="leafygreen-ui-1l06pbn"> example.com </code> ) as the given hostname. If the parent domains and hostname do not match, you will not be able to connect. </p> </div> </div> <p class="leafygreen-ui-1kp3ins"> This example shows a DNS seed list connection string that is missing the <code class="leafygreen-ui-1l06pbn"> &lt;hostname&gt; </code> . This is incorrect and raises an error. </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"# This connection string is missing the &lt;hostname&gt; and raises a connection error\n\nmongodb+srv://myDatabaseUser:D1fficultP%[email protected]/"} </script> <div class="css-1lju8ps"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-tyg50d"> <pre class="leafygreen-ui-1453az5" tabindex="0"><code class="lg-highlight-hljs-light none leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx"># This connection string is missing the &lt;hostname&gt; and raises a connection error</td></tr><tr class=""><td class="leafygreen-ui-7razhx"><div class="leafygreen-ui-ihxujy"></div></td></tr><tr class=""><td class="leafygreen-ui-7razhx">mongodb+srv://myDatabaseUser:D1fficultP%[email protected]/</td></tr></tbody></table></code></pre> </div> </div> </div> <p class="leafygreen-ui-1kp3ins"> Like the standard connection string, the DNS seed list connection string supports specifying options as a query string. With a DNS seed list connection string, you can <em> also </em> specify the following options via a TXT record: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <code class="leafygreen-ui-1l06pbn"> replicaSet </code> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <code class="leafygreen-ui-1l06pbn"> authSource </code> </p> </li> </ul> <p class="leafygreen-ui-1kp3ins"> You may only specify one TXT record per <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> instance. If multiple TXT records appear in the DNS and/or if the TXT record contains an option other than <code class="leafygreen-ui-1l06pbn"> replicaSet </code> or <code class="leafygreen-ui-1l06pbn"> authSource </code> , the client will return an error. </p> <p class="leafygreen-ui-1kp3ins"> The TXT record for the <code class="leafygreen-ui-1l06pbn"> server.example.com </code> DNS entry would resemble: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"Record TTL Class Text\nserver.example.com. 86400 IN TXT \"replicaSet=mySet&amp;authSource=authDB\""} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><code class="lg-highlight-hljs-light none leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">Record TTL Class Text</td></tr><tr class=""><td class="leafygreen-ui-7razhx">server.example.com. 86400 IN TXT "replicaSet=mySet&amp;authSource=authDB"</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"> Taken together, the DNS SRV records and the options specified in the TXT record resolve to the following standard format connection string: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"mongodb://myDatabaseUser:D1fficultP%[email protected]:27317,mongodb2.example.com:27017/?replicaSet=mySet&amp;authSource=authDB"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-1q4bxgx" tabindex="0"><code class="lg-highlight-hljs-light none leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">mongodb://myDatabaseUser:D1fficultP%[email protected]:27317,mongodb2.example.com:27017/?replicaSet=mySet&amp;authSource=authDB</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"> You can override the options specified in a TXT record by passing the option in the query string. In the following example, the query string has provided an override for the <code class="leafygreen-ui-1l06pbn"> authSource </code> option configured in the TXT record of the DNS entry above. </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"mongodb+srv://myDatabaseUser:D1fficultP%[email protected]/?connectTimeoutMS=300000&amp;authSource=aDifferentAuthDB"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-1q4bxgx" tabindex="0"><code class="lg-highlight-hljs-light none leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">mongodb+srv://myDatabaseUser:D1fficultP%[email protected]/?connectTimeoutMS=300000&amp;authSource=aDifferentAuthDB</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"> Given the override for the <code class="leafygreen-ui-1l06pbn"> authSource </code> , the equivalent connection string in the standard format would be: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"mongodb://myDatabaseUser:D1fficultP%[email protected]:27317,mongodb2.example.com:27017/?connectTimeoutMS=300000&amp;replicaSet=mySet&amp;authSource=aDifferentAuthDB"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-1q4bxgx" tabindex="0"><code class="lg-highlight-hljs-light none leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">mongodb://myDatabaseUser:D1fficultP%[email protected]:27317,mongodb2.example.com:27017/?connectTimeoutMS=300000&amp;replicaSet=mySet&amp;authSource=aDifferentAuthDB</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-15mdk4" role="note"> <h2 class="leafygreen-ui-6n7b7d"> Note </h2> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> The <code class="leafygreen-ui-1l06pbn"> mongodb+srv </code> option fails if there is no available DNS with records that correspond to the hostname identified in the connection string. If you use the <code class="leafygreen-ui-1l06pbn"> +srv </code> connection string modifier, the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/connection-string-options/#mongodb-urioption-urioption.tls"> <code class="leafygreen-ui-1l06pbn"> tls </code> </a> (or the equivalent <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/connection-string-options/#mongodb-urioption-urioption.ssl"> <code class="leafygreen-ui-1l06pbn"> ssl </code> </a> ) option is set to <code class="leafygreen-ui-1l06pbn"> true </code> for the connection. You can override this behavior by explicitly setting the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/connection-string-options/#mongodb-urioption-urioption.tls"> <code class="leafygreen-ui-1l06pbn"> tls </code> </a> (or the equivalent <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/connection-string-options/#mongodb-urioption-urioption.ssl"> <code class="leafygreen-ui-1l06pbn"> ssl </code> </a> ) option to <code class="leafygreen-ui-1l06pbn"> false </code> with <code class="leafygreen-ui-1l06pbn"> tls=false </code> (or <code class="leafygreen-ui-1l06pbn"> ssl=false </code> ) in the query string. </p> <p class="leafygreen-ui-1kp3ins"> For an example that connects <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/mongodb-shell/#mongodb-binary-bin.mongosh" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongosh </code> </span> </a> to a replica set using the DNS seed list connection format, see <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/mongodb-shell/reference/options/#std-label-example-connect-mongosh-using-srv" target="_self"> <span> mongosh Connection Options <!-- --> . </span> </a> </p> </div> </div> <span class="leafygreen-ui-1qnjd6d" id="std-label-connections-standard-connection-string-format"> </span> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Standard Connection String Format <a class="headerlink leafygreen-ui-1kepx47" href="#standard-connection-string-format" 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="standard-connection-string-format"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> This section describes the standard format of the MongoDB connection URI used to connect to a self-hosted MongoDB standalone deployment, replica set, or sharded cluster. </p> <p class="leafygreen-ui-1kp3ins"> The standard URI connection scheme has the form: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"mongodb://[username:password@]host1[:port1][,...hostN[:portN]][/[defaultauthdb][?options]]"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-1q4bxgx" tabindex="0"><code class="lg-highlight-hljs-light none leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">mongodb://[username:password@]host1[:port1][,...hostN[:portN]][/[defaultauthdb][?options]]</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"> For more examples, see <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/connection-string-examples/#std-label-connections-connection-examples"> Connection String Examples <!-- --> . </a> </p> <section> <h4 class="contains-headerlink leafygreen-ui-1vzlt5f"> Connection String Components <a class="headerlink leafygreen-ui-1kepx47" href="#connection-string-components-1" 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="connection-string-components-1"> </div> </a> </h4> <p class="leafygreen-ui-1kp3ins"> A connection string includes the following components: </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> Component </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> <code class="leafygreen-ui-1l06pbn"> mongodb:// </code> or <code class="leafygreen-ui-1l06pbn"> mongodb+srv:// </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> A required prefix to identify that this is a string in the standard connection format ( <code class="leafygreen-ui-1l06pbn"> mongodb:// </code> ) or SRV connection format ( <code class="leafygreen-ui-1l06pbn"> mongodb+srv:// </code> ). To learn more about each format, see <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-connections-standard-connection-string-format" target="_self"> <span> Standard Connection String Format </span> </a> and <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-connections-dns-seedlist" target="_self"> <span> SRV Connection Format <!-- --> . </span> </a> </div> </div> </td> </tr> <tr class="leafygreen-ui-15dvrnp"> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> username:password@ </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <p class="leafygreen-ui-1kp3ins"> Optional. Authentication credentials. </p> <p class="leafygreen-ui-1kp3ins"> If specified, the client will attempt to authenticate the user to the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/connection-string-options/#mongodb-urioption-urioption.authSource"> <code class="leafygreen-ui-1l06pbn"> authSource </code> </a> . If <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/connection-string-options/#mongodb-urioption-urioption.authSource"> <code class="leafygreen-ui-1l06pbn"> authSource </code> </a> is unspecified, the client will attempt to authenticate the user to the <code class="leafygreen-ui-1l06pbn"> defaultauthdb </code> . And if the <code class="leafygreen-ui-1l06pbn"> defaultauthdb </code> is unspecified, to the <code class="leafygreen-ui-1l06pbn"> admin </code> database. </p> <p class="leafygreen-ui-1kp3ins"> If the username or password includes the following characters, those characters must be converted using <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://tools.ietf.org/html/rfc3986#section-2.1" rel="noopener noreferrer"> <span> percent encoding <!-- --> : </span> <svg alt="" aria-hidden="true" class="leafygreen-ui-1ie5kuq" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M13.823 2.4491C13.8201 2.30008 13.6999 2.17994 13.5509 2.17704L9.5062 2.09836C9.25654 2.09351 9.12821 2.39519 9.30482 2.5718L10.3856 3.65257L7.93433 6.10383C7.87964 6.15852 7.83047 6.21665 7.78683 6.27752L5.99909 8.06525C5.46457 8.59977 5.46457 9.4664 5.99909 10.0009C6.53361 10.5354 7.40023 10.5354 7.93475 10.0009L9.72249 8.21317C9.78336 8.16953 9.84148 8.12037 9.89618 8.06567L12.3474 5.61441L13.4282 6.69518C13.6048 6.87179 13.9065 6.74347 13.9016 6.4938L13.823 2.4491Z" fill="currentColor"> </path> <path d="M7.25 3.12893C7.66421 3.12893 8 3.46472 8 3.87893C8 4.29315 7.66421 4.62893 7.25 4.62893H4C3.72386 4.62893 3.5 4.85279 3.5 5.12893V11.9929C3.5 12.2691 3.72386 12.4929 4 12.4929H10.864C11.1401 12.4929 11.364 12.2691 11.364 11.9929V8.75C11.364 8.33579 11.6998 8 12.114 8C12.5282 8 12.864 8.33579 12.864 8.75V11.9929C12.864 13.0975 11.9686 13.9929 10.864 13.9929H4C2.89543 13.9929 2 13.0975 2 11.9929V5.12893C2 4.02436 2.89543 3.12893 4 3.12893H7.25Z" fill="currentColor"> </path> </svg> </a> </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"$ : / ? # [ ] @"} </script> <div class="css-1lju8ps"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1jheeh3"> <pre class="leafygreen-ui-1agdxuk" tabindex="-1"><code class="lg-highlight-hljs-light none leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">$ : / ? # [ ] @</td></tr></tbody></table></code></pre> </div> </div> </div> <p class="leafygreen-ui-1kp3ins"> See also <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/connection-string-options/#mongodb-urioption-urioption.authSource"> <code class="leafygreen-ui-1l06pbn"> authSource </code> . </a> </p> </div> </div> </td> </tr> <tr class="leafygreen-ui-15dvrnp"> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> host[:port] </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <p class="leafygreen-ui-1kp3ins"> The host (and optional port number) where the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> instance (or <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongos/#mongodb-binary-bin.mongos"> <code class="leafygreen-ui-1l06pbn"> mongos </code> </a> instance for a sharded cluster) is running. You can specify a hostname, IP address, or UNIX domain socket. Specify as many hosts as appropriate for your deployment topology: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> For a standalone, specify the hostname of the standalone <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> instance. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> For a replica set, specify the hostname(s) of the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> instance(s) as listed in the replica set configuration. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> For a sharded cluster, specify the hostname(s) of the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongos/#mongodb-binary-bin.mongos"> <code class="leafygreen-ui-1l06pbn"> mongos </code> </a> instance(s). </p> </li> </ul> <p class="leafygreen-ui-1kp3ins"> If the port number is not specified, the default port <code class="leafygreen-ui-1l06pbn"> 27017 </code> is used. </p> <p class="leafygreen-ui-1kp3ins"> If you use the SRV URI connection format, you can specify only one host and no port. Otherwise, the driver or <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/mongodb-shell/#mongodb-binary-bin.mongosh" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongosh </code> </span> </a> raises a parse error and does not perform DNS resolution. </p> </div> </div> </td> </tr> <tr class="leafygreen-ui-15dvrnp"> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> /defaultauthdb </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <p class="leafygreen-ui-1kp3ins"> Optional. The authentication database to use if the connection string includes <code class="leafygreen-ui-1l06pbn"> username:password@ </code> authentication credentials but the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/connection-string-options/#mongodb-urioption-urioption.authSource"> <code class="leafygreen-ui-1l06pbn"> authSource </code> </a> option is unspecified. </p> <p class="leafygreen-ui-1kp3ins"> If both <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/connection-string-options/#mongodb-urioption-urioption.authSource"> <code class="leafygreen-ui-1l06pbn"> authSource </code> </a> and <code class="leafygreen-ui-1l06pbn"> defaultauthdb </code> are unspecified, the client will attempt to authenticate the specified user to the <code class="leafygreen-ui-1l06pbn"> admin </code> database. </p> </div> </div> </td> </tr> <tr class="leafygreen-ui-15dvrnp"> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> ?&lt;options&gt; </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <p class="leafygreen-ui-1kp3ins"> Optional. A query string that specifies connection specific options as <code class="leafygreen-ui-1l06pbn"> &lt;name&gt;=&lt;value&gt; </code> pairs. See <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/connection-string-options/#std-label-connections-connection-options"> Connection String Options </a> for a full description of these options. </p> <p class="leafygreen-ui-1kp3ins"> If the connection string does not specify a database/ you must specify a slash ( <code class="leafygreen-ui-1l06pbn"> / </code> ) between the last <code class="leafygreen-ui-1l06pbn"> host </code> and the question mark ( <code class="leafygreen-ui-1l06pbn"> ? </code> ) that begins the string of options. </p> </div> </div> </td> </tr> </tbody> </table> </div> </section> </section> </section> </section>
https://www.mongodb.com/docs/manual/reference/bson-type-comparison-order/
<section> <h1 class="contains-headerlink leafygreen-ui-41fr9s" weight="medium"> Comparison/Sort Order <a class="headerlink leafygreen-ui-1kepx47" href="#comparison-sort-order" 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="comparison-sort-order"> </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="#numeric-types" target="_self"> <span> Numeric Types </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#strings" target="_self"> <span> Strings </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#arrays" target="_self"> <span> Arrays </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#objects" target="_self"> <span> Objects </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#dates-and-timestamps" target="_self"> <span> Dates and Timestamps </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#non-existent-fields" target="_self"> <span> Non-existent Fields </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#bindata" target="_self"> <span> BinData </span> </a> </li> </ul> </div> <p class="leafygreen-ui-1kp3ins"> When comparing values of different <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/bson-types/#std-label-bson-types"> BSON types </a> in sort operations, MongoDB uses the following comparison order, from lowest to highest: </p> <ol class="leafygreen-ui-rioki0" type="1"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> MinKey (internal type) </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Null </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Numbers (ints, longs, doubles, decimals) </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Symbol, String </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Object </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Array </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> BinData </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> ObjectId </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Boolean </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Date </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Timestamp </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Regular Expression </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> MaxKey (internal type) </p> </li> </ol> <div class="leafygreen-ui-15mdk4" role="note"> <h2 class="leafygreen-ui-6n7b7d"> Note </h2> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/range/#std-label-range"> $range </a> query and aggregation operators perform comparisons only on fields where the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/bson-types/#std-label-bson-types"> BSON type </a> matches the query value's type. MongoDB supports limited cross-BSON comparison through <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/db.collection.find/#std-label-type-bracketing"> Type Bracketing <!-- --> . </a> </p> </div> </div> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Numeric Types <a class="headerlink leafygreen-ui-1kepx47" href="#numeric-types" 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="numeric-types"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> MongoDB treats some types as equivalent for comparison purposes. For instance, numeric types undergo conversion before comparison. </p> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Strings <a class="headerlink leafygreen-ui-1kepx47" href="#strings" 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="strings"> </div> </a> </h2> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Binary Comparison <a class="headerlink leafygreen-ui-1kepx47" href="#binary-comparison" 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="binary-comparison"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> By default, MongoDB uses the simple binary comparison to compare strings. </p> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Collation <a class="headerlink leafygreen-ui-1kepx47" href="#collation" 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="collation"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/collation/#std-label-collation"> Collation </a> allows users to specify language-specific rules for string comparison, such as rules for lettercase and accent marks. </p> <p class="leafygreen-ui-1kp3ins"> Collation specification has the following syntax: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{\n locale: &lt;string&gt;,\n caseLevel: &lt;boolean&gt;,\n caseFirst: &lt;string&gt;,\n strength: &lt;int&gt;,\n numericOrdering: &lt;boolean&gt;,\n alternate: &lt;string&gt;,\n maxVariable: &lt;string&gt;,\n backwards: &lt;boolean&gt;\n}"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" tabindex="-1"><code class="lg-highlight-hljs-light none leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> locale: &lt;string&gt;,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> caseLevel: &lt;boolean&gt;,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> caseFirst: &lt;string&gt;,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> strength: &lt;int&gt;,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> numericOrdering: &lt;boolean&gt;,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> alternate: &lt;string&gt;,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> maxVariable: &lt;string&gt;,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> backwards: &lt;boolean&gt;</td></tr><tr class=""><td class="leafygreen-ui-7razhx">}</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"> When specifying collation, the <code class="leafygreen-ui-1l06pbn"> locale </code> field is mandatory; all other collation fields are optional. For descriptions of the fields, see <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/collation/#std-label-collation-document-fields"> Collation Document <!-- --> . </a> </p> <p class="leafygreen-ui-1kp3ins"> If no collation is specified for the collection or for the operations, MongoDB uses the simple binary comparison used in prior versions for string comparisons. </p> <span class="leafygreen-ui-1qnjd6d" id="std-label-bson-type-comparison-order-arrays"> </span> </section> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Arrays <a class="headerlink leafygreen-ui-1kepx47" href="#arrays" 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="arrays"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> In array comparisons: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> A less-than comparison, or an ascending sort, compares the smallest elements of the array according to the BSON type sort order. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> A greater-than comparison, or a descending sort, compares the largest elements of the array according to the reverse BSON type sort order. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> When comparing a field whose value is a one element array (example, <code class="leafygreen-ui-1l06pbn"> [ 1 ] </code> ) with non-array fields (example, <code class="leafygreen-ui-1l06pbn"> 2 </code> ), the comparison is for <code class="leafygreen-ui-1l06pbn"> 1 </code> and <code class="leafygreen-ui-1l06pbn"> 2 </code> . </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> A comparison of an empty array (example, <code class="leafygreen-ui-1l06pbn"> [ ] </code> ) considers the empty array as less than a <code class="leafygreen-ui-1l06pbn"> null </code> value or a missing field value. </p> </li> </ul> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Objects <a class="headerlink leafygreen-ui-1kepx47" href="#objects" 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="objects"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> MongoDB's comparison of <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-BSON"> BSON </a> objects uses the following order: </p> <ol class="leafygreen-ui-rioki0" type="1"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Recursively compare key-value pairs in the order that they appear within the BSON object. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Compare the field types. MongoDB uses the following comparison order for field types, from lowest to highest: </p> <ol class="leafygreen-ui-rioki0" type="a"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> MinKey (internal type) </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Null </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Numbers (ints, longs, doubles, decimals) </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Symbol, String </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Object </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Array </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> BinData </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> ObjectId </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Boolean </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Date </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Timestamp </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Regular Expression </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> MaxKey (internal type) </p> </li> </ol> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> If the field types are equal, compare the <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/document/#std-label-document-field-names"> key field names <!-- --> . </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> If the key field names are equal, compare the field values. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> If the field values are equal, compare the next key/value pair (return to step 1). An object without further pairs is less than an object with further pairs. </p> </li> </ol> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Dates and Timestamps <a class="headerlink leafygreen-ui-1kepx47" href="#dates-and-timestamps" 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="dates-and-timestamps"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> Date objects sort before Timestamp objects. </p> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Non-existent Fields <a class="headerlink leafygreen-ui-1kepx47" href="#non-existent-fields" 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="non-existent-fields"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> The comparison treats a non-existent field as if it were an empty BSON Object. As such, a sort on the <code class="leafygreen-ui-1l06pbn"> a </code> field in documents <code class="leafygreen-ui-1l06pbn"> { } </code> and <code class="leafygreen-ui-1l06pbn"> { a: null } </code> would treat the documents as equivalent in sort order. </p> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> BinData <a class="headerlink leafygreen-ui-1kepx47" href="#bindata" 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="bindata"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> MongoDB sorts <code class="leafygreen-ui-1l06pbn"> BinData </code> in the following order: </p> <ol class="leafygreen-ui-rioki0" type="1"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> First, the length or size of the data. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Then, by the BSON one-byte subtype. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Finally, by the data, performing a byte-by-byte comparison. </p> </li> </ol> </section> </section>
https://www.mongodb.com/docs/manual/reference/command/dropAllUsersFromDatabase/
<section> <h1 class="contains-headerlink leafygreen-ui-41fr9s" weight="medium"> dropAllUsersFromDatabase <a class="headerlink leafygreen-ui-1kepx47" href="#dropallusersfromdatabase" 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="dropallusersfromdatabase"> </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="#definition" target="_self"> <span> Definition </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#compatibility" target="_self"> <span> Compatibility </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#syntax" target="_self"> <span> Syntax </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#command-fields" target="_self"> <span> Command Fields </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#required-access" target="_self"> <span> Required Access </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#example" target="_self"> <span> Example </span> </a> </li> </ul> </div> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Definition <a class="headerlink leafygreen-ui-1kepx47" href="#definition" 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="definition"> </div> </a> </h2> <dl class="dbcommand"> <dt> <code class="leafygreen-ui-1l06pbn"> dropAllUsersFromDatabase </code> <a class="headerlink leafygreen-ui-1kepx47" href="#mongodb-dbcommand-dbcmd.dropAllUsersFromDatabase" title="Permalink to this definition"> <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="mongodb-dbcommand-dbcmd.dropAllUsersFromDatabase"> </div> </a> </dt> <dd> <p class="leafygreen-ui-1kp3ins"> Removes all users from the database on which you run the command. </p> <div class="leafygreen-ui-13vw3ie" role="note"> <h2 class="leafygreen-ui-1fn4p2b"> Tip </h2> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> In <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/mongodb-shell/#std-program-mongosh" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongosh </code> </span> </a> , this command can also be run through the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/db.dropAllUsers/#mongodb-method-db.dropAllUsers"> <code class="leafygreen-ui-1l06pbn"> db.dropAllUsers() </code> </a> helper method <!-- --> . </p> <p class="leafygreen-ui-1kp3ins"> Helper methods are convenient for <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/mongodb-shell/#std-program-mongosh" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongosh </code> </span> </a> users, but they may not return the same level of information as database commands. In cases where the convenience is not needed or the additional return fields are required, use the database command. </p> </div> </div> <div class="leafygreen-ui-1sjx7ru" role="note"> <h2 class="leafygreen-ui-29m78u"> Warning </h2> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> The <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-dbcommand-dbcmd.dropAllUsersFromDatabase" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> dropAllUsersFromDatabase </code> </span> </a> removes all users from the database. </p> </div> </div> </dd> </dl> </section> <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"> This command is available in 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> <div class="leafygreen-ui-85da11" role="note"> <h2 class="leafygreen-ui-1ac4g5h"> Important </h2> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> This command is not supported in M0, M2, and M5 clusters. For more information, see <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/atlas/unsupported-commands/" target="_self"> <span> Unsupported Commands <!-- --> . </span> </a> </p> </div> </div> <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"> Syntax <a class="headerlink leafygreen-ui-1kepx47" href="#syntax" 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="syntax"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> The command has the following syntax: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.runCommand(\n {\n dropAllUsersFromDatabase: 1,\n writeConcern: { &lt;write&gt; },\n comment: &lt;any&gt;\n }\n)","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">runCommand</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">dropAllUsersFromDatabase</span>: <span class="lg-highlight-number">1</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">writeConcern</span>: <!-- -->{ <!-- -->&lt;write concern&gt; },</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> comment: &lt;any&gt;</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">)</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> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Command Fields <a class="headerlink leafygreen-ui-1kepx47" href="#command-fields" 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="command-fields"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> The command takes the following fields: </p> <div class="leafygreen-ui-skkc39" tabindex="0"> <table class="leafygreen-ui-hr8lsv"> <colgroup> <col style="width:20%"/> <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> Field </div> </div> </th> <th class="leafygreen-ui-13uteka" role="columnheader" scope="col"> <div class="leafygreen-ui-ui0te9"> <div> Type </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> <code class="leafygreen-ui-1l06pbn"> dropAllUsersFromDatabase </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> integer </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Specify <code class="leafygreen-ui-1l06pbn"> 1 </code> to drop all the users from the current database. </div> </div> </td> </tr> <tr class=""> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> writeConcern </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> document </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <p class="leafygreen-ui-1kp3ins"> Optional. The level of <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/write-concern/#std-label-write-concern"> write concern </a> for the operation. See <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/write-concern/#std-label-wc-specs"> Write Concern Specification <!-- --> . </a> </p> </div> </div> </td> </tr> <tr class=""> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> comment </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> any </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <p class="leafygreen-ui-1kp3ins"> Optional. A user-provided comment to attach to this command. Once set, this comment appears alongside records of this command in the following locations: </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/log-messages/#std-label-log-messages-ref"> mongod log messages </a> , in the <code class="leafygreen-ui-1l06pbn"> attr.command.cursor.comment </code> field. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/database-profiler/#std-label-profiler"> Database profiler </a> output, in the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/database-profiler/#mongodb-data-system.profile.command"> <code class="leafygreen-ui-1l06pbn"> command.comment </code> </a> field. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/command/currentOp/#mongodb-dbcommand-dbcmd.currentOp"> <code class="leafygreen-ui-1l06pbn"> currentOp </code> </a> output, in the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/command/currentOp/#mongodb-data-currentOp.command"> <code class="leafygreen-ui-1l06pbn"> command.comment </code> </a> field. </p> </li> </ul> <p class="leafygreen-ui-1kp3ins"> A comment can be any valid <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/bson-types/#std-label-bson-types"> BSON type </a> (string, integer, object, array, etc). </p> </div> </div> </td> </tr> </tbody> </table> </div> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Required Access <a class="headerlink leafygreen-ui-1kepx47" href="#required-access" 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="required-access"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> You must have the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/privilege-actions/#mongodb-authaction-dropUser"> <code class="leafygreen-ui-1l06pbn"> dropUser </code> </a> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/privilege-actions/#std-label-security-user-actions"> action </a> on a database to drop a user from that database. </p> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Example <a class="headerlink leafygreen-ui-1kepx47" href="#example" 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="example"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> The following sequence of operations in <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/mongodb-shell/#mongodb-binary-bin.mongosh" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongosh </code> </span> </a> drops every user from the <code class="leafygreen-ui-1l06pbn"> products </code> database: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"use products\ndb.runCommand( { dropAllUsersFromDatabase: 1, writeConcern: { w: \"majority\" } } )","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">use products</td></tr><tr class=""><td class="leafygreen-ui-7razhx">db.<span class="lg-highlight-title lg-highlight-function">runCommand</span>( <!-- -->{ <span class="lg-highlight-attr">dropAllUsersFromDatabase</span>: <span class="lg-highlight-number">1</span>, <span class="lg-highlight-attr">writeConcern</span>: <!-- -->{ <span class="lg-highlight-attr">w</span>: <span class="lg-highlight-string">"majority"</span> } } )</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 <code class="leafygreen-ui-1l06pbn"> n </code> field in the results document shows the number of users removed: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ \"n\" : 12, \"ok\" : 1 }","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">{ <span class="lg-highlight-string">"n"</span> <!-- -->: <span class="lg-highlight-number">12</span>, <span class="lg-highlight-string">"ok"</span> <!-- -->: <span class="lg-highlight-number">1</span> }</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> </section> </section>
https://www.mongodb.com/docs/manual/reference/operator/aggregation/round/
<section> <h1 class="contains-headerlink leafygreen-ui-41fr9s" weight="medium"> $round (aggregation) <a class="headerlink leafygreen-ui-1kepx47" href="#-round--aggregation-" 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="-round--aggregation-"> </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="#definition" target="_self"> <span> Definition </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#behavior" target="_self"> <span> Behavior </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#example" target="_self"> <span> Example </span> </a> </li> </ul> </div> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Definition <a class="headerlink leafygreen-ui-1kepx47" href="#definition" 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="definition"> </div> </a> </h2> <dl class="expression"> <dt> <code class="leafygreen-ui-1l06pbn"> $round </code> <a class="headerlink leafygreen-ui-1kepx47" href="#mongodb-expression-exp.-round" title="Permalink to this definition"> <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="mongodb-expression-exp.-round"> </div> </a> </dt> <dd> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-expression-exp.-round" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $round </code> </span> </a> rounds a number to a whole integer <em> or </em> to a specified decimal place. </p> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-expression-exp.-round" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $round </code> </span> </a> has the following syntax: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ $round : [ &lt;number&gt;, &lt;place&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">{ <!-- -->$round<!-- --> <!-- -->: <!-- -->[ &lt;<!-- -->number<!-- -->&gt;<!-- -->,<!-- --> <!-- -->&lt;<!-- -->place<!-- -->&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: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> Field </div> </div> </th> <th class="leafygreen-ui-13uteka" role="columnheader" scope="col"> <div class="leafygreen-ui-ui0te9"> <div> Type </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> <code class="leafygreen-ui-1l06pbn"> &lt;number&gt; </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> number </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <p class="leafygreen-ui-1kp3ins"> Can be any valid <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/#std-label-aggregation-expressions"> expression </a> that resolves to a number. Specifically, the expression must resolve to an integer, double, <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/mongodb-extended-json-v1/#mongodb-bsontype-data_numberdecimal"> <code class="leafygreen-ui-1l06pbn"> decimal </code> </a> , or <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/mongodb-extended-json-v1/#mongodb-bsontype-data_numberlong"> <code class="leafygreen-ui-1l06pbn"> long </code> . </a> </p> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-expression-exp.-round" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $round </code> </span> </a> returns an error if the expression resolves to a non-numeric data type. </p> </div> </div> </td> </tr> <tr class=""> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> &lt;place&gt; </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> integer </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <p class="leafygreen-ui-1kp3ins"> <em> Optional </em> Can be any valid <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/#std-label-aggregation-expressions"> expression </a> that resolves to an integer between -20 and 100, exclusive. e.g. <code class="leafygreen-ui-1l06pbn"> -20 &lt; place &lt; 100 </code> . Defaults to <code class="leafygreen-ui-1l06pbn"> 0 </code> if unspecified. </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> If <code class="leafygreen-ui-1l06pbn"> &lt;place&gt; </code> resolves to a positive integer, <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-expression-exp.-round" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $round </code> </span> </a> rounds to <code class="leafygreen-ui-1l06pbn"> &lt;place&gt; </code> decimal places. </p> <p class="leafygreen-ui-1kp3ins"> For example, <code class="leafygreen-ui-1l06pbn"> $round : [1234.5678, 2] </code> rounds to two decimal places and returns <code class="leafygreen-ui-1l06pbn"> 1234.57 </code> . </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> If <code class="leafygreen-ui-1l06pbn"> &lt;place&gt; </code> resolves to a negative integer, <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-expression-exp.-round" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $round </code> </span> </a> rounds using the digit <code class="leafygreen-ui-1l06pbn"> &lt;place&gt; </code> to the left of the decimal. </p> <p class="leafygreen-ui-1kp3ins"> For example, <code class="leafygreen-ui-1l06pbn"> $round : [1234.5678, -2] </code> uses the 2nd digit to the left of the decimal ( <code class="leafygreen-ui-1l06pbn"> 3 </code> ) and returns <code class="leafygreen-ui-1l06pbn"> 1200 </code> . </p> <p class="leafygreen-ui-1kp3ins"> If the absolute value of <code class="leafygreen-ui-1l06pbn"> &lt;place&gt; </code> equals or exceeds the number of digits to the left of the decimal, <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-expression-exp.-round" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $round </code> </span> </a> returns <code class="leafygreen-ui-1l06pbn"> 0 </code> . </p> <p class="leafygreen-ui-1kp3ins"> For example, <code class="leafygreen-ui-1l06pbn"> $round : [ 1234.5678, -4] </code> specifies the fourth digit to the left of the decimal. This equals the number of digits left of the decimal and returns <code class="leafygreen-ui-1l06pbn"> 0 </code> . </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> If <code class="leafygreen-ui-1l06pbn"> &lt;place&gt; </code> resolves to <code class="leafygreen-ui-1l06pbn"> 0 </code> , <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-expression-exp.-round" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $round </code> </span> </a> rounds using the first digit to the right of the decimal and returns rounded integer value. </p> <p class="leafygreen-ui-1kp3ins"> For example, <code class="leafygreen-ui-1l06pbn"> $round : [1234.5678, 0] </code> returns <code class="leafygreen-ui-1l06pbn"> 1235 </code> . </p> </li> </ul> </div> </div> </td> </tr> </tbody> </table> </div> </dd> </dl> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Behavior <a class="headerlink leafygreen-ui-1kepx47" href="#behavior" 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="behavior"> </div> </a> </h2> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Rounding to Even Values <a class="headerlink leafygreen-ui-1kepx47" href="#rounding-to-even-values" 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="rounding-to-even-values"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> When rounding on a value of <code class="leafygreen-ui-1l06pbn"> 5 </code> , <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-expression-exp.-round" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $round </code> </span> </a> rounds to the nearest even value. For example, consider the following sample documents: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{_id : 1, \"value\" : 10.5},\n{_id : 2, \"value\" : 11.5},\n{_id : 3, \"value\" : 12.5},\n{_id : 4, \"value\" : 13.5}","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">{<!-- -->_id <!-- -->: <span class="lg-highlight-number">1</span>, <span class="lg-highlight-string">"value"</span> <!-- -->: <span class="lg-highlight-number">10.5</span>}<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{<!-- -->_id <!-- -->: <span class="lg-highlight-number">2</span>, <span class="lg-highlight-string">"value"</span> <!-- -->: <span class="lg-highlight-number">11.5</span>}<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{<!-- -->_id <!-- -->: <span class="lg-highlight-number">3</span>, <span class="lg-highlight-string">"value"</span> <!-- -->: <span class="lg-highlight-number">12.5</span>}<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{<!-- -->_id <!-- -->: <span class="lg-highlight-number">4</span>, <span class="lg-highlight-string">"value"</span> <!-- -->: <span class="lg-highlight-number">13.5</span>}</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"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-expression-exp.-round" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $round : [ "$value", 0] </code> </span> </a> returns the following: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{_id : 1, \"value\" : 10},\n{_id : 2, \"value\" : 12},\n{_id : 3, \"value\" : 12},\n{_id : 4, \"value\" : 14}","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">{<!-- -->_id <!-- -->: <span class="lg-highlight-number">1</span>, <span class="lg-highlight-string">"value"</span> <!-- -->: <span class="lg-highlight-number">10</span>}<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{<!-- -->_id <!-- -->: <span class="lg-highlight-number">2</span>, <span class="lg-highlight-string">"value"</span> <!-- -->: <span class="lg-highlight-number">12</span>}<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{<!-- -->_id <!-- -->: <span class="lg-highlight-number">3</span>, <span class="lg-highlight-string">"value"</span> <!-- -->: <span class="lg-highlight-number">12</span>}<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{<!-- -->_id <!-- -->: <span class="lg-highlight-number">4</span>, <span class="lg-highlight-string">"value"</span> <!-- -->: <span class="lg-highlight-number">14</span>}</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 value <code class="leafygreen-ui-1l06pbn"> 10.5 </code> is closest to the even value <code class="leafygreen-ui-1l06pbn"> 10 </code> , while the values <code class="leafygreen-ui-1l06pbn"> 11.5 </code> and <code class="leafygreen-ui-1l06pbn"> 12.5 </code> are closest to the even value <code class="leafygreen-ui-1l06pbn"> 12 </code> . Rounding to the nearest even value supports more even distribution of rounded data than always rounding up or down. </p> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Returned Data Type <a class="headerlink leafygreen-ui-1kepx47" href="#returned-data-type" 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="returned-data-type"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> The returned data type matches the data type of the input expression or value. </p> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> <code class="leafygreen-ui-1l06pbn"> null </code> , <code class="leafygreen-ui-1l06pbn"> NaN </code> , and <code class="leafygreen-ui-1l06pbn"> +/- Infinity </code> <a class="headerlink leafygreen-ui-1kepx47" href="#null--nan--and-----infinity" 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="null--nan--and-----infinity"> </div> </a> </h3> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> If the first argument resolves to a value of <code class="leafygreen-ui-1l06pbn"> null </code> or refers to a field that is missing, <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-expression-exp.-round" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $round </code> </span> </a> returns <code class="leafygreen-ui-1l06pbn"> null </code> . </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> If the first argument resolves to <code class="leafygreen-ui-1l06pbn"> NaN </code> , <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-expression-exp.-round" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $round </code> </span> </a> returns <code class="leafygreen-ui-1l06pbn"> NaN </code> . </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> If the first argument resolves to negative or positive infinity, <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-expression-exp.-round" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $round </code> </span> </a> returns negative or positive infinity respectively. </p> </li> </ul> <div class="leafygreen-ui-skkc39" tabindex="0"> <table class="leafygreen-ui-hr8lsv"> <colgroup> <col style="width:85%"/> <col style="width:15%"/> </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> Example </div> </div> </th> <th class="leafygreen-ui-13uteka" role="columnheader" scope="col"> <div class="leafygreen-ui-ui0te9"> <div> Results </div> </div> </th> </tr> </thead> <tbody> <tr class=""> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> { $round: [ NaN, 1] } </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> NaN </code> </div> </div> </td> </tr> <tr class=""> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> { $round: [ null, 1] } </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> null </code> </div> </div> </td> </tr> <tr class=""> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> { $round : [ Infinity, 1 ] } </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> Infinity </code> </div> </div> </td> </tr> <tr class=""> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> { $round : [ -Infinity, 1 ] } </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> -Infinity </code> </div> </div> </td> </tr> </tbody> </table> </div> </section> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Example <a class="headerlink leafygreen-ui-1kepx47" href="#example" 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="example"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> Create a collection named <code class="leafygreen-ui-1l06pbn"> samples </code> with the following documents: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.samples.insertMany(\n [\n { _id: 1, value: 19.25 },\n { _id: 2, value: 28.73 },\n { _id: 3, value: 34.32 },\n { _id: 4, value: -45.39 }\n ]\n)","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">samples</span>.<span class="lg-highlight-title lg-highlight-function">insertMany</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">1</span>, <span class="lg-highlight-attr">value</span>: <span class="lg-highlight-number">19.25</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">2</span>, <span class="lg-highlight-attr">value</span>: <span class="lg-highlight-number">28.73</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">3</span>, <span class="lg-highlight-attr">value</span>: <span class="lg-highlight-number">34.32</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">4</span>, <span class="lg-highlight-attr">value</span>: <!-- -->-<span class="lg-highlight-number">45.39</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> ]</td></tr><tr class=""><td class="leafygreen-ui-7razhx">)</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> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> The following aggregation returns <code class="leafygreen-ui-1l06pbn"> value </code> rounded to the first decimal place: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.samples.aggregate([\n { $project: { roundedValue: { $round: [ \"$value\", 1 ] } } }\n])","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><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">samples</span>.<span class="lg-highlight-title lg-highlight-function">aggregate</span>(<!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">$project</span>: <!-- -->{ <span class="lg-highlight-attr">roundedValue</span>: <!-- -->{ <span class="lg-highlight-attr">$round</span>: <!-- -->[ <span class="lg-highlight-string">"$value"</span>, <span class="lg-highlight-number">1</span> ] } } }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">])</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 operation returns the following results: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ \"_id\" : 1, \"roundedValue\" : 19.2 }\n{ \"_id\" : 2, \"roundedValue\" : 28.7 }\n{ \"_id\" : 3, \"roundedValue\" : 34.3 }\n{ \"_id\" : 4, \"roundedValue\" : -45.4 }","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">1</span>, <span class="lg-highlight-string">"roundedValue"</span> <!-- -->: <span class="lg-highlight-number">19.2</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">2</span>, <span class="lg-highlight-string">"roundedValue"</span> <!-- -->: <span class="lg-highlight-number">28.7</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">3</span>, <span class="lg-highlight-string">"roundedValue"</span> <!-- -->: <span class="lg-highlight-number">34.3</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">4</span>, <span class="lg-highlight-string">"roundedValue"</span> <!-- -->: <!-- -->-<span class="lg-highlight-number">45.4</span> }</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> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> The following aggregation returns <code class="leafygreen-ui-1l06pbn"> value </code> rounded using the first digit to the left of the decimal: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.samples.aggregate([\n { $project: { roundedValue: { $round: [ \"$value\", -1 ] } } }\n])","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><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">samples</span>.<span class="lg-highlight-title lg-highlight-function">aggregate</span>(<!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">$project</span>: <!-- -->{ <span class="lg-highlight-attr">roundedValue</span>: <!-- -->{ <span class="lg-highlight-attr">$round</span>: <!-- -->[ <span class="lg-highlight-string">"$value"</span>, <!-- -->-<span class="lg-highlight-number">1</span> ] } } }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">])</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 operation returns the following results: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ \"_id\" : 1, \"roundedValue\" : 10 }\n{ \"_id\" : 2, \"roundedValue\" : 20 }\n{ \"_id\" : 3, \"roundedValue\" : 30 }\n{ \"_id\" : 4, \"roundedValue\" : -50 }","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">1</span>, <span class="lg-highlight-string">"roundedValue"</span> <!-- -->: <span class="lg-highlight-number">10</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">2</span>, <span class="lg-highlight-string">"roundedValue"</span> <!-- -->: <span class="lg-highlight-number">20</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">3</span>, <span class="lg-highlight-string">"roundedValue"</span> <!-- -->: <span class="lg-highlight-number">30</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">4</span>, <span class="lg-highlight-string">"roundedValue"</span> <!-- -->: <!-- -->-<span class="lg-highlight-number">50</span> }</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> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> The following aggregation returns <code class="leafygreen-ui-1l06pbn"> value </code> rounded to the whole integer: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.samples.aggregate([\n { $project: { roundedValue: { $round: [ \"$value\", 0 ] } } }\n])","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><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">samples</span>.<span class="lg-highlight-title lg-highlight-function">aggregate</span>(<!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-attr">$project</span>: <!-- -->{ <span class="lg-highlight-attr">roundedValue</span>: <!-- -->{ <span class="lg-highlight-attr">$round</span>: <!-- -->[ <span class="lg-highlight-string">"$value"</span>, <span class="lg-highlight-number">0</span> ] } } }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">])</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 operation returns the following results: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ \"_id\" : 1, \"roundedValue\" : 19 }\n{ \"_id\" : 2, \"roundedValue\" : 29 }\n{ \"_id\" : 3, \"roundedValue\" : 34 }\n{ \"_id\" : 4, \"roundedValue\" : -45 }","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">1</span>, <span class="lg-highlight-string">"roundedValue"</span> <!-- -->: <span class="lg-highlight-number">19</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">2</span>, <span class="lg-highlight-string">"roundedValue"</span> <!-- -->: <span class="lg-highlight-number">29</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">3</span>, <span class="lg-highlight-string">"roundedValue"</span> <!-- -->: <span class="lg-highlight-number">34</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">4</span>, <span class="lg-highlight-string">"roundedValue"</span> <!-- -->: <!-- -->-<span class="lg-highlight-number">45</span> }</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> </li> </ul> </section> </section>
https://www.mongodb.com/docs/manual/tutorial/split-chunks-in-sharded-cluster/
<section> <h1 class="contains-headerlink leafygreen-ui-41fr9s" weight="medium"> Split Chunks in a Sharded Cluster <a class="headerlink leafygreen-ui-1kepx47" href="#split-chunks-in-a-sharded-cluster" 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="split-chunks-in-a-sharded-cluster"> </div> </a> </h1> <p class="leafygreen-ui-1kp3ins"> By default, MongoDB potentially splits a <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-chunk"> chunk </a> only when migrating data belonging to it. However, you may want to split chunks manually if you have a large amount of data in your cluster and very few <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-chunk"> chunks </a> , as is the case after deploying a cluster using existing data. </p> <p class="leafygreen-ui-1kp3ins"> To split chunks manually, use the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/command/split/#mongodb-dbcommand-dbcmd.split"> <code class="leafygreen-ui-1l06pbn"> split </code> </a> command with either fields <code class="leafygreen-ui-1l06pbn"> middle </code> or <code class="leafygreen-ui-1l06pbn"> find </code> . <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/mongodb-shell/#mongodb-binary-bin.mongosh" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongosh </code> </span> </a> provides the helper methods <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/sh.splitFind/#mongodb-method-sh.splitFind"> <code class="leafygreen-ui-1l06pbn"> sh.splitFind() </code> </a> and <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/sh.splitAt/#mongodb-method-sh.splitAt"> <code class="leafygreen-ui-1l06pbn"> sh.splitAt() </code> . </a> </p> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/sh.splitFind/#mongodb-method-sh.splitFind"> <code class="leafygreen-ui-1l06pbn"> splitFind() </code> </a> splits the chunk that contains the <em> first </em> document returned that matches this query into two equally sized chunks. You must specify the full namespace (i.e. " <code class="leafygreen-ui-1l06pbn"> &lt;database&gt;.&lt;collection&gt; </code> ") of the sharded collection to <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/sh.splitFind/#mongodb-method-sh.splitFind"> <code class="leafygreen-ui-1l06pbn"> splitFind() </code> </a> . The query in <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/sh.splitFind/#mongodb-method-sh.splitFind"> <code class="leafygreen-ui-1l06pbn"> splitFind() </code> </a> does not need to use the shard key, though it nearly always makes sense to do so. </p> <div class="leafygreen-ui-vg7qwp" role="note"> <h2 class="leafygreen-ui-2xicti"> Example </h2> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> The following command splits the chunk that contains the value of <code class="leafygreen-ui-1l06pbn"> 63109 </code> for the <code class="leafygreen-ui-1l06pbn"> zipcode </code> field in the <code class="leafygreen-ui-1l06pbn"> people </code> collection of the <code class="leafygreen-ui-1l06pbn"> records </code> database: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"sh.splitFind( \"records.people\", { \"zipcode\": \"63109\" } )","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">sh.<span class="lg-highlight-title lg-highlight-function">splitFind</span>( <span class="lg-highlight-string">"records.people"</span>, <!-- -->{ <span class="lg-highlight-string">"zipcode"</span>: <span class="lg-highlight-string">"63109"</span> } )</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> </div> <p class="leafygreen-ui-1kp3ins"> Use <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/sh.splitAt/#mongodb-method-sh.splitAt"> <code class="leafygreen-ui-1l06pbn"> splitAt() </code> </a> to split a chunk in two, using the queried document as the lower bound in the new chunk: </p> <div class="leafygreen-ui-vg7qwp" role="note"> <h2 class="leafygreen-ui-2xicti"> Example </h2> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> The following command splits the chunk that contains the value of <code class="leafygreen-ui-1l06pbn"> 63109 </code> for the <code class="leafygreen-ui-1l06pbn"> zipcode </code> field in the <code class="leafygreen-ui-1l06pbn"> people </code> collection of the <code class="leafygreen-ui-1l06pbn"> records </code> database. </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"sh.splitAt( \"records.people\", { \"zipcode\": \"63109\" } )","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">sh.<span class="lg-highlight-title lg-highlight-function">splitAt</span>( <span class="lg-highlight-string">"records.people"</span>, <!-- -->{ <span class="lg-highlight-string">"zipcode"</span>: <span class="lg-highlight-string">"63109"</span> } )</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> </div> <div class="leafygreen-ui-15mdk4" role="note"> <h2 class="leafygreen-ui-6n7b7d"> Note </h2> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/sh.splitAt/#mongodb-method-sh.splitAt"> <code class="leafygreen-ui-1l06pbn"> splitAt() </code> </a> does not necessarily split the chunk into two equally sized chunks. The split occurs at the location of the document matching the query, regardless of where that document is in the chunk. </p> </div> </div> <div class="leafygreen-ui-13vw3ie" role="note"> <h2 class="leafygreen-ui-1fn4p2b"> Tip </h2> <h3 class="leafygreen-ui-144d5kf"> <strong> See also: </strong> </h3> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/sharding-data-partitioning/#std-label-initial-chunks-empty-collection"> Empty Collection </a> </p> </div> </div> </section>
https://www.mongodb.com/docs/manual/reference/operator/aggregation/substrCP/
<section> <h1 class="contains-headerlink leafygreen-ui-41fr9s" weight="medium"> $substrCP (aggregation) <a class="headerlink leafygreen-ui-1kepx47" href="#-substrcp--aggregation-" 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="-substrcp--aggregation-"> </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="#definition" target="_self"> <span> Definition </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#behavior" target="_self"> <span> Behavior </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#example" target="_self"> <span> Example </span> </a> </li> </ul> </div> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Definition <a class="headerlink leafygreen-ui-1kepx47" href="#definition" 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="definition"> </div> </a> </h2> <dl class="expression"> <dt> <code class="leafygreen-ui-1l06pbn"> $substrCP </code> <a class="headerlink leafygreen-ui-1kepx47" href="#mongodb-expression-exp.-substrCP" title="Permalink to this definition"> <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="mongodb-expression-exp.-substrCP"> </div> </a> </dt> <dd> <p class="leafygreen-ui-1kp3ins"> Returns the substring of a string. The substring starts with the character at the specified UTF-8 <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="http://www.unicode.org/glossary/#code_point" rel="noopener noreferrer"> <span> code point (CP) </span> <svg alt="" aria-hidden="true" class="leafygreen-ui-1ie5kuq" height="16" role="presentation" viewbox="0 0 16 16" width="16"> <path d="M13.823 2.4491C13.8201 2.30008 13.6999 2.17994 13.5509 2.17704L9.5062 2.09836C9.25654 2.09351 9.12821 2.39519 9.30482 2.5718L10.3856 3.65257L7.93433 6.10383C7.87964 6.15852 7.83047 6.21665 7.78683 6.27752L5.99909 8.06525C5.46457 8.59977 5.46457 9.4664 5.99909 10.0009C6.53361 10.5354 7.40023 10.5354 7.93475 10.0009L9.72249 8.21317C9.78336 8.16953 9.84148 8.12037 9.89618 8.06567L12.3474 5.61441L13.4282 6.69518C13.6048 6.87179 13.9065 6.74347 13.9016 6.4938L13.823 2.4491Z" fill="currentColor"> </path> <path d="M7.25 3.12893C7.66421 3.12893 8 3.46472 8 3.87893C8 4.29315 7.66421 4.62893 7.25 4.62893H4C3.72386 4.62893 3.5 4.85279 3.5 5.12893V11.9929C3.5 12.2691 3.72386 12.4929 4 12.4929H10.864C11.1401 12.4929 11.364 12.2691 11.364 11.9929V8.75C11.364 8.33579 11.6998 8 12.114 8C12.5282 8 12.864 8.33579 12.864 8.75V11.9929C12.864 13.0975 11.9686 13.9929 10.864 13.9929H4C2.89543 13.9929 2 13.0975 2 11.9929V5.12893C2 4.02436 2.89543 3.12893 4 3.12893H7.25Z" fill="currentColor"> </path> </svg> </a> index (zero-based) in the string for the number of code points specified. </p> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-expression-exp.-substrCP" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $substrCP </code> </span> </a> has the following <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/#std-label-agg-quick-ref-operator-expressions"> operator expression syntax <!-- --> : </a> </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ $substrCP: [ &lt;string&gt;, <code>, <code> ] }</code></code>","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-1q4bxgx" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-attr">$substrCP</span>: <!-- -->[ <!-- -->&lt;string expression&gt;, &lt;code point index&gt;, &lt;code point count&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: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> Field </div> </div> </th> <th class="leafygreen-ui-13uteka" role="columnheader" scope="col"> <div class="leafygreen-ui-ui0te9"> <div> Type </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> <code class="leafygreen-ui-1l06pbn"> string expression </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> string </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <p class="leafygreen-ui-1kp3ins"> The string from which the substring will be extracted. <code class="leafygreen-ui-1l06pbn"> string expression </code> can be any valid <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/#std-label-aggregation-expressions"> expression </a> as long as it resolves to a string. For more information on expressions, see <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/#std-label-aggregation-expressions"> Expression Operators <!-- --> . </a> </p> <p class="leafygreen-ui-1kp3ins"> If the argument resolves to a value of <code class="leafygreen-ui-1l06pbn"> null </code> or refers to a field that is missing, <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-expression-exp.-substrCP" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $substrCP </code> </span> </a> returns an empty string. </p> <p class="leafygreen-ui-1kp3ins"> If the argument does not resolve to a string or <code class="leafygreen-ui-1l06pbn"> null </code> nor refers to a missing field, <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-expression-exp.-substrCP" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $substrCP </code> </span> </a> returns an error. </p> </div> </div> </td> </tr> <tr class=""> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> code point index </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> number </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Indicates the starting point of the substring. <code class="leafygreen-ui-1l06pbn"> code point index </code> can be any valid <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/#std-label-aggregation-expressions"> expression </a> as long as it resolves to a non-negative integer. </div> </div> </td> </tr> <tr class=""> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> code point count </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> number </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Can be any valid <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/#std-label-aggregation-expressions"> expression </a> as long as it resolves to a non-negative integer or number that can be represented as an integer (such as 2.0). </div> </div> </td> </tr> </tbody> </table> </div> <div class="leafygreen-ui-skkc39" tabindex="0"> <table class="leafygreen-ui-hr8lsv"> <colgroup> <col style="width:55%"/> <col style="width:45%"/> </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> Example </div> </div> </th> <th class="leafygreen-ui-13uteka" role="columnheader" scope="col"> <div class="leafygreen-ui-ui0te9"> <div> Results </div> </div> </th> </tr> </thead> <tbody> <tr class="leafygreen-ui-15dvrnp"> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> { $substrCP: [ "abcde", 1, 2 ] } </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> "bc" </code> </div> </div> </td> </tr> <tr class="leafygreen-ui-15dvrnp"> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> { $substrCP: [ "Hello World!", 6, 5 ] } </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> "World" </code> </div> </div> </td> </tr> <tr class="leafygreen-ui-15dvrnp"> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> { $substrCP: [ "cafétéria", 0, 5 ] } </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> "cafét" </code> </div> </div> </td> </tr> <tr class="leafygreen-ui-15dvrnp"> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> { $substrCP: [ "cafétéria", 5, 4 ] } </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> "éria" </code> </div> </div> </td> </tr> <tr class="leafygreen-ui-15dvrnp"> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> { $substrCP: [ "cafétéria", 7, 3 ] } </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> "ia" </code> </div> </div> </td> </tr> <tr class="leafygreen-ui-15dvrnp"> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> { $substrCP: [ "cafétéria", 3, 1 ] } </code> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> "é" </code> </div> </div> </td> </tr> </tbody> </table> </div> </dd> </dl> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Behavior <a class="headerlink leafygreen-ui-1kepx47" href="#behavior" 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="behavior"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> The <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-expression-exp.-substrCP" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $substrCP </code> </span> </a> operator uses the code points to extract the substring. This behavior differs from the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/substrBytes/#mongodb-expression-exp.-substrBytes"> <code class="leafygreen-ui-1l06pbn"> $substrBytes </code> </a> operator which extracts the substring by the number of bytes, where each character uses between one and four bytes. </p> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Example <a class="headerlink leafygreen-ui-1kepx47" href="#example" 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="example"> </div> </a> </h2> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Single-Byte Character Set <a class="headerlink leafygreen-ui-1kepx47" href="#single-byte-character-set" 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="single-byte-character-set"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> Consider an <code class="leafygreen-ui-1l06pbn"> inventory </code> collection with the following documents: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ \"_id\" : 1, \"item\" : \"ABC1\", quarter: \"13Q1\", \"description\" : \"product 1\" }\n{ \"_id\" : 2, \"item\" : \"ABC2\", quarter: \"13Q4\", \"description\" : \"product 2\" }\n{ \"_id\" : 3, \"item\" : \"XYZ1\", quarter: \"14Q2\", \"description\" : null }","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">1</span>, <span class="lg-highlight-string">"item"</span> <!-- -->: <span class="lg-highlight-string">"ABC1"</span>, <span class="lg-highlight-attr">quarter</span>: <span class="lg-highlight-string">"13Q1"</span>, <span class="lg-highlight-string">"description"</span> <!-- -->: <span class="lg-highlight-string">"product 1"</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">2</span>, <span class="lg-highlight-string">"item"</span> <!-- -->: <span class="lg-highlight-string">"ABC2"</span>, <span class="lg-highlight-attr">quarter</span>: <span class="lg-highlight-string">"13Q4"</span>, <span class="lg-highlight-string">"description"</span> <!-- -->: <span class="lg-highlight-string">"product 2"</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">3</span>, <span class="lg-highlight-string">"item"</span> <!-- -->: <span class="lg-highlight-string">"XYZ1"</span>, <span class="lg-highlight-attr">quarter</span>: <span class="lg-highlight-string">"14Q2"</span>, <span class="lg-highlight-string">"description"</span> <!-- -->: <span class="lg-highlight-literal">null</span> }</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 operation uses the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-expression-exp.-substrCP" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> $substrCP </code> </span> </a> operator to separate the <code class="leafygreen-ui-1l06pbn"> quarter </code> value into a <code class="leafygreen-ui-1l06pbn"> yearSubstring </code> and a <code class="leafygreen-ui-1l06pbn"> quarterSubstring </code> . The <code class="leafygreen-ui-1l06pbn"> quarterSubstring </code> field represents the rest of the string from the specified <code class="leafygreen-ui-1l06pbn"> byte index </code> following the <code class="leafygreen-ui-1l06pbn"> yearSubstring </code> . It is calculated by subtracting the <code class="leafygreen-ui-1l06pbn"> byte index </code> from the length of the string using <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/strLenCP/#mongodb-expression-exp.-strLenCP"> <code class="leafygreen-ui-1l06pbn"> $strLenCP </code> . </a> </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.inventory.aggregate(\n [\n {\n $project: {\n item: 1,\n yearSubstring: { $substrCP: [ \"$quarter\", 0, 2 ] },\n quarterSubtring: {\n $substrCP: [\n \"$quarter\", 2, { $subtract: [ { $strLenCP: \"$quarter\" }, 2 ] }\n ]\n }\n }\n }\n ]\n)","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><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">inventory</span>.<span class="lg-highlight-title lg-highlight-function">aggregate</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">$project</span>: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">item</span>: <span class="lg-highlight-number">1</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">yearSubstring</span>: <!-- -->{ <span class="lg-highlight-attr">$substrCP</span>: <!-- -->[ <span class="lg-highlight-string">"$quarter"</span>, <span class="lg-highlight-number">0</span>, <span class="lg-highlight-number">2</span> ] }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">quarterSubtring</span>: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">$substrCP</span>: <!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"$quarter"</span>, <span class="lg-highlight-number">2</span>, <!-- -->{ <span class="lg-highlight-attr">$subtract</span>: <!-- -->[ <!-- -->{ <span class="lg-highlight-attr">$strLenCP</span>: <span class="lg-highlight-string">"$quarter"</span> }<!-- -->, <span class="lg-highlight-number">2</span> ] }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> ]</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> ]</td></tr><tr class=""><td class="leafygreen-ui-7razhx">)</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 operation returns the following results: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ \"_id\" : 1, \"item\" : \"ABC1\", \"yearSubstring\" : \"13\", \"quarterSubtring\" : \"Q1\" }\n{ \"_id\" : 2, \"item\" : \"ABC2\", \"yearSubstring\" : \"13\", \"quarterSubtring\" : \"Q4\" }\n{ \"_id\" : 3, \"item\" : \"XYZ1\", \"yearSubstring\" : \"14\", \"quarterSubtring\" : \"Q2\" }","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">1</span>, <span class="lg-highlight-string">"item"</span> <!-- -->: <span class="lg-highlight-string">"ABC1"</span>, <span class="lg-highlight-string">"yearSubstring"</span> <!-- -->: <span class="lg-highlight-string">"13"</span>, <span class="lg-highlight-string">"quarterSubtring"</span> <!-- -->: <span class="lg-highlight-string">"Q1"</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">2</span>, <span class="lg-highlight-string">"item"</span> <!-- -->: <span class="lg-highlight-string">"ABC2"</span>, <span class="lg-highlight-string">"yearSubstring"</span> <!-- -->: <span class="lg-highlight-string">"13"</span>, <span class="lg-highlight-string">"quarterSubtring"</span> <!-- -->: <span class="lg-highlight-string">"Q4"</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">3</span>, <span class="lg-highlight-string">"item"</span> <!-- -->: <span class="lg-highlight-string">"XYZ1"</span>, <span class="lg-highlight-string">"yearSubstring"</span> <!-- -->: <span class="lg-highlight-string">"14"</span>, <span class="lg-highlight-string">"quarterSubtring"</span> <!-- -->: <span class="lg-highlight-string">"Q2"</span> }</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> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Single-Byte and Multibyte Character Set <a class="headerlink leafygreen-ui-1kepx47" href="#single-byte-and-multibyte-character-set" 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="single-byte-and-multibyte-character-set"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> Create a <code class="leafygreen-ui-1l06pbn"> food </code> collection with the following documents: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.food.insertMany(\n [\n { \"_id\" : 1, \"name\" : \"apple\" },\n { \"_id\" : 2, \"name\" : \"banana\" },\n { \"_id\" : 3, \"name\" : \"éclair\" },\n { \"_id\" : 4, \"name\" : \"hamburger\" },\n { \"_id\" : 5, \"name\" : \"jalapeño\" },\n { \"_id\" : 6, \"name\" : \"pizza\" },\n { \"_id\" : 7, \"name\" : \"tacos\" },\n { \"_id\" : 8, \"name\" : \"寿司sushi\" }\n ]\n)","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">food</span>.<span class="lg-highlight-title lg-highlight-function">insertMany</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">1</span>, <span class="lg-highlight-string">"name"</span> <!-- -->: <span class="lg-highlight-string">"apple"</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">2</span>, <span class="lg-highlight-string">"name"</span> <!-- -->: <span class="lg-highlight-string">"banana"</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">3</span>, <span class="lg-highlight-string">"name"</span> <!-- -->: <span class="lg-highlight-string">"éclair"</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">4</span>, <span class="lg-highlight-string">"name"</span> <!-- -->: <span class="lg-highlight-string">"hamburger"</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">5</span>, <span class="lg-highlight-string">"name"</span> <!-- -->: <span class="lg-highlight-string">"jalapeño"</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">6</span>, <span class="lg-highlight-string">"name"</span> <!-- -->: <span class="lg-highlight-string">"pizza"</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">7</span>, <span class="lg-highlight-string">"name"</span> <!-- -->: <span class="lg-highlight-string">"tacos"</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">8</span>, <span class="lg-highlight-string">"name"</span> <!-- -->: <span class="lg-highlight-string">"寿司sushi"</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> ]</td></tr><tr class=""><td class="leafygreen-ui-7razhx">)</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 example uses the <code class="leafygreen-ui-1l06pbn"> $substrCP </code> operator to create a three byte <code class="leafygreen-ui-1l06pbn"> menuCode </code> from the <code class="leafygreen-ui-1l06pbn"> name </code> value: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.food.aggregate(\n [\n {\n $project: {\n \"name\": 1,\n \"menuCode\": { $substrCP: [ \"$name\", 0, 3 ] }\n }\n }\n ]\n)","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">food</span>.<span class="lg-highlight-title lg-highlight-function">aggregate</span>(</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-attr">$project</span>: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"name"</span>: <span class="lg-highlight-number">1</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> <span class="lg-highlight-string">"menuCode"</span>: <!-- -->{ <span class="lg-highlight-attr">$substrCP</span>: <!-- -->[ <span class="lg-highlight-string">"$name"</span>, <span class="lg-highlight-number">0</span>, <span class="lg-highlight-number">3</span> ] }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> ]</td></tr><tr class=""><td class="leafygreen-ui-7razhx">)</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 operation returns the following results: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ \"_id\" : 1, \"name\" : \"apple\", \"menuCode\" : \"app\" }\n{ \"_id\" : 2, \"name\" : \"banana\", \"menuCode\" : \"ban\" }\n{ \"_id\" : 3, \"name\" : \"éclair\", \"menuCode\" : \"écl\" }\n{ \"_id\" : 4, \"name\" : \"hamburger\", \"menuCode\" : \"ham\" }\n{ \"_id\" : 5, \"name\" : \"jalapeño\", \"menuCode\" : \"jal\" }\n{ \"_id\" : 6, \"name\" : \"pizza\", \"menuCode\" : \"piz\" }\n{ \"_id\" : 7, \"name\" : \"tacos\", \"menuCode\" : \"tac\" }\n{ \"_id\" : 8, \"name\" : \"寿司sushi\", \"menuCode\" : \"寿司s\" }","programmingLanguage":"JavaScript"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-yzcs8i"> <pre class="leafygreen-ui-11itue3" 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">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">1</span>, <span class="lg-highlight-string">"name"</span> <!-- -->: <span class="lg-highlight-string">"apple"</span>, <span class="lg-highlight-string">"menuCode"</span> <!-- -->: <span class="lg-highlight-string">"app"</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">2</span>, <span class="lg-highlight-string">"name"</span> <!-- -->: <span class="lg-highlight-string">"banana"</span>, <span class="lg-highlight-string">"menuCode"</span> <!-- -->: <span class="lg-highlight-string">"ban"</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">3</span>, <span class="lg-highlight-string">"name"</span> <!-- -->: <span class="lg-highlight-string">"éclair"</span>, <span class="lg-highlight-string">"menuCode"</span> <!-- -->: <span class="lg-highlight-string">"écl"</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">4</span>, <span class="lg-highlight-string">"name"</span> <!-- -->: <span class="lg-highlight-string">"hamburger"</span>, <span class="lg-highlight-string">"menuCode"</span> <!-- -->: <span class="lg-highlight-string">"ham"</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">5</span>, <span class="lg-highlight-string">"name"</span> <!-- -->: <span class="lg-highlight-string">"jalapeño"</span>, <span class="lg-highlight-string">"menuCode"</span> <!-- -->: <span class="lg-highlight-string">"jal"</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">6</span>, <span class="lg-highlight-string">"name"</span> <!-- -->: <span class="lg-highlight-string">"pizza"</span>, <span class="lg-highlight-string">"menuCode"</span> <!-- -->: <span class="lg-highlight-string">"piz"</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">7</span>, <span class="lg-highlight-string">"name"</span> <!-- -->: <span class="lg-highlight-string">"tacos"</span>, <span class="lg-highlight-string">"menuCode"</span> <!-- -->: <span class="lg-highlight-string">"tac"</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">{ <span class="lg-highlight-string">"_id"</span> <!-- -->: <span class="lg-highlight-number">8</span>, <span class="lg-highlight-string">"name"</span> <!-- -->: <span class="lg-highlight-string">"寿司sushi"</span>, <span class="lg-highlight-string">"menuCode"</span> <!-- -->: <span class="lg-highlight-string">"寿司s"</span> }</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-13vw3ie" role="note"> <h2 class="leafygreen-ui-1fn4p2b"> Tip </h2> <h3 class="leafygreen-ui-144d5kf"> <strong> See also: </strong> </h3> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/substrBytes/#mongodb-expression-exp.-substrBytes"> <code class="leafygreen-ui-1l06pbn"> $substrBytes </code> </a> </p> </div> </div> </section> </section> </section>
https://www.mongodb.com/docs/manual/tutorial/install-mongodb-enterprise-on-suse-tarball/
<section> <h1 class="contains-headerlink leafygreen-ui-41fr9s" weight="medium"> Install MongoDB Enterprise on SUSE using .tgz Tarball <a class="headerlink leafygreen-ui-1kepx47" href="#install-mongodb-enterprise-on-suse-using-.tgz-tarball" 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="install-mongodb-enterprise-on-suse-using-.tgz-tarball"> </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="#overview" target="_self"> <span> Overview </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#considerations" target="_self"> <span> Considerations </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#install-mongodb-enterprise-edition" target="_self"> <span> Install MongoDB Enterprise Edition </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#run-mongodb-enterprise-edition" target="_self"> <span> Run MongoDB Enterprise Edition </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#additional-information" target="_self"> <span> Additional Information </span> </a> </li> </ul> </div> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Overview <a class="headerlink leafygreen-ui-1kepx47" href="#overview" 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="overview"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> Use this tutorial to manually install MongoDB 8.0 <!-- --> Enterprise <!-- --> Edition on SUSE Linux Enterprise Server (SLES) using a downloaded <code class="leafygreen-ui-1l06pbn"> .tgz </code> tarball. </p> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/products/mongodb-enterprise-advanced?tck=docs_server" target="_self"> <span> MongoDB Enterprise Edition </span> </a> is available on select platforms and contains support for several features related to security and monitoring. </p> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> MongoDB Version <a class="headerlink leafygreen-ui-1kepx47" href="#mongodb-version" 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="mongodb-version"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> This tutorial installs MongoDB 8.0 <!-- --> Enterprise <!-- --> Edition. To install a different version of MongoDB <!-- --> Enterprise <!-- --> , use the version drop-down menu in the upper-left corner of this page to select the documentation for that version. </p> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Installation Method <a class="headerlink leafygreen-ui-1kepx47" href="#installation-method" 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="installation-method"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> While MongoDB can be installed manually via a downloaded <code class="leafygreen-ui-1l06pbn"> .tgz </code> tarball as described in this document, it is recommended to use the <code class="leafygreen-ui-1l06pbn"> zypper </code> package manager on your system to install MongoDB if possible. Using a package manager automatically installs all needed dependencies, provides an example <code class="leafygreen-ui-1l06pbn"> mongod.conf </code> file to get you started, and simplifies future upgrade and maintenance tasks. </p> <p class="leafygreen-ui-1kp3ins"> ➤ <!-- --> See <a class="leafygreen-ui-tqgtui" href="/docs/manual/tutorial/install-mongodb-enterprise-on-suse/"> Install MongoDB using the zypper Package Manager </a> for instructions. </p> </section> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Considerations <a class="headerlink leafygreen-ui-1kepx47" href="#considerations" 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="considerations"> </div> </a> </h2> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> MongoDB Shell, <code class="leafygreen-ui-1l06pbn"> mongosh </code> <a class="headerlink leafygreen-ui-1kepx47" href="#mongodb-shell--mongosh" 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="mongodb-shell--mongosh"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> When you use the <code class="leafygreen-ui-1l06pbn"> .tgz </code> package to install the server, you need to follow the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/mongodb-shell/install/" target="_self"> <span> mongosh installation instructions </span> </a> to download and install <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/mongodb-shell/" target="_self"> <span> mongosh </span> </a> separately. </p> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Platform Support <a class="headerlink leafygreen-ui-1kepx47" href="#platform-support" 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="platform-support"> </div> </a> </h3> <div class="leafygreen-ui-15mdk4" role="note"> <h2 class="leafygreen-ui-6n7b7d"> Note </h2> <h3 class="leafygreen-ui-144d5kf"> <strong> EOL Notice </strong> </h3> <div class="leafygreen-ui-9mycqc"> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> MongoDB 5.0 Enterprise Edition removes support for SLES12 on <a class="leafygreen-ui-tqgtui" href="/docs/manual/administration/production-notes/#std-label-prod-notes-supported-platforms-s390x"> s390x </a> </p> </li> </ul> </div> </div> <p class="leafygreen-ui-1kp3ins"> MongoDB 8.0 Enterprise Edition supports the following <strong class="css-4dei7l"> 64-bit </strong> SUSE Linux Enterprise Server (SLES) releases on <a class="leafygreen-ui-tqgtui" href="/docs/manual/administration/production-notes/#std-label-prod-notes-supported-platforms-x86_64"> x86_64 </a> architecture: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <span class="leafygreen-ui-vm4wms" tabindex="0"> SLES </span> 15 </p> </li> </ul> <p class="leafygreen-ui-1kp3ins"> MongoDB only supports the 64-bit versions of these platforms. </p> <p class="leafygreen-ui-1kp3ins"> See <a class="leafygreen-ui-tqgtui" href="/docs/manual/administration/production-notes/#std-label-prod-notes-supported-platforms"> Platform Support </a> for more information. </p> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Production Notes <a class="headerlink leafygreen-ui-1kepx47" href="#production-notes" 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="production-notes"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> Before deploying MongoDB in a production environment, consider the <a class="leafygreen-ui-tqgtui" href="/docs/manual/administration/production-notes/"> Production Notes for Self-Managed Deployments </a> document which offers performance considerations and configuration recommendations for production MongoDB deployments. </p> <span class="leafygreen-ui-1qnjd6d" id="std-label-install-enterprise-suse-from-tarball"> </span> </section> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Install MongoDB Enterprise Edition <a class="headerlink leafygreen-ui-1kepx47" href="#install-mongodb-enterprise-edition" 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="install-mongodb-enterprise-edition"> </div> </a> </h2> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Prerequisites <a class="headerlink leafygreen-ui-1kepx47" href="#prerequisites" 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="prerequisites"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> Use the following command to install the dependencies required for the MongoDB <!-- --> Enterprise <!-- --> <code class="leafygreen-ui-1l06pbn"> .tgz </code> tarball: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"sudo zypper install cyrus-sasl cyrus-sasl-plain cyrus-sasl-gssapi krb5 libcurl4 libldap-2_4-2 libopenssl1_1 libsensors4 libwrap0","programmingLanguage":"Bash"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-1q4bxgx" tabindex="0"><code class="lg-highlight-hljs-light bash leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">sudo zypper install cyrus-sasl cyrus-sasl-plain cyrus-sasl-gssapi krb5 libcurl4 libldap-2_4-2 libopenssl1_1 libsensors4 libwrap0</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> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Procedure <a class="headerlink leafygreen-ui-1kepx47" href="#procedure" 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="procedure"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> Follow these steps to manually install MongoDB <!-- --> Enterprise <!-- --> Edition from the <code class="leafygreen-ui-1l06pbn"> .tgz </code> . </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"HowTo","steps":[{"@type":"HowToStep","text":"Download the tarball.After you have installed the required prerequisite packages, download\nthe MongoDB Enterprise tgz tarball from the following link:➤ MongoDB Download CenterIn the Version dropdown, select the version of\nMongoDB to download.In the Platform dropdown, select your operating system\nversion and architecture.In the Package dropdown, select tgz.Click Download."},{"@type":"HowToStep","text":"Extract the files from the downloaded archive.For example, from a system shell, you can extract using the tar command:"},{"@type":"HowToStep","text":"Ensure the binaries are in a directory listed in your PATH environment variable.The MongoDB binaries are in the bin/ directory of the tarball.\nYou can either:Copy the binaries into a directory listed in your PATH\nvariable, such as /usr/local/bin (Update\n/path/to/the/mongodb-directory/ with your installation\ndirectory as appropriate)Create symbolic links to the binaries from a directory listed in\nyour PATH variable, such as /usr/local/bin (Update\n/path/to/the/mongodb-directory/ with your installation\ndirectory as appropriate):"},{"@type":"HowToStep","text":"Install the MongoDB Shell (mongosh).Install mongosh then use the MongoDB Shell\nto connect to your deployment.Download the package for the version of mongosh you need from the\nMongoDB Download Center and uncompress the package."}],"name":"Procedure","image":"https://webimages.mongodb.com/_com_assets/cms/kuyj2focmkbxv7gh3-stacked_default_slate_blue.svg?auto=format%252Ccompress"} </script> <div class="css-4nyere eccljxs0"> <div class="css-1nuklj8 e1ckbxcu1"> <div class="css-18fui5z e1ckbxcu0"> <div class="css-19lsqsq e1ckbxcu2"> 1 </div> </div> <div class="css-1ed38mk"> <section> <h4 class="contains-headerlink leafygreen-ui-1vzlt5f"> Download the tarball. <a class="headerlink leafygreen-ui-1kepx47" href="#download-the-tarball" 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="download-the-tarball"> </div> </a> </h4> <p class="leafygreen-ui-1kp3ins"> After you have installed the required prerequisite packages, download the MongoDB <!-- --> Enterprise <!-- --> <code class="leafygreen-ui-1l06pbn"> tgz </code> tarball from the following link: </p> <p class="leafygreen-ui-1kp3ins"> ➤ <!-- --> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/try/download/enterprise?tck=docs_server" target="_self"> <span> MongoDB Download Center </span> </a> </p> <ol class="leafygreen-ui-rioki0" type="a"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> In the <span class="guilabel css-h15tq0"> Version </span> dropdown, select the version of MongoDB to download. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> In the <span class="guilabel css-h15tq0"> Platform </span> dropdown, select your operating system version and architecture. </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> In the <span class="guilabel css-h15tq0"> Package </span> dropdown, select <span class="guilabel css-h15tq0"> tgz </span> . </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Click <span class="guilabel css-h15tq0"> Download </span> . </p> </li> </ol> </section> </div> </div> <div class="css-1nuklj8 e1ckbxcu1"> <div class="css-18fui5z e1ckbxcu0"> <div class="css-19lsqsq e1ckbxcu2"> 2 </div> </div> <div class="css-1ed38mk"> <section> <h4 class="contains-headerlink leafygreen-ui-1vzlt5f"> Extract the files from the downloaded archive. <a class="headerlink leafygreen-ui-1kepx47" href="#extract-the-files-from-the-downloaded-archive" 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="extract-the-files-from-the-downloaded-archive"> </div> </a> </h4> <p class="leafygreen-ui-1kp3ins"> For example, from a system shell, you can extract using the <code class="leafygreen-ui-1l06pbn"> tar </code> command: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"tar -zxvf mongodb-linux-*-8.0.0.tgz","programmingLanguage":"Bash"} </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 bash leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">tar -zxvf mongodb-linux-*-8.0.0.tgz</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> </section> </div> </div> <div class="css-1nuklj8 e1ckbxcu1"> <div class="css-18fui5z e1ckbxcu0"> <div class="css-19lsqsq e1ckbxcu2"> 3 </div> </div> <div class="css-1ed38mk"> <section> <h4 class="contains-headerlink leafygreen-ui-1vzlt5f"> Ensure the binaries are in a directory listed in your <code class="leafygreen-ui-1l06pbn"> PATH </code> environment variable. <a class="headerlink leafygreen-ui-1kepx47" href="#ensure-the-binaries-are-in-a-directory-listed-in-your-path-environment-variable" 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="ensure-the-binaries-are-in-a-directory-listed-in-your-path-environment-variable"> </div> </a> </h4> <p class="leafygreen-ui-1kp3ins"> The MongoDB binaries are in the <code class="leafygreen-ui-1l06pbn"> bin/ </code> directory of the tarball. You can either: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Copy the binaries into a directory listed in your <code class="leafygreen-ui-1l06pbn"> PATH </code> variable, such as <code class="leafygreen-ui-1l06pbn"> /usr/local/bin </code> (Update <code class="leafygreen-ui-1l06pbn"> /path/to/the/mongodb-directory/ </code> with your installation directory as appropriate) </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"sudo cp /path/to/the/mongodb-directory/bin/* /usr/local/bin/","programmingLanguage":"Bash"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-1q4bxgx" tabindex="0"><code class="lg-highlight-hljs-light bash leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">sudo <span class="lg-highlight-built_in">cp</span> <!-- -->/path/to/the/mongodb-directory/bin<!-- -->/* <!-- -->/usr/local/bin<!-- -->/</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> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> Create symbolic links to the binaries from a directory listed in your <code class="leafygreen-ui-1l06pbn"> PATH </code> variable, such as <code class="leafygreen-ui-1l06pbn"> /usr/local/bin </code> (Update <code class="leafygreen-ui-1l06pbn"> /path/to/the/mongodb-directory/ </code> with your installation directory as appropriate): </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"sudo ln -s /path/to/the/mongodb-directory/bin/* /usr/local/bin/","programmingLanguage":"Bash"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-1q4bxgx" tabindex="0"><code class="lg-highlight-hljs-light bash leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">sudo <span class="lg-highlight-built_in">ln</span> -s <!-- -->/path/to/the/mongodb-directory/bin<!-- -->/* <!-- -->/usr/local/bin<!-- -->/</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> </li> </ul> </section> </div> </div> <div class="css-1nuklj8 e1ckbxcu1"> <div class="css-18fui5z e1ckbxcu0"> <div class="css-19lsqsq e1ckbxcu2"> 4 </div> </div> <div class="css-1ed38mk"> <section> <h4 class="contains-headerlink leafygreen-ui-1vzlt5f"> Install the MongoDB Shell ( <code class="leafygreen-ui-1l06pbn"> mongosh </code> ). <a class="headerlink leafygreen-ui-1kepx47" href="#install-the-mongodb-shell-mongosh" 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="install-the-mongodb-shell-mongosh"> </div> </a> </h4> <p class="leafygreen-ui-1kp3ins"> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/mongodb-shell/install/" target="_self"> <span> Install </span> </a> <code class="leafygreen-ui-1l06pbn"> mongosh </code> then use the MongoDB Shell to connect to your deployment. </p> <p class="leafygreen-ui-1kp3ins"> Download the package for the version of <code class="leafygreen-ui-1l06pbn"> mongosh </code> you need from the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/try/download/enterprise?tck=docs_server" target="_self"> <span> MongoDB Download Center </span> </a> and uncompress the package. </p> </section> </div> </div> </div> </section> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Run MongoDB Enterprise Edition <a class="headerlink leafygreen-ui-1kepx47" href="#run-mongodb-enterprise-edition" 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="run-mongodb-enterprise-edition"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> By default, a MongoDB instance stores: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> its data files in <code class="leafygreen-ui-1l06pbn"> /var/lib/mongo </code> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> its log files in <code class="leafygreen-ui-1l06pbn"> /var/log/mongodb </code> </p> </li> </ul> <p class="leafygreen-ui-1kp3ins"> If you installed via the package manager, these default directories are created during the installation. </p> <p class="leafygreen-ui-1kp3ins"> If you installed manually by downloading the tarballs, you can create the directories using <code class="leafygreen-ui-1l06pbn"> mkdir -p &lt;directory&gt; </code> or <code class="leafygreen-ui-1l06pbn"> sudo mkdir -p &lt;directory&gt; </code> depending on the user that will run MongoDB. (See your linux man pages for information on <code class="leafygreen-ui-1l06pbn"> mkdir </code> and <code class="leafygreen-ui-1l06pbn"> sudo </code> .) </p> <p class="leafygreen-ui-1kp3ins"> By default, MongoDB runs using the <code class="leafygreen-ui-1l06pbn"> mongod </code> user account. If you change the user that runs the MongoDB process, you <strong> must </strong> also modify the permission to the <code class="leafygreen-ui-1l06pbn"> /var/lib/mongo </code> and <code class="leafygreen-ui-1l06pbn"> /var/log/mongodb </code> directories to give this user access to these directories. </p> <p class="leafygreen-ui-1kp3ins"> To specify a different log file directory and data file directory, edit the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/configuration-options/#mongodb-setting-systemLog.path"> <code class="leafygreen-ui-1l06pbn"> systemLog.path </code> </a> and <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/configuration-options/#mongodb-setting-storage.dbPath"> <code class="leafygreen-ui-1l06pbn"> storage.dbPath </code> </a> settings in the <code class="leafygreen-ui-1l06pbn"> /etc/mongod.conf </code> . Ensure that the user running MongoDB has access to these directories. </p> <p class="leafygreen-ui-1kp3ins"> Most Unix-like operating systems limit the system resources that a process may use. These limits may negatively impact MongoDB operation, and should be adjusted. See <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/ulimit/"> UNIX <code class="leafygreen-ui-1l06pbn"> ulimit </code> Settings for Self-Managed Deployments </a> for the recommended settings for your platform. </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"> If the <code class="leafygreen-ui-1l06pbn"> ulimit </code> value for number of open files is under <code class="leafygreen-ui-1l06pbn"> 64000 </code> , MongoDB generates a startup warning. </p> </div> </div> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Procedure <a class="headerlink leafygreen-ui-1kepx47" href="#procedure-1" 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="procedure-1"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> Follow these steps to run MongoDB <!-- --> Enterprise <!-- --> Edition. These instructions assume that you are using the default settings. </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"HowTo","steps":[{"@type":"HowToStep","text":"Create the data and log directories.Create a directory where the MongoDB instance stores its data. For\nexample:Create a directory where the MongoDB instance stores its log. For example:The user that starts the MongoDB process must have read and write\npermission to these directories. For example, if you intend to run\nMongoDB as yourself:"},{"@type":"HowToStep","text":"Run MongoDB.To run MongoDB, run the mongod process at the system prompt.For details on the command-line options --dbpath and --logpath, see\nOptions."},{"@type":"HowToStep","text":"Verify that MongoDB has started successfully.Verify that MongoDB has started successfully by\nchecking the process output for the following line in the\nlog file /var/log/mongodb/mongod.log:You may see non-critical warnings in the process\noutput. As long as you see the log line shown above, you can safely\nignore these warnings during your initial evaluation of MongoDB."},{"@type":"HowToStep","text":"Begin using MongoDB.Start a mongosh session on the same host machine as the\nmongod. You can run mongosh\nwithout any command-line options to connect to a\nmongod that is running on your localhost with default\nport 27017.For more information on connecting using mongosh,\nsuch as to connect to a mongod instance running\non a different host and/or port, see the\nmongosh documentation.To help you start using MongoDB, MongoDB provides Getting\nStarted Guides in various driver editions. For the\ndriver documentation, see Start Developing with MongoDB."}],"name":"Procedure","image":"https://webimages.mongodb.com/_com_assets/cms/kuyj2focmkbxv7gh3-stacked_default_slate_blue.svg?auto=format%252Ccompress"} </script> <div class="css-4nyere eccljxs0"> <div class="css-1nuklj8 e1ckbxcu1"> <div class="css-18fui5z e1ckbxcu0"> <div class="css-19lsqsq e1ckbxcu2"> 1 </div> </div> <div class="css-1ed38mk"> <section> <h4 class="contains-headerlink leafygreen-ui-1vzlt5f"> Create the data and log directories. <a class="headerlink leafygreen-ui-1kepx47" href="#create-the-data-and-log-directories" 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="create-the-data-and-log-directories"> </div> </a> </h4> <p class="leafygreen-ui-1kp3ins"> Create a directory where the MongoDB instance stores its data. For example: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"sudo mkdir -p /var/lib/mongo","programmingLanguage":"Bash"} </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 bash leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">sudo <span class="lg-highlight-built_in">mkdir</span> -p <!-- -->/var/lib/mongo</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"> Create a directory where the MongoDB instance stores its log. For example: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"sudo mkdir -p /var/log/mongodb","programmingLanguage":"Bash"} </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 bash leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">sudo <span class="lg-highlight-built_in">mkdir</span> -p <!-- -->/var/log/mongodb</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 user that starts the MongoDB process must have read and write permission to these directories. For example, if you intend to run MongoDB as yourself: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"sudo chown `whoami` /var/lib/mongo # Or substitute another user\nsudo chown `whoami` /var/log/mongodb # Or substitute another user","programmingLanguage":"Bash"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-11itue3" tabindex="0"><code class="lg-highlight-hljs-light bash leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">sudo <span class="lg-highlight-built_in">chown</span> `<span class="lg-highlight-built_in">whoami</span>` <!-- -->/var/lib/mongo<!-- --> <span class="lg-highlight-comment"># Or substitute another user</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx">sudo <span class="lg-highlight-built_in">chown</span> `<span class="lg-highlight-built_in">whoami</span>` <!-- -->/var/log/mongodb<!-- --> <span class="lg-highlight-comment"># Or substitute another user</span></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> </section> </div> </div> <div class="css-1nuklj8 e1ckbxcu1"> <div class="css-18fui5z e1ckbxcu0"> <div class="css-19lsqsq e1ckbxcu2"> 2 </div> </div> <div class="css-1ed38mk"> <section> <h4 class="contains-headerlink leafygreen-ui-1vzlt5f"> Run MongoDB. <a class="headerlink leafygreen-ui-1kepx47" href="#run-mongodb" 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="run-mongodb"> </div> </a> </h4> <p class="leafygreen-ui-1kp3ins"> To run MongoDB, run the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> process at the system prompt. </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"mongod --dbpath /var/lib/mongo --logpath /var/log/mongodb/mongod.log --fork","programmingLanguage":"Bash"} </script> <div class="css-16lmvu9"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1b1bvay"> <pre class="leafygreen-ui-1q4bxgx" tabindex="0"><code class="lg-highlight-hljs-light bash leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">mongod --dbpath <!-- -->/var/lib/mongo<!-- --> --logpath <!-- -->/var/log/mongodb/mongod.log<!-- --> --fork</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"> For details on the command-line options <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#std-option-mongod.--dbpath"> <code class="leafygreen-ui-1l06pbn"> --dbpath </code> </a> and <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#std-option-mongod.--logpath"> <code class="leafygreen-ui-1l06pbn"> --logpath </code> </a> , see <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#std-label-mongod-options"> Options <!-- --> . </a> </p> </section> </div> </div> <div class="css-1nuklj8 e1ckbxcu1"> <div class="css-18fui5z e1ckbxcu0"> <div class="css-19lsqsq e1ckbxcu2"> 3 </div> </div> <div class="css-1ed38mk"> <section> <h4 class="contains-headerlink leafygreen-ui-1vzlt5f"> Verify that MongoDB has started successfully. <a class="headerlink leafygreen-ui-1kepx47" href="#verify-that-mongodb-has-started-successfully" 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="verify-that-mongodb-has-started-successfully"> </div> </a> </h4> <p class="leafygreen-ui-1kp3ins"> Verify that MongoDB has started successfully by checking the process output for the following line in the log file <code class="leafygreen-ui-1l06pbn"> /var/log/mongodb/mongod.log </code> : </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"[initandlisten] waiting for connections on port 27017\n"} </script> <div class="css-1lju8ps"> <div class="leafygreen-ui-196mwvg"> <div class="leafygreen-ui-1jheeh3"> <pre class="leafygreen-ui-1agdxuk" tabindex="-1"><code class="lg-highlight-hljs-light none leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">[initandlisten] waiting for connections on port 27017</td></tr></tbody></table></code></pre> </div> </div> </div> <p class="leafygreen-ui-1kp3ins"> You may see non-critical warnings in the process output. As long as you see the log line shown above, you can safely ignore these warnings during your initial evaluation of MongoDB. </p> </section> </div> </div> <div class="css-1nuklj8 e1ckbxcu1"> <div class="css-18fui5z e1ckbxcu0"> <div class="css-19lsqsq e1ckbxcu2"> 4 </div> </div> <div class="css-1ed38mk"> <section> <h4 class="contains-headerlink leafygreen-ui-1vzlt5f"> Begin using MongoDB. <a class="headerlink leafygreen-ui-1kepx47" href="#begin-using-mongodb" 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="begin-using-mongodb"> </div> </a> </h4> <p class="leafygreen-ui-1kp3ins"> Start a <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/mongodb-shell/#mongodb-binary-bin.mongosh" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongosh </code> </span> </a> session on the same host machine as the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> . You can run <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/mongodb-shell/#mongodb-binary-bin.mongosh" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongosh </code> </span> </a> without any command-line options to connect to a <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> that is running on your localhost with default port 27017. </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"\nmongosh\n","programmingLanguage":"Shell"} </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 shell leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">mongosh</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"> For more information on connecting using <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/mongodb-shell/#mongodb-binary-bin.mongosh" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongosh </code> </span> </a> , such as to connect to a <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod"> <code class="leafygreen-ui-1l06pbn"> mongod </code> </a> instance running on a different host and/or port, see the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/mongodb-shell/" target="_self"> <span> mongosh documentation <!-- --> . </span> </a> </p> <p class="leafygreen-ui-1kp3ins"> To help you start using MongoDB, MongoDB provides <a class="leafygreen-ui-tqgtui" href="/docs/manual/tutorial/getting-started/#std-label-getting-started"> Getting Started Guides </a> in various driver editions. For the driver documentation, see <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://api.mongodb.com/" target="_self"> <span> Start Developing with MongoDB <!-- --> . </span> </a> </p> </section> </div> </div> </div> </section> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Additional Information <a class="headerlink leafygreen-ui-1kepx47" href="#additional-information" 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="additional-information"> </div> </a> </h2> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Localhost Binding by Default <a class="headerlink leafygreen-ui-1kepx47" href="#localhost-binding-by-default" 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="localhost-binding-by-default"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> By default, MongoDB launches with <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/configuration-options/#mongodb-setting-net.bindIp"> <code class="leafygreen-ui-1l06pbn"> bindIp </code> </a> set to <code class="leafygreen-ui-1l06pbn"> 127.0.0.1 </code> , which binds to the localhost network interface. This means that the <code class="leafygreen-ui-1l06pbn"> mongod </code> can only accept connections from clients that are running on the same machine. Remote clients will not be able to connect to the <code class="leafygreen-ui-1l06pbn"> mongod </code> , and the <code class="leafygreen-ui-1l06pbn"> mongod </code> will not be able to initialize a <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-replica-set"> replica set </a> unless this value is set to a valid network interface. </p> <p class="leafygreen-ui-1kp3ins"> This value can be configured either: </p> <ul class="leafygreen-ui-rioki0"> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> in the MongoDB configuration file with <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/configuration-options/#mongodb-setting-net.bindIp"> <code class="leafygreen-ui-1l06pbn"> bindIp </code> </a> , or </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> via the command-line argument <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#std-option-mongod.--bind_ip"> <code class="leafygreen-ui-1l06pbn"> --bind_ip </code> </a> </p> </li> </ul> <div class="leafygreen-ui-1sjx7ru" role="note"> <h2 class="leafygreen-ui-29m78u"> Warning </h2> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> Before you bind your instance to a publicly-accessible IP address, you must secure your cluster from unauthorized access. For a complete list of security recommendations, see <a class="leafygreen-ui-tqgtui" href="/docs/manual/administration/security-checklist/#std-label-security-checklist"> Security Checklist for Self-Managed Deployments </a> . At minimum, consider <a class="leafygreen-ui-tqgtui" href="/docs/manual/administration/security-checklist/#std-label-checklist-auth"> enabling authentication </a> and <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/security-hardening/#std-label-network-config-hardening"> hardening network infrastructure <!-- --> . </a> </p> </div> </div> <p class="leafygreen-ui-1kp3ins"> For more information on configuring <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/configuration-options/#mongodb-setting-net.bindIp"> <code class="leafygreen-ui-1l06pbn"> bindIp </code> </a> , see <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/security-mongodb-configuration/"> IP Binding in Self-Managed Deployments <!-- --> . </a> </p> </section> </section> </section>
https://www.mongodb.com/docs/manual/core/retryable-writes/
<section> <h1 class="contains-headerlink leafygreen-ui-41fr9s" weight="medium"> Retryable Writes <a class="headerlink leafygreen-ui-1kepx47" href="#retryable-writes" 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="retryable-writes"> </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="#prerequisites" target="_self"> <span> Prerequisites </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#retryable-writes-and-multi-document-transactions" target="_self"> <span> Retryable Writes and Multi-Document Transactions </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#enabling-retryable-writes" target="_self"> <span> Enabling Retryable Writes </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#retryable-write-operations" target="_self"> <span> Retryable Write Operations </span> </a> </li> <li class="leafygreen-ui-1jqtqlb"> <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#behavior" target="_self"> <span> Behavior </span> </a> </li> </ul> </div> <p class="leafygreen-ui-1kp3ins"> Retryable writes allow MongoDB drivers to automatically retry certain write operations a single time if they encounter network errors, or if they cannot find a healthy <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-primary"> primary </a> in the <a class="leafygreen-ui-tqgtui" href="/docs/manual/replication/#std-label-replication"> replica set </a> or <a class="leafygreen-ui-tqgtui" href="/docs/manual/sharding/#std-label-sharding-introduction"> sharded cluster <!-- --> . </a> </p> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Prerequisites <a class="headerlink leafygreen-ui-1kepx47" href="#prerequisites" 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="prerequisites"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> Retryable writes have the following requirements: </p> <dl> <dt> Supported Deployment Topologies </dt> <dd class="css-1ufxuu7"> Retryable writes require a <a class="leafygreen-ui-tqgtui" href="/docs/manual/replication/#std-label-replication"> replica set </a> or <a class="leafygreen-ui-tqgtui" href="/docs/manual/sharding/#std-label-sharding-introduction"> sharded cluster </a> , and do <strong> not </strong> support <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-standalone"> standalone instances <!-- --> . </a> </dd> <dt> Supported Storage Engine </dt> <dd class="css-1ufxuu7"> Retryable writes require a storage engine supporting document-level locking, such as the <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/wiredtiger/#std-label-storage-wiredtiger"> WiredTiger </a> or <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/inmemory/#std-label-storage-inmemory"> in-memory </a> storage engines. </dd> <dt> 3.6+ MongoDB Drivers </dt> <dd class="css-1ufxuu7"> <p class="leafygreen-ui-1kp3ins"> Clients require MongoDB drivers updated for MongoDB 3.6 or greater: </p> <div class="leafygreen-ui-skkc39" tabindex="0"> <table class="leafygreen-ui-hr8lsv"> <thead class="leafygreen-ui-a9ho40"> </thead> <tbody> <tr class=""> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <p class="leafygreen-ui-1kp3ins"> Java 3.6+ </p> <p class="leafygreen-ui-1kp3ins"> Python 3.6+ </p> <p class="leafygreen-ui-1kp3ins"> C 1.9+ </p> <p class="leafygreen-ui-1kp3ins"> Go 1.8+ </p> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <p class="leafygreen-ui-1kp3ins"> C# 2.5+ </p> <p class="leafygreen-ui-1kp3ins"> Node 3.0+ </p> <p class="leafygreen-ui-1kp3ins"> Ruby 2.5+ </p> <p class="leafygreen-ui-1kp3ins"> Rust 2.1+ </p> <p class="leafygreen-ui-1kp3ins"> Swift 1.2+ </p> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <p class="leafygreen-ui-1kp3ins"> Perl 2.0+ </p> <p class="leafygreen-ui-1kp3ins"> PHPC 1.4+ </p> <p class="leafygreen-ui-1kp3ins"> Scala 2.2+ </p> <p class="leafygreen-ui-1kp3ins"> C++ 3.6.6+ </p> </div> </div> </td> </tr> </tbody> </table> </div> </dd> <dt> MongoDB Version </dt> <dd class="css-1ufxuu7"> The MongoDB version of every node in the cluster must be <code class="leafygreen-ui-1l06pbn"> 3.6 </code> or greater, and the <code class="leafygreen-ui-1l06pbn"> featureCompatibilityVersion </code> of each node in the cluster must be <code class="leafygreen-ui-1l06pbn"> 3.6 </code> or greater. See <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/command/setFeatureCompatibilityVersion/#mongodb-dbcommand-dbcmd.setFeatureCompatibilityVersion"> <code class="leafygreen-ui-1l06pbn"> setFeatureCompatibilityVersion </code> </a> for more information on the <code class="leafygreen-ui-1l06pbn"> featureCompatibilityVersion </code> flag. </dd> <dt> Write Acknowledgment </dt> <dd class="css-1ufxuu7"> Write operations issued with a <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/write-concern/"> Write Concern </a> of <code class="leafygreen-ui-1l06pbn"> 0 </code> are <strong> not </strong> retryable. </dd> </dl> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Retryable Writes and Multi-Document Transactions <a class="headerlink leafygreen-ui-1kepx47" href="#retryable-writes-and-multi-document-transactions" 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="retryable-writes-and-multi-document-transactions"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> The <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/transactions-in-applications/#std-label-transactions-retry"> transaction commit and abort operations </a> are retryable write operations. If the commit operation or the abort operation encounters an error, MongoDB drivers retry the operation a single time regardless of whether <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/connection-string-options/#mongodb-urioption-urioption.retryWrites"> <code class="leafygreen-ui-1l06pbn"> retryWrites </code> </a> is set to <code class="leafygreen-ui-1l06pbn"> false </code> . </p> <p class="leafygreen-ui-1kp3ins"> The write operations inside the transaction are not individually retryable, regardless of value of <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/connection-string-options/#mongodb-urioption-urioption.retryWrites"> <code class="leafygreen-ui-1l06pbn"> retryWrites </code> . </a> </p> <p class="leafygreen-ui-1kp3ins"> For more information on transactions, see <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/transactions/"> Transactions <!-- --> . </a> </p> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Enabling Retryable Writes <a class="headerlink leafygreen-ui-1kepx47" href="#enabling-retryable-writes" 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="enabling-retryable-writes"> </div> </a> </h2> <dl> <dt> MongoDB Drivers </dt> <dd class="css-1ufxuu7"> Drivers compatible with MongoDB 4.2 and higher enable <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-retryable-writes" target="_self"> <span> Retryable Writes </span> </a> by default. Earlier drivers require the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/connection-string-options/#mongodb-urioption-urioption.retryWrites"> <code class="leafygreen-ui-1l06pbn"> retryWrites=true </code> </a> option. The <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/connection-string-options/#mongodb-urioption-urioption.retryWrites"> <code class="leafygreen-ui-1l06pbn"> retryWrites=true </code> </a> option can be omitted in applications that use drivers compatible with MongoDB 4.2 and higher. <div class="line-block"> <div class="line"> <br/> </div> </div> To disable retryable writes, applications that use drivers compatible with MongoDB 4.2 and higher must include <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/connection-string-options/#mongodb-urioption-urioption.retryWrites"> <code class="leafygreen-ui-1l06pbn"> retryWrites=false </code> </a> in the connection string. </dd> <dt> <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/mongodb-shell/#mongodb-binary-bin.mongosh" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongosh </code> </span> </a> </dt> <dd class="css-1ufxuu7"> <p class="leafygreen-ui-1kp3ins"> Retryable writes are enabled by default in <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/mongodb-shell/#mongodb-binary-bin.mongosh" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongosh </code> </span> </a> . To disable retryable writes, use the <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/mongodb-shell/reference/options/#std-option-mongosh.--retryWrites" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> --retryWrites=false </code> </span> </a> command line option: </p> <script class="structured_data" type="application/ld+json"> {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"mongosh --retryWrites=false","programmingLanguage":"Bash"} </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 bash leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">mongosh --retryWrites=<span class="lg-highlight-literal">false</span></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> </dd> </dl> <span class="leafygreen-ui-1qnjd6d" id="std-label-retryable-write-ops"> </span> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Retryable Write Operations <a class="headerlink leafygreen-ui-1kepx47" href="#retryable-write-operations" 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="retryable-write-operations"> </div> </a> </h2> <p class="leafygreen-ui-1kp3ins"> The following write operations are retryable when issued with acknowledged write concern; e.g., <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/write-concern/"> Write Concern </a> cannot be <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/write-concern/#mongodb-writeconcern-writeconcern.-number-"> <code class="leafygreen-ui-1l06pbn"> {w: 0} </code> . </a> </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"> The write operations inside the <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/transactions/"> transactions </a> are not individually retryable. </p> </div> </div> <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> Methods </div> </div> </th> <th class="leafygreen-ui-13uteka" role="columnheader" scope="col"> <div class="leafygreen-ui-ui0te9"> <div> Descriptions </div> </div> </th> </tr> </thead> <tbody> <tr class="leafygreen-ui-15dvrnp"> <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.insertOne/#mongodb-method-db.collection.insertOne"> <code class="leafygreen-ui-1l06pbn"> db.collection.insertOne() </code> </a> </div> <div class="line"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/db.collection.insertMany/#mongodb-method-db.collection.insertMany"> <code class="leafygreen-ui-1l06pbn"> db.collection.insertMany() </code> </a> </div> </div> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Insert operations </div> </div> </td> </tr> <tr class="leafygreen-ui-15dvrnp"> <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/#mongodb-method-db.collection.updateOne"> <code class="leafygreen-ui-1l06pbn"> db.collection.updateOne() </code> </a> </div> <div class="line"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/db.collection.replaceOne/#mongodb-method-db.collection.replaceOne"> <code class="leafygreen-ui-1l06pbn"> db.collection.replaceOne() </code> </a> </div> </div> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Single-document update operations </div> </div> </td> </tr> <tr class="leafygreen-ui-15dvrnp"> <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.deleteOne/#mongodb-method-db.collection.deleteOne"> <code class="leafygreen-ui-1l06pbn"> db.collection.deleteOne() </code> </a> </div> <div class="line"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/db.collection.remove/#mongodb-method-db.collection.remove"> <code class="leafygreen-ui-1l06pbn"> db.collection.remove() </code> </a> where <code class="leafygreen-ui-1l06pbn"> justOne </code> is <code class="leafygreen-ui-1l06pbn"> true </code> </div> </div> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Single document delete operations </div> </div> </td> </tr> <tr class="leafygreen-ui-15dvrnp"> <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.findAndModify/#mongodb-method-db.collection.findAndModify"> <code class="leafygreen-ui-1l06pbn"> db.collection.findAndModify() </code> </a> </div> <div class="line"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/db.collection.findOneAndDelete/#mongodb-method-db.collection.findOneAndDelete"> <code class="leafygreen-ui-1l06pbn"> db.collection.findOneAndDelete() </code> </a> </div> <div class="line"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/db.collection.findOneAndReplace/#mongodb-method-db.collection.findOneAndReplace"> <code class="leafygreen-ui-1l06pbn"> db.collection.findOneAndReplace() </code> </a> </div> <div class="line"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/db.collection.findOneAndUpdate/#mongodb-method-db.collection.findOneAndUpdate"> <code class="leafygreen-ui-1l06pbn"> db.collection.findOneAndUpdate() </code> </a> </div> </div> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <code class="leafygreen-ui-1l06pbn"> findAndModify </code> operations. All <code class="leafygreen-ui-1l06pbn"> findAndModify </code> operations are single document operations. </div> </div> </td> </tr> <tr class="leafygreen-ui-15dvrnp"> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/db.collection.bulkWrite/#mongodb-method-db.collection.bulkWrite"> <code class="leafygreen-ui-1l06pbn"> db.collection.bulkWrite() </code> </a> with the following write operations: </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/method/db.collection.bulkWrite/#std-label-bulkwrite-write-operations-insertOne"> insertOne </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/db.collection.bulkWrite/#std-label-bulkwrite-write-operations-updateOneMany"> updateOne </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/db.collection.bulkWrite/#std-label-bulkwrite-write-operations-replaceOne"> replaceOne </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/db.collection.bulkWrite/#std-label-bulkwrite-write-operations-deleteOneMany"> deleteOne </a> </p> </li> </ul> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Bulk write operations that only consist of the single-document write operations. A retryable bulk operation can include any combination of the specified write operations but cannot include any multi-document write operations, such as <code class="leafygreen-ui-1l06pbn"> updateMany </code> . </div> </div> </td> </tr> <tr class="leafygreen-ui-15dvrnp"> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/Bulk/#mongodb-method-Bulk"> <code class="leafygreen-ui-1l06pbn"> Bulk </code> </a> operations for: </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/method/Bulk.find.removeOne/#mongodb-method-Bulk.find.removeOne"> <code class="leafygreen-ui-1l06pbn"> Bulk.find.removeOne() </code> </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/Bulk.find.replaceOne/#mongodb-method-Bulk.find.replaceOne"> <code class="leafygreen-ui-1l06pbn"> Bulk.find.replaceOne() </code> </a> </p> </li> <li class="leafygreen-ui-d7p7b6"> <p class="leafygreen-ui-1kp3ins"> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/Bulk.find.updateOne/#mongodb-method-Bulk.find.updateOne"> <code class="leafygreen-ui-1l06pbn"> Bulk.find.updateOne() </code> </a> </p> </li> </ul> </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Bulk write operations that only consist of the single-document write operations. A retryable bulk operation can include any combination of the specified write operations but cannot include any multi-document write operations, such as <code class="leafygreen-ui-1l06pbn"> update </code> which specifies <code class="leafygreen-ui-1l06pbn"> true </code> for the <code class="leafygreen-ui-1l06pbn"> multi </code> option. </div> </div> </td> </tr> </tbody> </table> </div> </section> <section> <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium"> Behavior <a class="headerlink leafygreen-ui-1kepx47" href="#behavior" 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="behavior"> </div> </a> </h2> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Persistent Network Errors <a class="headerlink leafygreen-ui-1kepx47" href="#persistent-network-errors" 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="persistent-network-errors"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> MongoDB retryable writes make only <strong> one </strong> retry attempt. This helps address transient network errors and <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/replica-set-elections/#std-label-replica-set-elections"> replica set elections </a> , but not persistent network errors. </p> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Failover Period <a class="headerlink leafygreen-ui-1kepx47" href="#failover-period" 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="failover-period"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> If the driver cannot find a healthy <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/glossary/#std-term-primary"> primary </a> in the destination replica set or sharded cluster shard, the drivers wait <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/connection-string-options/#mongodb-urioption-urioption.serverSelectionTimeoutMS"> <code class="leafygreen-ui-1l06pbn"> serverSelectionTimeoutMS </code> </a> milliseconds to determine the new primary before retrying. Retryable writes do not address instances where the failover period exceeds <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/connection-string-options/#mongodb-urioption-urioption.serverSelectionTimeoutMS"> <code class="leafygreen-ui-1l06pbn"> serverSelectionTimeoutMS </code> . </a> </p> <div class="leafygreen-ui-1sjx7ru" role="note"> <h2 class="leafygreen-ui-29m78u"> Warning </h2> <div class="leafygreen-ui-9mycqc"> <p class="leafygreen-ui-1kp3ins"> If the client application becomes temporarily unresponsive for more than the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/parameters/#mongodb-parameter-param.localLogicalSessionTimeoutMinutes"> <code class="leafygreen-ui-1l06pbn"> localLogicalSessionTimeoutMinutes </code> </a> after issuing a write operation, there is a chance that when the client applications starts responding (without a restart), the write operation may be retried and applied again. </p> </div> </div> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Diagnostics <a class="headerlink leafygreen-ui-1kepx47" href="#diagnostics" 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="diagnostics"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> The <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/command/serverStatus/#mongodb-dbcommand-dbcmd.serverStatus"> <code class="leafygreen-ui-1l06pbn"> serverStatus </code> </a> command, and its <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/mongodb-shell/#mongodb-binary-bin.mongosh" target="_self"> <span> <code class="leafygreen-ui-1l06pbn"> mongosh </code> </span> </a> shell helper <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/db.serverStatus/#mongodb-method-db.serverStatus"> <code class="leafygreen-ui-1l06pbn"> db.serverStatus() </code> </a> includes statistics on retryable writes in the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/command/serverStatus/#mongodb-serverstatus-serverstatus.transactions"> <code class="leafygreen-ui-1l06pbn"> transactions </code> </a> section. </p> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Retryable Writes Against <code class="leafygreen-ui-1l06pbn"> local </code> Database <a class="headerlink leafygreen-ui-1kepx47" href="#retryable-writes-against-local-database" 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="retryable-writes-against-local-database"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> The official MongoDB drivers enable retryable writes by default. Applications which write to the <code class="leafygreen-ui-1l06pbn"> local </code> <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/local-database/#std-label-replica-set-local-database"> database </a> will encounter write errors <em> unless </em> retryable writes are explicitly disabled. </p> <p class="leafygreen-ui-1kp3ins"> To disable retryable writes, specify <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/connection-string-options/#mongodb-urioption-urioption.retryWrites"> <code class="leafygreen-ui-1l06pbn"> retryWrites=false </code> </a> in the <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/connection-string/#std-label-mongodb-uri"> connection string </a> for the MongoDB cluster. </p> </section> <section> <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium"> Error Handling <a class="headerlink leafygreen-ui-1kepx47" href="#error-handling" 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="error-handling"> </div> </a> </h3> <p class="leafygreen-ui-1kp3ins"> Starting in MongoDB 6.1, if both the first and second attempt of a retryable write fail without a single write being performed, MongoDB returns an error with the <code class="leafygreen-ui-1l06pbn"> NoWritesPerformed </code> label. </p> <p class="leafygreen-ui-1kp3ins"> The <code class="leafygreen-ui-1l06pbn"> NoWritesPerformed </code> label differentiates the results of batch operations like <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/db.collection.insertMany/#mongodb-method-db.collection.insertMany"> <code class="leafygreen-ui-1l06pbn"> insertMany() </code> </a> . In an <code class="leafygreen-ui-1l06pbn"> insertMany </code> operation, one of the following outcomes can occur: </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> Outcome </div> </div> </th> <th class="leafygreen-ui-13uteka" role="columnheader" scope="col"> <div class="leafygreen-ui-ui0te9"> <div> MongoDB Output </div> </div> </th> </tr> </thead> <tbody> <tr class=""> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> No documents are inserted. </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Error returned with <code class="leafygreen-ui-1l06pbn"> NoWritesPerformed </code> label. </div> </div> </td> </tr> <tr class=""> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Partial work done. (At least one document is inserted, but not all.) </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Error returned without <code class="leafygreen-ui-1l06pbn"> NoWritesPerformed </code> label. </div> </div> </td> </tr> <tr class=""> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> All documents are inserted. </div> </div> </td> <td class="leafygreen-ui-1drjk7h"> <div class="leafygreen-ui-1n4j8xf"> <div> Success returned. </div> </div> </td> </tr> </tbody> </table> </div> <p class="leafygreen-ui-1kp3ins"> Applications can use the <code class="leafygreen-ui-1l06pbn"> NoWritesPerformed </code> label to definitively determine that no documents were inserted. This error reporting lets the application maintain an accurate state of the database when handling retryable writes. </p> <p class="leafygreen-ui-1kp3ins"> In previous versions of MongoDB, an error is returned when both the first and second attempts of a retryable write fail. However, there is no distinction made to indicate that no writes were performed. </p> </section> </section> </section>