# MongoDB

# Tuning

<div class="Y3BBE" data-hveid="CAEQAA" data-processed="true" data-sfc-cp="" id="bkmrk-mongodb-tuning-invol" jsaction="rcuQ6b:&wAW0We_7|npT2md" jscontroller="zcfIf" jsuid="wAW0We_7" style="font-family: 'Google Sans', Roboto, Arial, sans-serif; font-size: 16px; line-height: 24px; overflow-wrap: break-word; margin: 0px 0px 20px; color: rgb(10, 10, 10); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">MongoDB tuning involves a holistic approach, focusing on **[data modeling](https://www.google.com/search?q=data+modeling&sca_esv=8c1d8b7610d1bcd4&sxsrf=AE3TifOPNGjqgVwR6RtChD-KV8HcaTieLg%3A1765473263891&ei=7_s6aa-QNoqf4-EP7M6ysQY&ved=2ahUKEwj6hoq-hLaRAxV0UGwGHT4HCRsQgK4QegQIARAB&uact=5&oq=mongodb+tuning&gs_lp=Egxnd3Mtd2l6LXNlcnAiDm1vbmdvZGIgdHVuaW5nMgUQABiABDIGEAAYFhgeMgYQABgWGB4yBhAAGBYYHjIGEAAYFhgeMgYQABgWGB4yBhAAGBYYHjIGEAAYFhgeMgYQABgWGB4yBhAAGBYYHkjCU1DMDljwUXAHeAGQAQCYAZ0CoAGEGKoBBjAuMTYuMrgBA8gBAPgBAZgCGaAC4hyoAhDCAgoQABiwAxjWBBhHwgIEECMYJ8ICChAjGIAEGCcYigXCAgcQIxjwBRgnwgIKEAAYgAQYQxiKBcICCxAAGIAEGJECGIoFwgIQEC4YgAQY0QMYQxjHARiKBcICCxAAGIAEGLEDGIMBwgIOEC4YgAQYsQMY0QMYxwHCAg4QLhiABBixAxiDARiKBcICEBAAGIAEGLEDGEMYgwEYigXCAggQLhiABBixA8ICHxAuGIAEGNEDGEMYxwEYigUYlwUY3AQY3gQY4ATYAQHCAgUQLhiABMICCBAAGIAEGLEDwgIHECMYJxjqAsICFxAAGIAEGJECGLQCGOcGGIoFGOoC2AEBwgIKEC4YgAQYQxiKBcICDhAAGIAEGJECGLEDGIoFwgIREAAYgAQYkQIYsQMYgwEYigXCAg0QABiABBixAxhDGIoFwgIKEAAYgAQYFBiHAsICCBAAGBYYChgemAMW4gMFEgExIEDxBUWOR8WNUeDWiAYBkAYIugYGCAEQARgUkgcINy4xNS4yLjGgB6yuAbIHCDAuMTUuMi4xuAe8G8IHBjMtNC4yMcgHggSACAA&sclient=gws-wiz-serp&mstk=AUtExfC1bhK_cC3VtrCkupOFWLiaS2u3hqzK1fNG2bk18lYvZhbhAsQ5pUL4y7021iti12YyfLd0oXrrEce642Vd5c57__YTHVy6SSgDFdd_v8C1IY9ultYeDiVo8KmUL0yKGezXndw2ajTrALOg_oZQjfwNbhBGrjVCXcJE380Vd2n1-EWqa_bVKzG_K9oCY-OeNQanuNCID5OM39Mi44xjgoVbJiCa7y_qnwgJT6SlpXQGWhKIIYV9A6Q014ywxurCHdLW4iG4Wy0dy2v7FrvM-Lc8zb1Yxl1fE7jgvXFoATeU-cOBzgl1SOLTPdqpp5eZmo9Nu9MGOQOOjv-H57FPmnod2qNNwKKEGysIYqmSnYbhZjrMJsP7XR9ro6S_2F4iwYgor7rC7V5-DMXl2soWqg&csui=3)** (embedding vs. referencing), **[indexing](https://www.google.com/search?q=indexing&sca_esv=8c1d8b7610d1bcd4&sxsrf=AE3TifOPNGjqgVwR6RtChD-KV8HcaTieLg%3A1765473263891&ei=7_s6aa-QNoqf4-EP7M6ysQY&ved=2ahUKEwj6hoq-hLaRAxV0UGwGHT4HCRsQgK4QegQIARAC&uact=5&oq=mongodb+tuning&gs_lp=Egxnd3Mtd2l6LXNlcnAiDm1vbmdvZGIgdHVuaW5nMgUQABiABDIGEAAYFhgeMgYQABgWGB4yBhAAGBYYHjIGEAAYFhgeMgYQABgWGB4yBhAAGBYYHjIGEAAYFhgeMgYQABgWGB4yBhAAGBYYHkjCU1DMDljwUXAHeAGQAQCYAZ0CoAGEGKoBBjAuMTYuMrgBA8gBAPgBAZgCGaAC4hyoAhDCAgoQABiwAxjWBBhHwgIEECMYJ8ICChAjGIAEGCcYigXCAgcQIxjwBRgnwgIKEAAYgAQYQxiKBcICCxAAGIAEGJECGIoFwgIQEC4YgAQY0QMYQxjHARiKBcICCxAAGIAEGLEDGIMBwgIOEC4YgAQYsQMY0QMYxwHCAg4QLhiABBixAxiDARiKBcICEBAAGIAEGLEDGEMYgwEYigXCAggQLhiABBixA8ICHxAuGIAEGNEDGEMYxwEYigUYlwUY3AQY3gQY4ATYAQHCAgUQLhiABMICCBAAGIAEGLEDwgIHECMYJxjqAsICFxAAGIAEGJECGLQCGOcGGIoFGOoC2AEBwgIKEC4YgAQYQxiKBcICDhAAGIAEGJECGLEDGIoFwgIREAAYgAQYkQIYsQMYgwEYigXCAg0QABiABBixAxhDGIoFwgIKEAAYgAQYFBiHAsICCBAAGBYYChgemAMW4gMFEgExIEDxBUWOR8WNUeDWiAYBkAYIugYGCAEQARgUkgcINy4xNS4yLjGgB6yuAbIHCDAuMTUuMi4xuAe8G8IHBjMtNC4yMcgHggSACAA&sclient=gws-wiz-serp&mstk=AUtExfC1bhK_cC3VtrCkupOFWLiaS2u3hqzK1fNG2bk18lYvZhbhAsQ5pUL4y7021iti12YyfLd0oXrrEce642Vd5c57__YTHVy6SSgDFdd_v8C1IY9ultYeDiVo8KmUL0yKGezXndw2ajTrALOg_oZQjfwNbhBGrjVCXcJE380Vd2n1-EWqa_bVKzG_K9oCY-OeNQanuNCID5OM39Mi44xjgoVbJiCa7y_qnwgJT6SlpXQGWhKIIYV9A6Q014ywxurCHdLW4iG4Wy0dy2v7FrvM-Lc8zb1Yxl1fE7jgvXFoATeU-cOBzgl1SOLTPdqpp5eZmo9Nu9MGOQOOjv-H57FPmnod2qNNwKKEGysIYqmSnYbhZjrMJsP7XR9ro6S_2F4iwYgor7rC7V5-DMXl2soWqg&csui=3)** (creating efficient indexes for queries), **[query optimization](https://www.google.com/search?q=query+optimization&sca_esv=8c1d8b7610d1bcd4&sxsrf=AE3TifOPNGjqgVwR6RtChD-KV8HcaTieLg%3A1765473263891&ei=7_s6aa-QNoqf4-EP7M6ysQY&ved=2ahUKEwj6hoq-hLaRAxV0UGwGHT4HCRsQgK4QegQIARAD&uact=5&oq=mongodb+tuning&gs_lp=Egxnd3Mtd2l6LXNlcnAiDm1vbmdvZGIgdHVuaW5nMgUQABiABDIGEAAYFhgeMgYQABgWGB4yBhAAGBYYHjIGEAAYFhgeMgYQABgWGB4yBhAAGBYYHjIGEAAYFhgeMgYQABgWGB4yBhAAGBYYHkjCU1DMDljwUXAHeAGQAQCYAZ0CoAGEGKoBBjAuMTYuMrgBA8gBAPgBAZgCGaAC4hyoAhDCAgoQABiwAxjWBBhHwgIEECMYJ8ICChAjGIAEGCcYigXCAgcQIxjwBRgnwgIKEAAYgAQYQxiKBcICCxAAGIAEGJECGIoFwgIQEC4YgAQY0QMYQxjHARiKBcICCxAAGIAEGLEDGIMBwgIOEC4YgAQYsQMY0QMYxwHCAg4QLhiABBixAxiDARiKBcICEBAAGIAEGLEDGEMYgwEYigXCAggQLhiABBixA8ICHxAuGIAEGNEDGEMYxwEYigUYlwUY3AQY3gQY4ATYAQHCAgUQLhiABMICCBAAGIAEGLEDwgIHECMYJxjqAsICFxAAGIAEGJECGLQCGOcGGIoFGOoC2AEBwgIKEC4YgAQYQxiKBcICDhAAGIAEGJECGLEDGIoFwgIREAAYgAQYkQIYsQMYgwEYigXCAg0QABiABBixAxhDGIoFwgIKEAAYgAQYFBiHAsICCBAAGBYYChgemAMW4gMFEgExIEDxBUWOR8WNUeDWiAYBkAYIugYGCAEQARgUkgcINy4xNS4yLjGgB6yuAbIHCDAuMTUuMi4xuAe8G8IHBjMtNC4yMcgHggSACAA&sclient=gws-wiz-serp&mstk=AUtExfC1bhK_cC3VtrCkupOFWLiaS2u3hqzK1fNG2bk18lYvZhbhAsQ5pUL4y7021iti12YyfLd0oXrrEce642Vd5c57__YTHVy6SSgDFdd_v8C1IY9ultYeDiVo8KmUL0yKGezXndw2ajTrALOg_oZQjfwNbhBGrjVCXcJE380Vd2n1-EWqa_bVKzG_K9oCY-OeNQanuNCID5OM39Mi44xjgoVbJiCa7y_qnwgJT6SlpXQGWhKIIYV9A6Q014ywxurCHdLW4iG4Wy0dy2v7FrvM-Lc8zb1Yxl1fE7jgvXFoATeU-cOBzgl1SOLTPdqpp5eZmo9Nu9MGOQOOjv-H57FPmnod2qNNwKKEGysIYqmSnYbhZjrMJsP7XR9ro6S_2F4iwYgor7rC7V5-DMXl2soWqg&csui=3)** (using `explain()` for slow queries, projection), **[server configuration](https://www.google.com/search?q=server+configuration&sca_esv=8c1d8b7610d1bcd4&sxsrf=AE3TifOPNGjqgVwR6RtChD-KV8HcaTieLg%3A1765473263891&ei=7_s6aa-QNoqf4-EP7M6ysQY&ved=2ahUKEwj6hoq-hLaRAxV0UGwGHT4HCRsQgK4QegQIARAE&uact=5&oq=mongodb+tuning&gs_lp=Egxnd3Mtd2l6LXNlcnAiDm1vbmdvZGIgdHVuaW5nMgUQABiABDIGEAAYFhgeMgYQABgWGB4yBhAAGBYYHjIGEAAYFhgeMgYQABgWGB4yBhAAGBYYHjIGEAAYFhgeMgYQABgWGB4yBhAAGBYYHkjCU1DMDljwUXAHeAGQAQCYAZ0CoAGEGKoBBjAuMTYuMrgBA8gBAPgBAZgCGaAC4hyoAhDCAgoQABiwAxjWBBhHwgIEECMYJ8ICChAjGIAEGCcYigXCAgcQIxjwBRgnwgIKEAAYgAQYQxiKBcICCxAAGIAEGJECGIoFwgIQEC4YgAQY0QMYQxjHARiKBcICCxAAGIAEGLEDGIMBwgIOEC4YgAQYsQMY0QMYxwHCAg4QLhiABBixAxiDARiKBcICEBAAGIAEGLEDGEMYgwEYigXCAggQLhiABBixA8ICHxAuGIAEGNEDGEMYxwEYigUYlwUY3AQY3gQY4ATYAQHCAgUQLhiABMICCBAAGIAEGLEDwgIHECMYJxjqAsICFxAAGIAEGJECGLQCGOcGGIoFGOoC2AEBwgIKEC4YgAQYQxiKBcICDhAAGIAEGJECGLEDGIoFwgIREAAYgAQYkQIYsQMYgwEYigXCAg0QABiABBixAxhDGIoFwgIKEAAYgAQYFBiHAsICCBAAGBYYChgemAMW4gMFEgExIEDxBUWOR8WNUeDWiAYBkAYIugYGCAEQARgUkgcINy4xNS4yLjGgB6yuAbIHCDAuMTUuMi4xuAe8G8IHBjMtNC4yMcgHggSACAA&sclient=gws-wiz-serp&mstk=AUtExfC1bhK_cC3VtrCkupOFWLiaS2u3hqzK1fNG2bk18lYvZhbhAsQ5pUL4y7021iti12YyfLd0oXrrEce642Vd5c57__YTHVy6SSgDFdd_v8C1IY9ultYeDiVo8KmUL0yKGezXndw2ajTrALOg_oZQjfwNbhBGrjVCXcJE380Vd2n1-EWqa_bVKzG_K9oCY-OeNQanuNCID5OM39Mi44xjgoVbJiCa7y_qnwgJT6SlpXQGWhKIIYV9A6Q014ywxurCHdLW4iG4Wy0dy2v7FrvM-Lc8zb1Yxl1fE7jgvXFoATeU-cOBzgl1SOLTPdqpp5eZmo9Nu9MGOQOOjv-H57FPmnod2qNNwKKEGysIYqmSnYbhZjrMJsP7XR9ro6S_2F4iwYgor7rC7V5-DMXl2soWqg&csui=3)** (memory, storage, concurrency settings like tickets, connection pooling), and **[monitoring](https://www.google.com/search?q=monitoring&sca_esv=8c1d8b7610d1bcd4&sxsrf=AE3TifOPNGjqgVwR6RtChD-KV8HcaTieLg%3A1765473263891&ei=7_s6aa-QNoqf4-EP7M6ysQY&ved=2ahUKEwj6hoq-hLaRAxV0UGwGHT4HCRsQgK4QegQIARAF&uact=5&oq=mongodb+tuning&gs_lp=Egxnd3Mtd2l6LXNlcnAiDm1vbmdvZGIgdHVuaW5nMgUQABiABDIGEAAYFhgeMgYQABgWGB4yBhAAGBYYHjIGEAAYFhgeMgYQABgWGB4yBhAAGBYYHjIGEAAYFhgeMgYQABgWGB4yBhAAGBYYHkjCU1DMDljwUXAHeAGQAQCYAZ0CoAGEGKoBBjAuMTYuMrgBA8gBAPgBAZgCGaAC4hyoAhDCAgoQABiwAxjWBBhHwgIEECMYJ8ICChAjGIAEGCcYigXCAgcQIxjwBRgnwgIKEAAYgAQYQxiKBcICCxAAGIAEGJECGIoFwgIQEC4YgAQY0QMYQxjHARiKBcICCxAAGIAEGLEDGIMBwgIOEC4YgAQYsQMY0QMYxwHCAg4QLhiABBixAxiDARiKBcICEBAAGIAEGLEDGEMYgwEYigXCAggQLhiABBixA8ICHxAuGIAEGNEDGEMYxwEYigUYlwUY3AQY3gQY4ATYAQHCAgUQLhiABMICCBAAGIAEGLEDwgIHECMYJxjqAsICFxAAGIAEGJECGLQCGOcGGIoFGOoC2AEBwgIKEC4YgAQYQxiKBcICDhAAGIAEGJECGLEDGIoFwgIREAAYgAQYkQIYsQMYgwEYigXCAg0QABiABBixAxhDGIoFwgIKEAAYgAQYFBiHAsICCBAAGBYYChgemAMW4gMFEgExIEDxBUWOR8WNUeDWiAYBkAYIugYGCAEQARgUkgcINy4xNS4yLjGgB6yuAbIHCDAuMTUuMi4xuAe8G8IHBjMtNC4yMcgHggSACAA&sclient=gws-wiz-serp&mstk=AUtExfC1bhK_cC3VtrCkupOFWLiaS2u3hqzK1fNG2bk18lYvZhbhAsQ5pUL4y7021iti12YyfLd0oXrrEce642Vd5c57__YTHVy6SSgDFdd_v8C1IY9ultYeDiVo8KmUL0yKGezXndw2ajTrALOg_oZQjfwNbhBGrjVCXcJE380Vd2n1-EWqa_bVKzG_K9oCY-OeNQanuNCID5OM39Mi44xjgoVbJiCa7y_qnwgJT6SlpXQGWhKIIYV9A6Q014ywxurCHdLW4iG4Wy0dy2v7FrvM-Lc8zb1Yxl1fE7jgvXFoATeU-cOBzgl1SOLTPdqpp5eZmo9Nu9MGOQOOjv-H57FPmnod2qNNwKKEGysIYqmSnYbhZjrMJsP7XR9ro6S_2F4iwYgor7rC7V5-DMXl2soWqg&csui=3)** (profiler, Atlas tools) to ensure optimal performance, scalability, and resource usage for your specific application needs.<span class="uJ19be notranslate" data-processed="true" data-wiz-uids="wAW0We_k,wAW0We_l,wAW0We_m"><span class="vKEkVd" data-animation-atomic="" data-processed="true" style="white-space: nowrap; position: relative;"> <button aria-label="View related links" class="rBl3me" data-amic="true" data-icl-uuid="fb42ad01-4fdf-4950-a1c3-fc8c7e3f6fce" data-processed="true" data-ved="2ahUKEwj6hoq-hLaRAxV0UGwGHT4HCRsQye0OegQIARAG" data-wiz-attrbind="disabled=wAW0We_k/C5gNJc;class=wAW0We_k/UpSNec;" style="margin: 0px 6px 0px 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgb(229, 237, 255); border: none; border-radius: 10px; height: 20px; padding: 0px; width: 28px; position: relative; outline: 0px; cursor: pointer;" tabindex="0"><span class="wiMplc ofC0Ud" data-processed="true" style="color: rgb(0, 29, 53); display: inline-block; transform: rotate(135deg);"><svg fill="currentColor" focusable="false" height="12px" style="margin-top: 3px;" viewbox="0 0 24 24" width="12px" xmlns="http://www.w3.org/2000/svg"><path d="M3.9 12c0-1.71 1.39-3.1 3.1-3.1h4V7H7c-2.76 0-5 2.24-5 5s2.24 5 5 5h4v-1.9H7c-1.71 0-3.1-1.39-3.1-3.1zM8 13h8v-2H8v2zm9-6h-4v1.9h4c1.71 0 3.1 1.39 3.1 3.1s-1.39 3.1-3.1 3.1h-4V17h4c2.76 0 5-2.24 5-5s-2.24-5-5-5z"></path></svg></span></button></span></span></div><div class="Y3BBE" data-hveid="CAIQAA" data-processed="true" data-sfc-cp="" id="bkmrk-this-video-provides-" jsaction="rcuQ6b:&wAW0We_s|npT2md" jscontroller="zcfIf" jsuid="wAW0We_s" style="font-family: 'Google Sans', Roboto, Arial, sans-serif; font-size: 16px; line-height: 24px; overflow-wrap: break-word; margin: 10px 0px 20px; color: rgb(10, 10, 10); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">This video provides an overview of the MongoDB architecture for query performance: <div class="" data-processed="true" data-wiz-uids="wAW0We_u,wAW0We_v" jscontroller="uDeH3" jsuid="wAW0We_t"><div data-hveid="CAIQAQ" data-processed="true" data-ved="2ahUKEwj6hoq-hLaRAxV0UGwGHT4HCRsQ-bUQegQIAhAB"><div data-processed="true"><div class="Q2WBBe" data-processed="true" jsuid="wAW0We_v" style="container-type: inline-size; display: flex; flex-direction: column; background-color: rgb(243, 245, 246); margin-top: 12px; border-radius: 16px;"><div aria-label="" class="r0hyfc" data-animation-nesting="" data-processed="true" data-ved="2ahUKEwj6hoq-hLaRAxV0UGwGHT4HCRsQypYSegQIAhAC" jsuid="wAW0We_u" style="overflow: hidden; position: relative; border-radius: 16px 16px 0px 0px; width: 631.987px; height: 353.906px; outline: 0px;" tabindex="-1"><div class="RtAO3b" data-processed="true" data-sfc-cp="" data-wiz-uids="wAW0We_x" jsaction="rcuQ6b:&wAW0We_w|npT2md" jscallback="gfNXHe:&wAW0We_t:U8wGUb" jscontroller="wMmv4c" jsuid="wAW0We_w" style="width: 631.987px; height: 353.906px;"><div class="nrdPJf" data-processed="true" data-ved="2ahUKEwj6hoq-hLaRAxV0UGwGHT4HCRsQtbEQegQIAhAD" jsaction="click:&wAW0We_w|T2P31d" jsuid="wAW0We_x" role="button" style="cursor: pointer; width: 631.987px; height: 353.906px; outline: 0px;" tabindex="0">![Related video thumbnail](https://articles.ravapps.com/uploads/images/gallery/2025-12/gPtT9sQ0bb9n9n53-embedded-image-o6jwigho.jpeg)<div aria-label="Play" class="mxefw" data-processed="true" style="height: 44px; left: calc(50% - 22px); position: absolute; top: calc(50% - 22px); width: 44px;"><svg fill="none" height="44" viewbox="0 0 44 44" width="44" xmlns="http://www.w3.org/2000/svg"><rect fill="black" fill-opacity="0.6" height="44" rx="22" width="44"></rect><path d="M17 15.5222V28.4772C17 29.5554 18.2017 30.1986 19.0988 29.6005L28.8151 23.123C29.6166 22.5886 29.6166 21.4108 28.8151 20.8764L19.0988 14.3989C18.2017 13.8008 17 14.444 17 15.5222Z" fill="white"></path></svg></div><div class="Pa4wsd YkW4Kb" data-processed="true" style="align-items: center; display: flex; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0.6); border-radius: 100px; font-size: 12px; gap: 4px; left: 12px; line-height: 1.33; position: absolute; bottom: 12px; padding: 2px 8px; z-index: 2;"><span class="zY18Ie" data-processed="true" style="color: rgb(255, 255, 255);">06:26</span></div><div class="dumoDb YkW4Kb" data-processed="true" style="z-index: 2; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0.6); border-radius: 100px; cursor: pointer; position: absolute; right: 14px; top: 12px;"><div class="CaQWce" data-processed="true" jscontroller="sRLmTc" jsuid="wAW0We_y" style="align-items: center; color: rgb(255, 255, 255); display: flex; height: 20px; justify-content: center; transform: rotate(45deg); width: 20px;"><svg fill="currentColor" height="18px" viewbox="0 -960 960 960" width="18px" xmlns="http://www.w3.org/2000/svg"><path d="M480-120 300-300l58-58 122 122 122-122 58 58-180 180ZM358-598l-58-58 180-180 180 180-58 58-122-122-122 122Z" fill="currentColor"></path></svg></div></div><div class="AJ10sd" data-processed="true" data-signal-inputs="RMdumc=wAW0We_t/TVP8Qe" data-ved="2ahUKEwj6hoq-hLaRAxV0UGwGHT4HCRsQz_MQegQIAhAE" data-wiz-uids="wAW0We_z,wAW0We_10" jsaction="rcuQ6b:&wAW0We_z|npT2md" jscontroller="oi1tWc" jsuid="wAW0We_z" style="position: absolute; inset: 0px; z-index: 1;"><video class="OjJwgf" data-processed="true" loop="loop" muted="" preload="none" src="https://encrypted-vtbn2.gstatic.com/video?q=tbn:ANd9GcTdQpe72evDeZq9lu-5jbPx4L9IzW8GKpR_j5AqQ5_XtkHqZTAo" style="width: 631.987px; height: 353.906px; object-fit: cover; opacity: 0; transition: opacity 0.2s ease-in-out;"></video></div></div></div></div><div data-processed="true">[<div class="RhEuY" data-processed="true" style="display: flex; padding: 16px 12px 12px; gap: 8px; align-items: center;"><div class="SWvopd" data-processed="true" jscontroller="aNJZAb" jsuid="wAW0We_11" style="height: fit-content; width: fit-content; margin-bottom: 2px; position: relative;"><div class="Lki2rc" data-processed="true" style="width: 20px; height: 20px; line-height: 20px;"><div aria-hidden="true" class="U9BD8 Wsaimf QyEYne" data-processed="true" jscontroller="Cky8Oc" jsuid="wAW0We_12" style="width: 19.9875px; height: 19.9875px; line-height: 16px; display: flex; flex-shrink: 0; align-items: center; justify-content: center; overflow: hidden; background-color: rgb(255, 255, 255); border-radius: 50%;">![](https://articles.ravapps.com/uploads/images/gallery/2025-12/KlRaooA1bW8tYPOn-embedded-image-56md8fyd.png)</div></div><div class="JccCTc xG6cCf" data-processed="true" style="position: absolute; bottom: -4px; right: -4px; border-radius: 50%; line-height: 10px; padding: 2px; background-color: rgb(255, 255, 255); width: 10px; height: 10px;"><div aria-hidden="true" class="U9BD8 Wsaimf QyEYne" data-processed="true" jscontroller="Cky8Oc" jsuid="wAW0We_13" style="width: 9.99375px; height: 9.99375px; line-height: 16px; display: flex; flex-shrink: 0; align-items: center; justify-content: center; overflow: hidden; background-color: rgb(255, 255, 255); border-radius: 50%;">![](https://articles.ravapps.com/uploads/images/gallery/2025-12/v7HnlgkJpt2ePFsJ-embedded-image-dopjj9gw.png)</div></div></div><div data-processed="true"><div class="SrjfCd" data-processed="true" style="color: rgb(31, 31, 31); font-size: 12px; line-height: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;">MongoDB</div><div class="Pcl3Vd" data-processed="true" style="color: rgb(31, 31, 31); letter-spacing: 0px; font-size: 11px; line-height: 13px;">YouTube • 9 Jul 2025</div></div></div>](https://www.youtube.com/watch?v=s1_55jY0Amw)</div></div></div></div></div></div><div class="Fsg96" data-processed="true" data-sfc-cp="" id="bkmrk--1" jsaction="rcuQ6b:&wAW0We_14|npT2md" jscontroller="KHhJQ" jsuid="wAW0We_14" style="color: rgb(10, 10, 10); font-family: 'Google Sans', Roboto, Arial, sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">  
</div><div aria-level="3" class="otQkpb" data-animation-nesting="" data-processed="true" data-sfc-cp="" id="bkmrk-key-areas-for-tuning" jscontroller="a7qCn" jsuid="wAW0We_15" role="heading" style="color: rgb(0, 29, 53); font-family: 'Google Sans', Roboto, Arial, sans-serif; font-size: 20px; line-height: 28px; margin: 20px 0px 10px; font-weight: 600; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">Key Areas for Tuning<span class="txxDge notranslate" data-processed="true" data-wiz-uids="wAW0We_16,wAW0We_17,wAW0We_18" style="visibility: hidden;"><span class="vKEkVd" data-animation-atomic="" data-processed="true" style="white-space: nowrap; position: relative;"><button aria-label="View related links" class="rBl3me" data-amic="true" data-icl-uuid="d4fa4861-b16b-4a29-9ed5-4b8247c003fe" data-processed="true" data-ved="2ahUKEwj6hoq-hLaRAxV0UGwGHT4HCRsQye0OegQIAxAA" data-wiz-attrbind="disabled=wAW0We_16/C5gNJc;class=wAW0We_16/UpSNec;" style="margin: 0px 6px 0px 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgb(229, 237, 255); border: none; border-radius: 10px; height: 20px; padding: 0px; width: 28px; position: relative; outline: 0px; cursor: pointer;" tabindex="0"><span class="wiMplc ofC0Ud" data-processed="true" style="color: rgb(0, 29, 53); display: inline-block; transform: rotate(135deg);"><svg fill="currentColor" focusable="false" height="12px" style="margin-top: 3px;" viewbox="0 0 24 24" width="12px" xmlns="http://www.w3.org/2000/svg"><path d="M3.9 12c0-1.71 1.39-3.1 3.1-3.1h4V7H7c-2.76 0-5 2.24-5 5s2.24 5 5 5h4v-1.9H7c-1.71 0-3.1-1.39-3.1-3.1zM8 13h8v-2H8v2zm9-6h-4v1.9h4c1.71 0 3.1 1.39 3.1 3.1s-1.39 3.1-3.1 3.1h-4V17h4c2.76 0 5-2.24 5-5s-2.24-5-5-5z"></path></svg></span></button></span></span></div>1. <span class="T286Pc" data-processed="true" data-sfc-cp="" style="overflow-wrap: break-word;">**Data Modeling &amp; Indexing:**</span>
    - <span class="T286Pc" data-processed="true" data-sfc-cp="" style="overflow-wrap: break-word;">**Embed vs. Reference:** Model data for common access patterns, embedding related data for fewer reads, but referencing when data is shared or grows large (minimizing document size).</span>
    - <span class="T286Pc" data-processed="true" data-sfc-cp="" style="overflow-wrap: break-word;">**Index Strategically:** Create indexes on fields used in `find()`, `sort()`, and `aggregate()` stages. Use compound indexes for multi-field queries.</span>
    - <span class="T286Pc" data-processed="true" data-sfc-cp="" style="overflow-wrap: break-word;">**Avoid Collection Scans:** Use `explain()` to ensure queries use index scans, not full collection scans.</span><span class="uJ19be notranslate" data-processed="true" data-wiz-uids="wAW0We_1r,wAW0We_1s,wAW0We_1t"><span class="vKEkVd" data-animation-atomic="" data-processed="true" style="white-space: nowrap; position: relative;"> <button aria-label="View related links" class="rBl3me" data-amic="true" data-icl-uuid="6b3c63d7-1352-4001-b69d-c37437c2d888" data-processed="true" data-ved="2ahUKEwj6hoq-hLaRAxV0UGwGHT4HCRsQye0OegQIBBAE" data-wiz-attrbind="disabled=wAW0We_1r/C5gNJc;class=wAW0We_1r/UpSNec;" style="margin: 0px 6px 0px 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgb(229, 237, 255); border: none; border-radius: 10px; height: 20px; padding: 0px; width: 28px; position: relative; outline: 0px; cursor: pointer;" tabindex="0"><span class="wiMplc ofC0Ud" data-processed="true" style="color: rgb(0, 29, 53); display: inline-block; transform: rotate(135deg);"><svg fill="currentColor" focusable="false" height="12px" style="margin-top: 3px;" viewbox="0 0 24 24" width="12px" xmlns="http://www.w3.org/2000/svg"><path d="M3.9 12c0-1.71 1.39-3.1 3.1-3.1h4V7H7c-2.76 0-5 2.24-5 5s2.24 5 5 5h4v-1.9H7c-1.71 0-3.1-1.39-3.1-3.1zM8 13h8v-2H8v2zm9-6h-4v1.9h4c1.71 0 3.1 1.39 3.1 3.1s-1.39 3.1-3.1 3.1h-4V17h4c2.76 0 5-2.24 5-5s-2.24-5-5-5z"></path></svg></span></button></span></span>

<div class="Y3BBE" data-hveid="CAUQAA" data-processed="true" data-sfc-cp="" id="bkmrk-this-video-explains-" jsaction="rcuQ6b:&wAW0We_1x|npT2md" jscontroller="zcfIf" jsuid="wAW0We_1x" style="font-family: 'Google Sans', Roboto, Arial, sans-serif; font-size: 16px; line-height: 24px; overflow-wrap: break-word; margin: 10px 0px 20px; color: rgb(10, 10, 10); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">This video explains the importance of indexes for performance: <div class="" data-processed="true" data-wiz-uids="wAW0We_1z,wAW0We_20" jscontroller="uDeH3" jsuid="wAW0We_1y"><div data-hveid="CAUQAQ" data-processed="true" data-ved="2ahUKEwj6hoq-hLaRAxV0UGwGHT4HCRsQ-bUQegQIBRAB"><div data-processed="true"><div class="Q2WBBe" data-processed="true" jsuid="wAW0We_20" style="container-type: inline-size; display: flex; flex-direction: column; background-color: rgb(243, 245, 246); margin-top: 12px; border-radius: 16px;"><div aria-label="" class="r0hyfc" data-animation-nesting="" data-processed="true" data-ved="2ahUKEwj6hoq-hLaRAxV0UGwGHT4HCRsQypYSegQIBRAC" jsuid="wAW0We_1z" style="overflow: hidden; position: relative; border-radius: 16px 16px 0px 0px; width: 631.987px; height: 353.906px; outline: 0px;" tabindex="-1"><div class="RtAO3b" data-processed="true" data-sfc-cp="" data-wiz-uids="wAW0We_22" jsaction="rcuQ6b:&wAW0We_21|npT2md" jscallback="gfNXHe:&wAW0We_1y:U8wGUb" jscontroller="wMmv4c" jsuid="wAW0We_21" style="width: 631.987px; height: 353.906px;"><div class="nrdPJf" data-processed="true" data-ved="2ahUKEwj6hoq-hLaRAxV0UGwGHT4HCRsQtbEQegQIBRAD" jsaction="click:&wAW0We_21|T2P31d" jsuid="wAW0We_22" role="button" style="cursor: pointer; width: 631.987px; height: 353.906px; outline: 0px;" tabindex="0">![Related video thumbnail](https://articles.ravapps.com/uploads/images/gallery/2025-12/6ZVbyQLduetlZbm5-embedded-image-wsnjijal.jpeg)<div class="n7j80c YkW4Kb" data-processed="true" jscontroller="ItMuwb" jsuid="wAW0We_23" style="z-index: 2; border-radius: 100px; bottom: 12px; height: 4px; left: 12px; position: absolute; width: calc(100% - 24px); --segment-bar-offset: 12px;"><div class="llCCib" data-processed="true" style="transform: translateX(-50%); width: fit-content; align-items: center; background: none 0% 0% / auto repeat scroll padding-box border-box rgb(255, 255, 255); opacity: 0.85; border-radius: 100px; color: rgb(31, 31, 31); display: flex; flex-direction: row; font-size: 12px; gap: 4px; line-height: 1.33; padding: 2px 8px; position: absolute; top: -27px; white-space: nowrap; left: 358.706px;"><svg fill="currentColor" height="12" viewbox="0 0 12 12" width="12" xmlns="http://www.w3.org/2000/svg"><path d="M3.5 2.7611V9.2386C3.5 9.77772 4.10085 10.0993 4.54942 9.80023L9.40755 6.56148C9.80832 6.2943 9.80832 5.70539 9.40755 5.43821L4.54942 2.19946C4.10085 1.90041 3.5 2.22198 3.5 2.7611Z"></path></svg><span data-processed="true">58s</span></div><div class="s3ITrd" data-processed="true" style="background: none 0% 0% / auto repeat scroll padding-box border-box rgb(255, 255, 255); opacity: 0.85; display: flex; height: 3.99375px; justify-content: center; position: absolute; z-index: 1; left: 352.631px; width: 12.15px;"><div class="PoLW7d" data-processed="true" style="position: absolute; border-left: 3.5px solid transparent; border-right: 3.5px solid transparent; border-top: 2.4px solid rgb(255, 255, 255); top: -7px;">  
</div></div></div><div class="dumoDb YkW4Kb" data-processed="true" style="z-index: 2; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0.6); border-radius: 100px; cursor: pointer; position: absolute; right: 14px; top: 12px;"><div class="CaQWce" data-processed="true" jscontroller="sRLmTc" jsuid="wAW0We_24" style="align-items: center; color: rgb(255, 255, 255); display: flex; height: 20px; justify-content: center; transform: rotate(45deg); width: 20px;"><svg fill="currentColor" height="18px" viewbox="0 -960 960 960" width="18px" xmlns="http://www.w3.org/2000/svg"><path d="M480-120 300-300l58-58 122 122 122-122 58 58-180 180ZM358-598l-58-58 180-180 180 180-58 58-122-122-122 122Z" fill="currentColor"></path></svg></div></div></div></div></div><div data-processed="true">[<div class="RhEuY" data-processed="true" style="display: flex; padding: 16px 12px 12px; gap: 8px; align-items: center;"><div class="SWvopd" data-processed="true" jscontroller="aNJZAb" jsuid="wAW0We_25" style="height: fit-content; width: fit-content; margin-bottom: 2px; position: relative;"><div class="Lki2rc" data-processed="true" style="width: 20px; height: 20px; line-height: 20px;"><div aria-hidden="true" class="U9BD8 Wsaimf QyEYne" data-processed="true" jscontroller="Cky8Oc" jsuid="wAW0We_26" style="width: 19.9875px; height: 19.9875px; line-height: 16px; display: flex; flex-shrink: 0; align-items: center; justify-content: center; overflow: hidden; background-color: rgb(255, 255, 255); border-radius: 50%;">![](https://articles.ravapps.com/uploads/images/gallery/2025-12/2TagcWKbNJy9QR2k-embedded-image-1a8fa6tk.png)</div></div><div class="JccCTc xG6cCf" data-processed="true" style="position: absolute; bottom: -4px; right: -4px; border-radius: 50%; line-height: 10px; padding: 2px; background-color: rgb(255, 255, 255); width: 10px; height: 10px;"><div aria-hidden="true" class="U9BD8 Wsaimf QyEYne" data-processed="true" jscontroller="Cky8Oc" jsuid="wAW0We_27" style="width: 9.99375px; height: 9.99375px; line-height: 16px; display: flex; flex-shrink: 0; align-items: center; justify-content: center; overflow: hidden; background-color: rgb(255, 255, 255); border-radius: 50%;">![](https://articles.ravapps.com/uploads/images/gallery/2025-12/6KZCyutDjdRbRT4I-embedded-image-81lbc6aw.png)</div></div></div><div data-processed="true"><div class="SrjfCd" data-processed="true" style="color: rgb(31, 31, 31); font-size: 12px; line-height: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;">solarwindsinc</div><div class="Pcl3Vd" data-processed="true" style="color: rgb(31, 31, 31); letter-spacing: 0px; font-size: 11px; line-height: 13px;">YouTube • 12 Oct 2021</div></div></div>](https://www.youtube.com/watch?v=eWBjIHfMWWc&t=1797)</div></div></div></div></div></div>2. <span class="T286Pc" data-processed="true" data-sfc-cp="" style="overflow-wrap: break-word;">**Query &amp; Aggregation Optimization:**</span>
    - <span class="T286Pc" data-processed="true" data-sfc-cp="" style="overflow-wrap: break-word;">**Use the Profiler:** Enable the database profiler to find slow queries exceeding a threshold.</span>
    - <span class="T286Pc" data-processed="true" data-sfc-cp="" style="overflow-wrap: break-word;">**`explain()` Plan:** Analyze `explain()` output to see if indexes are used, how many documents are examined, and identify bottlenecks.</span>
    - <span class="T286Pc" data-processed="true" data-sfc-cp="" style="overflow-wrap: break-word;">**Projection:** Use `projection` to return only needed fields, reducing network traffic and memory.</span>
    - <span class="T286Pc" data-processed="true" data-sfc-cp="" style="overflow-wrap: break-word;">**Aggregation Pipelines:** Optimize stages, push filters down, and use appropriate operators for complex data processing.</span><span class="uJ19be notranslate" data-processed="true" data-wiz-uids="wAW0We_2s,wAW0We_2t,wAW0We_2u"><span class="vKEkVd" data-animation-atomic="" data-processed="true" style="white-space: nowrap; position: relative;"> <button aria-label="View related links" class="rBl3me" data-amic="true" data-icl-uuid="a64ebe34-9998-4041-9c43-249abf61b4d3" data-processed="true" data-ved="2ahUKEwj6hoq-hLaRAxV0UGwGHT4HCRsQye0OegQIBhAF" data-wiz-attrbind="disabled=wAW0We_2s/C5gNJc;class=wAW0We_2s/UpSNec;" style="margin: 0px 6px 0px 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgb(229, 237, 255); border: none; border-radius: 10px; height: 20px; padding: 0px; width: 28px; position: relative; outline: 0px; cursor: pointer;" tabindex="0"><span class="wiMplc ofC0Ud" data-processed="true" style="color: rgb(0, 29, 53); display: inline-block; transform: rotate(135deg);"><svg fill="currentColor" focusable="false" height="12px" style="margin-top: 3px;" viewbox="0 0 24 24" width="12px" xmlns="http://www.w3.org/2000/svg"><path d="M3.9 12c0-1.71 1.39-3.1 3.1-3.1h4V7H7c-2.76 0-5 2.24-5 5s2.24 5 5 5h4v-1.9H7c-1.71 0-3.1-1.39-3.1-3.1zM8 13h8v-2H8v2zm9-6h-4v1.9h4c1.71 0 3.1 1.39 3.1 3.1s-1.39 3.1-3.1 3.1h-4V17h4c2.76 0 5-2.24 5-5s-2.24-5-5-5z"></path></svg></span></button></span></span>

<div class="Y3BBE" data-hveid="CAcQAA" data-processed="true" data-sfc-cp="" id="bkmrk-this-video-demonstra" jsaction="rcuQ6b:&wAW0We_2x|npT2md" jscontroller="zcfIf" jsuid="wAW0We_2x" style="font-family: 'Google Sans', Roboto, Arial, sans-serif; font-size: 16px; line-height: 24px; overflow-wrap: break-word; margin: 10px 0px 20px; color: rgb(10, 10, 10); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">This video demonstrates how to use the profiler and analyze query plans: <div class="" data-processed="true" data-wiz-uids="wAW0We_2z,wAW0We_30" jscontroller="uDeH3" jsuid="wAW0We_2y"><div data-hveid="CAcQAQ" data-processed="true" data-ved="2ahUKEwj6hoq-hLaRAxV0UGwGHT4HCRsQ-bUQegQIBxAB"><div data-processed="true"><div class="Q2WBBe" data-processed="true" jsuid="wAW0We_30" style="container-type: inline-size; display: flex; flex-direction: column; background-color: rgb(243, 245, 246); margin-top: 12px; border-radius: 16px;"><div aria-label="" class="r0hyfc" data-animation-nesting="" data-processed="true" data-ved="2ahUKEwj6hoq-hLaRAxV0UGwGHT4HCRsQypYSegQIBxAC" jsuid="wAW0We_2z" style="overflow: hidden; position: relative; border-radius: 16px 16px 0px 0px; width: 631.987px; height: 353.906px; outline: 0px;" tabindex="-1"><div class="RtAO3b" data-processed="true" data-sfc-cp="" data-wiz-uids="wAW0We_32" jsaction="rcuQ6b:&wAW0We_31|npT2md" jscallback="gfNXHe:&wAW0We_2y:U8wGUb" jscontroller="wMmv4c" jsuid="wAW0We_31" style="width: 631.987px; height: 353.906px;"><div class="nrdPJf" data-processed="true" data-ved="2ahUKEwj6hoq-hLaRAxV0UGwGHT4HCRsQtbEQegQIBxAD" jsaction="click:&wAW0We_31|T2P31d" jsuid="wAW0We_32" role="button" style="cursor: pointer; width: 631.987px; height: 353.906px; outline: 0px;" tabindex="0">![Related video thumbnail](https://articles.ravapps.com/uploads/images/gallery/2025-12/BsedwK0vTjJm15OO-embedded-image-piu09esc.jpeg)<div class="n7j80c YkW4Kb" data-processed="true" jscontroller="ItMuwb" jsuid="wAW0We_33" style="z-index: 2; border-radius: 100px; bottom: 12px; height: 4px; left: 12px; position: absolute; width: calc(100% - 24px); --segment-bar-offset: 12px;"><div class="llCCib" data-processed="true" style="transform: translateX(-50%); width: fit-content; align-items: center; background: none 0% 0% / auto repeat scroll padding-box border-box rgb(255, 255, 255); opacity: 0.85; border-radius: 100px; color: rgb(31, 31, 31); display: flex; flex-direction: row; font-size: 12px; gap: 4px; line-height: 1.33; padding: 2px 8px; position: absolute; top: -27px; white-space: nowrap; left: 477.262px;"><svg fill="currentColor" height="12" viewbox="0 0 12 12" width="12" xmlns="http://www.w3.org/2000/svg"><path d="M3.5 2.7611V9.2386C3.5 9.77772 4.10085 10.0993 4.54942 9.80023L9.40755 6.56148C9.80832 6.2943 9.80832 5.70539 9.40755 5.43821L4.54942 2.19946C4.10085 1.90041 3.5 2.22198 3.5 2.7611Z"></path></svg><span data-processed="true">1m</span></div><div class="s3ITrd" data-processed="true" style="background: none 0% 0% / auto repeat scroll padding-box border-box rgb(255, 255, 255); opacity: 0.85; display: flex; height: 3.99375px; justify-content: center; position: absolute; z-index: 1; left: 437.737px; width: 79.0312px;"><div class="PoLW7d" data-processed="true" style="position: absolute; border-left: 3.5px solid transparent; border-right: 3.5px solid transparent; border-top: 2.4px solid rgb(255, 255, 255); top: -7px;">  
</div></div></div><div class="dumoDb YkW4Kb" data-processed="true" style="z-index: 2; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0.6); border-radius: 100px; cursor: pointer; position: absolute; right: 14px; top: 12px;"><div class="CaQWce" data-processed="true" jscontroller="sRLmTc" jsuid="wAW0We_34" style="align-items: center; color: rgb(255, 255, 255); display: flex; height: 20px; justify-content: center; transform: rotate(45deg); width: 20px;"><svg fill="currentColor" height="18px" viewbox="0 -960 960 960" width="18px" xmlns="http://www.w3.org/2000/svg"><path d="M480-120 300-300l58-58 122 122 122-122 58 58-180 180ZM358-598l-58-58 180-180 180 180-58 58-122-122-122 122Z" fill="currentColor"></path></svg></div></div></div></div></div><div data-processed="true">[<div class="RhEuY" data-processed="true" style="display: flex; padding: 16px 12px 12px; gap: 8px; align-items: center;"><div class="SWvopd" data-processed="true" jscontroller="aNJZAb" jsuid="wAW0We_35" style="height: fit-content; width: fit-content; margin-bottom: 2px; position: relative;"><div class="Lki2rc" data-processed="true" style="width: 20px; height: 20px; line-height: 20px;"><div aria-hidden="true" class="U9BD8 Wsaimf QyEYne" data-processed="true" jscontroller="Cky8Oc" jsuid="wAW0We_36" style="width: 19.9875px; height: 19.9875px; line-height: 16px; display: flex; flex-shrink: 0; align-items: center; justify-content: center; overflow: hidden; background-color: rgb(255, 255, 255); border-radius: 50%;">![](https://articles.ravapps.com/uploads/images/gallery/2025-12/QIfNd8vVldmzgbP8-embedded-image-isrsfdyw.png)</div></div><div class="JccCTc xG6cCf" data-processed="true" style="position: absolute; bottom: -4px; right: -4px; border-radius: 50%; line-height: 10px; padding: 2px; background-color: rgb(255, 255, 255); width: 10px; height: 10px;"><div aria-hidden="true" class="U9BD8 Wsaimf QyEYne" data-processed="true" jscontroller="Cky8Oc" jsuid="wAW0We_37" style="width: 9.99375px; height: 9.99375px; line-height: 16px; display: flex; flex-shrink: 0; align-items: center; justify-content: center; overflow: hidden; background-color: rgb(255, 255, 255); border-radius: 50%;">![](https://articles.ravapps.com/uploads/images/gallery/2025-12/zqzuqgfRmyGfM5FM-embedded-image-3lxaplfg.png)</div></div></div><div data-processed="true"><div class="SrjfCd" data-processed="true" style="color: rgb(31, 31, 31); font-size: 12px; line-height: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;">CodeLucky</div><div class="Pcl3Vd" data-processed="true" style="color: rgb(31, 31, 31); letter-spacing: 0px; font-size: 11px; line-height: 13px;">YouTube • 30 Aug 2025</div></div></div>](https://www.youtube.com/watch?v=h0vWdePFTFc&t=337)</div></div></div></div></div></div>3. <span class="T286Pc" data-processed="true" data-sfc-cp="" style="overflow-wrap: break-word;">**Server &amp; Storage Engine Tuning:**</span>
    - <span class="T286Pc" data-processed="true" data-sfc-cp="" style="overflow-wrap: break-word;">**WiredTiger Tickets:** Adjust `wiredTigerTicketValues` for read/write concurrency if operations queue up (tickets hit 0).</span>
    - <span class="T286Pc" data-processed="true" data-sfc-cp="" style="overflow-wrap: break-word;">**Memory:** Configure `storage.wiredTiger.engineConfig.cacheSizeGB` for optimal WiredTiger cache size.</span>
    - <span class="T286Pc" data-processed="true" data-sfc-cp="" style="overflow-wrap: break-word;">**Compression:** Enable compression (e.g., Snappy, zlib) to reduce I/O and storage, often improving performance.</span><span class="uJ19be notranslate" data-processed="true" data-wiz-uids="wAW0We_3o,wAW0We_3p,wAW0We_3q"><span class="vKEkVd" data-animation-atomic="" data-processed="true" style="white-space: nowrap; position: relative;"> <button aria-label="View related links" class="rBl3me" data-amic="true" data-icl-uuid="facadc67-a246-4d71-b39b-26703cae09ad" data-processed="true" data-ved="2ahUKEwj6hoq-hLaRAxV0UGwGHT4HCRsQye0OegQICBAE" data-wiz-attrbind="disabled=wAW0We_3o/C5gNJc;class=wAW0We_3o/UpSNec;" style="margin: 0px 6px 0px 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgb(229, 237, 255); border: none; border-radius: 10px; height: 20px; padding: 0px; width: 28px; position: relative; outline: 0px; cursor: pointer;" tabindex="0"><span class="wiMplc ofC0Ud" data-processed="true" style="color: rgb(0, 29, 53); display: inline-block; transform: rotate(135deg);"><svg fill="currentColor" focusable="false" height="12px" style="margin-top: 3px;" viewbox="0 0 24 24" width="12px" xmlns="http://www.w3.org/2000/svg"><path d="M3.9 12c0-1.71 1.39-3.1 3.1-3.1h4V7H7c-2.76 0-5 2.24-5 5s2.24 5 5 5h4v-1.9H7c-1.71 0-3.1-1.39-3.1-3.1zM8 13h8v-2H8v2zm9-6h-4v1.9h4c1.71 0 3.1 1.39 3.1 3.1s-1.39 3.1-3.1 3.1h-4V17h4c2.76 0 5-2.24 5-5s-2.24-5-5-5z"></path></svg></span></button></span></span>

<div class="Y3BBE" data-hveid="CAkQAA" data-processed="true" data-sfc-cp="" id="bkmrk-this-video-discusses" jsaction="rcuQ6b:&wAW0We_3t|npT2md" jscontroller="zcfIf" jsuid="wAW0We_3t" style="font-family: 'Google Sans', Roboto, Arial, sans-serif; font-size: 16px; line-height: 24px; overflow-wrap: break-word; margin: 10px 0px 20px; color: rgb(10, 10, 10); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">This video discusses memory settings and their impact on performance: <div class="" data-processed="true" data-wiz-uids="wAW0We_3v,wAW0We_3w" jscontroller="uDeH3" jsuid="wAW0We_3u"><div data-hveid="CAkQAQ" data-processed="true" data-ved="2ahUKEwj6hoq-hLaRAxV0UGwGHT4HCRsQ-bUQegQICRAB"><div data-processed="true"><div class="Q2WBBe" data-processed="true" jsuid="wAW0We_3w" style="container-type: inline-size; display: flex; flex-direction: column; background-color: rgb(243, 245, 246); margin-top: 12px; border-radius: 16px;"><div aria-label="" class="r0hyfc" data-animation-nesting="" data-processed="true" data-ved="2ahUKEwj6hoq-hLaRAxV0UGwGHT4HCRsQypYSegQICRAC" jsuid="wAW0We_3v" style="overflow: hidden; position: relative; border-radius: 16px 16px 0px 0px; width: 631.987px; height: 353.906px; outline: 0px;" tabindex="-1"><div class="RtAO3b" data-processed="true" data-sfc-cp="" data-wiz-uids="wAW0We_3y" jsaction="rcuQ6b:&wAW0We_3x|npT2md" jscallback="gfNXHe:&wAW0We_3u:U8wGUb" jscontroller="wMmv4c" jsuid="wAW0We_3x" style="width: 631.987px; height: 353.906px;"><div class="nrdPJf" data-processed="true" data-ved="2ahUKEwj6hoq-hLaRAxV0UGwGHT4HCRsQtbEQegQICRAD" jsaction="click:&wAW0We_3x|T2P31d" jsuid="wAW0We_3y" role="button" style="cursor: pointer; width: 631.987px; height: 353.906px; outline: 0px;" tabindex="0">![Related video thumbnail](https://articles.ravapps.com/uploads/images/gallery/2025-12/DlckaE0ATJQLJJHD-embedded-image-phlxxzrd.jpeg)<div class="n7j80c YkW4Kb" data-processed="true" jscontroller="ItMuwb" jsuid="wAW0We_3z" style="z-index: 2; border-radius: 100px; bottom: 12px; height: 4px; left: 12px; position: absolute; width: calc(100% - 24px); --segment-bar-offset: 12px;"><div class="llCCib" data-processed="true" style="transform: translateX(-50%); width: fit-content; align-items: center; background: none 0% 0% / auto repeat scroll padding-box border-box rgb(255, 255, 255); opacity: 0.85; border-radius: 100px; color: rgb(31, 31, 31); display: flex; flex-direction: row; font-size: 12px; gap: 4px; line-height: 1.33; padding: 2px 8px; position: absolute; top: -27px; white-space: nowrap; left: 243.187px;"><svg fill="currentColor" height="12" viewbox="0 0 12 12" width="12" xmlns="http://www.w3.org/2000/svg"><path d="M3.5 2.7611V9.2386C3.5 9.77772 4.10085 10.0993 4.54942 9.80023L9.40755 6.56148C9.80832 6.2943 9.80832 5.70539 9.40755 5.43821L4.54942 2.19946C4.10085 1.90041 3.5 2.22198 3.5 2.7611Z"></path></svg><span data-processed="true">47s</span></div><div class="s3ITrd" data-processed="true" style="background: none 0% 0% / auto repeat scroll padding-box border-box rgb(255, 255, 255); opacity: 0.85; display: flex; height: 3.99375px; justify-content: center; position: absolute; z-index: 1; left: 206.7px; width: 72.9562px;"><div class="PoLW7d" data-processed="true" style="position: absolute; border-left: 3.5px solid transparent; border-right: 3.5px solid transparent; border-top: 2.4px solid rgb(255, 255, 255); top: -7px;">  
</div></div></div><div class="dumoDb YkW4Kb" data-processed="true" style="z-index: 2; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0.6); border-radius: 100px; cursor: pointer; position: absolute; right: 14px; top: 12px;"><div class="CaQWce" data-processed="true" jscontroller="sRLmTc" jsuid="wAW0We_40" style="align-items: center; color: rgb(255, 255, 255); display: flex; height: 20px; justify-content: center; transform: rotate(45deg); width: 20px;"><svg fill="currentColor" height="18px" viewbox="0 -960 960 960" width="18px" xmlns="http://www.w3.org/2000/svg"><path d="M480-120 300-300l58-58 122 122 122-122 58 58-180 180ZM358-598l-58-58 180-180 180 180-58 58-122-122-122 122Z" fill="currentColor"></path></svg></div></div><div class="AJ10sd" data-processed="true" data-signal-inputs="RMdumc=wAW0We_3u/TVP8Qe" data-ved="2ahUKEwj6hoq-hLaRAxV0UGwGHT4HCRsQz_MQegQICRAE" data-wiz-uids="wAW0We_41,wAW0We_42" jsaction="rcuQ6b:&wAW0We_41|npT2md" jscontroller="oi1tWc" jsuid="wAW0We_41" style="position: absolute; inset: 0px; z-index: 1;"><video class="OjJwgf" data-processed="true" loop="loop" muted="" preload="none" src="https://encrypted-vtbn2.gstatic.com/video?q=tbn:ANd9GcQ1OnmRYmE35CGPsX4JsBGVNi2CR2ZNYzWbf436ejumRNZbQeju" style="width: 631.987px; height: 353.906px; object-fit: cover; opacity: 0; transition: opacity 0.2s ease-in-out;"></video></div></div></div></div><div data-processed="true">[<div class="RhEuY" data-processed="true" style="display: flex; padding: 16px 12px 12px; gap: 8px; align-items: center;"><div class="SWvopd" data-processed="true" jscontroller="aNJZAb" jsuid="wAW0We_43" style="height: fit-content; width: fit-content; margin-bottom: 2px; position: relative;"><div class="Lki2rc" data-processed="true" style="width: 20px; height: 20px; line-height: 20px;"><div aria-hidden="true" class="U9BD8 Wsaimf QyEYne" data-processed="true" jscontroller="Cky8Oc" jsuid="wAW0We_44" style="width: 19.9875px; height: 19.9875px; line-height: 16px; display: flex; flex-shrink: 0; align-items: center; justify-content: center; overflow: hidden; background-color: rgb(255, 255, 255); border-radius: 50%;">![](https://articles.ravapps.com/uploads/images/gallery/2025-12/r1BJKqXXceUHgDoW-embedded-image-aqlnzwmi.png)</div></div><div class="JccCTc xG6cCf" data-processed="true" style="position: absolute; bottom: -4px; right: -4px; border-radius: 50%; line-height: 10px; padding: 2px; background-color: rgb(255, 255, 255); width: 10px; height: 10px;"><div aria-hidden="true" class="U9BD8 Wsaimf QyEYne" data-processed="true" jscontroller="Cky8Oc" jsuid="wAW0We_45" style="width: 9.99375px; height: 9.99375px; line-height: 16px; display: flex; flex-shrink: 0; align-items: center; justify-content: center; overflow: hidden; background-color: rgb(255, 255, 255); border-radius: 50%;">![](https://articles.ravapps.com/uploads/images/gallery/2025-12/5v6VJMCo6tmDNSBf-embedded-image-0wjsxm9e.png)</div></div></div><div data-processed="true"><div class="SrjfCd" data-processed="true" style="color: rgb(31, 31, 31); font-size: 12px; line-height: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;">Percona</div><div class="Pcl3Vd" data-processed="true" style="color: rgb(31, 31, 31); letter-spacing: 0px; font-size: 11px; line-height: 13px;">YouTube • 19 Jan 2021</div></div></div>](https://www.youtube.com/watch?v=LEUtqqG6qhc&t=138)</div></div></div></div></div></div>4. <span class="T286Pc" data-processed="true" data-sfc-cp="" style="overflow-wrap: break-word;">**Connection Management:**</span>
    - <span class="T286Pc" data-processed="true" data-sfc-cp="" style="overflow-wrap: break-word;">**Connection Pooling:** Tune `minPoolSize`, `maxPoolSize`, and `socketTimeoutMS` in your drivers to match application load and network conditions.</span><span class="uJ19be notranslate" data-processed="true" data-wiz-uids="wAW0We_4h,wAW0We_4i,wAW0We_4j"><span class="vKEkVd" data-animation-atomic="" data-processed="true" style="white-space: nowrap; position: relative;"> <button aria-label="View related links" class="rBl3me" data-amic="true" data-icl-uuid="d633097e-0267-4908-b3c8-605ce46affe5" data-processed="true" data-ved="2ahUKEwj6hoq-hLaRAxV0UGwGHT4HCRsQye0OegQIChAC" data-wiz-attrbind="disabled=wAW0We_4h/C5gNJc;class=wAW0We_4h/UpSNec;" style="margin: 0px 6px 0px 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgb(229, 237, 255); border: none; border-radius: 10px; height: 20px; padding: 0px; width: 28px; position: relative; outline: 0px; cursor: pointer;" tabindex="0"><span class="wiMplc ofC0Ud" data-processed="true" style="color: rgb(0, 29, 53); display: inline-block; transform: rotate(135deg);"><svg fill="currentColor" focusable="false" height="12px" style="margin-top: 3px;" viewbox="0 0 24 24" width="12px" xmlns="http://www.w3.org/2000/svg"><path d="M3.9 12c0-1.71 1.39-3.1 3.1-3.1h4V7H7c-2.76 0-5 2.24-5 5s2.24 5 5 5h4v-1.9H7c-1.71 0-3.1-1.39-3.1-3.1zM8 13h8v-2H8v2zm9-6h-4v1.9h4c1.71 0 3.1 1.39 3.1 3.1s-1.39 3.1-3.1 3.1h-4V17h4c2.76 0 5-2.24 5-5s-2.24-5-5-5z"></path></svg></span></button></span></span>

<div class="Y3BBE" data-hveid="CAsQAA" data-processed="true" data-sfc-cp="" id="bkmrk-this-video-explores-" jsaction="rcuQ6b:&wAW0We_4l|npT2md" jscontroller="zcfIf" jsuid="wAW0We_4l" style="font-family: 'Google Sans', Roboto, Arial, sans-serif; font-size: 16px; line-height: 24px; overflow-wrap: break-word; margin: 10px 0px 20px; color: rgb(10, 10, 10); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">This video explores patterns for tuning MongoDB performance and scalability: <div class="" data-processed="true" data-wiz-uids="wAW0We_4n,wAW0We_4o" jscontroller="uDeH3" jsuid="wAW0We_4m"><div data-hveid="CAsQAQ" data-processed="true" data-ved="2ahUKEwj6hoq-hLaRAxV0UGwGHT4HCRsQ-bUQegQICxAB"><div data-processed="true"><div class="Q2WBBe" data-processed="true" jsuid="wAW0We_4o" style="container-type: inline-size; display: flex; flex-direction: column; background-color: rgb(243, 245, 246); margin-top: 12px; border-radius: 16px;"><div aria-label="" class="r0hyfc" data-animation-nesting="" data-processed="true" data-ved="2ahUKEwj6hoq-hLaRAxV0UGwGHT4HCRsQypYSegQICxAC" jsuid="wAW0We_4n" style="overflow: hidden; position: relative; border-radius: 16px 16px 0px 0px; width: 631.987px; height: 353.906px; outline: 0px;" tabindex="-1"><div class="RtAO3b" data-processed="true" data-sfc-cp="" data-wiz-uids="wAW0We_4q" jsaction="rcuQ6b:&wAW0We_4p|npT2md" jscallback="gfNXHe:&wAW0We_4m:U8wGUb" jscontroller="wMmv4c" jsuid="wAW0We_4p" style="width: 631.987px; height: 353.906px;"><div class="nrdPJf" data-processed="true" data-ved="2ahUKEwj6hoq-hLaRAxV0UGwGHT4HCRsQtbEQegQICxAD" jsaction="click:&wAW0We_4p|T2P31d" jsuid="wAW0We_4q" role="button" style="cursor: pointer; width: 631.987px; height: 353.906px; outline: 0px;" tabindex="0">![Related video thumbnail](https://articles.ravapps.com/uploads/images/gallery/2025-12/fhfXubGFMDtm8dze-embedded-image-c25qy8xe.jpeg)<div class="n7j80c YkW4Kb" data-processed="true" jscontroller="ItMuwb" jsuid="wAW0We_4r" style="z-index: 2; border-radius: 100px; bottom: 12px; height: 4px; left: 12px; position: absolute; width: calc(100% - 24px); --segment-bar-offset: 12px;"><div class="llCCib" data-processed="true" style="transform: translateX(-50%); width: fit-content; align-items: center; background: none 0% 0% / auto repeat scroll padding-box border-box rgb(255, 255, 255); opacity: 0.85; border-radius: 100px; color: rgb(31, 31, 31); display: flex; flex-direction: row; font-size: 12px; gap: 4px; line-height: 1.33; padding: 2px 8px; position: absolute; top: -27px; white-space: nowrap; left: 234.075px;"><svg fill="currentColor" height="12" viewbox="0 0 12 12" width="12" xmlns="http://www.w3.org/2000/svg"><path d="M3.5 2.7611V9.2386C3.5 9.77772 4.10085 10.0993 4.54942 9.80023L9.40755 6.56148C9.80832 6.2943 9.80832 5.70539 9.40755 5.43821L4.54942 2.19946C4.10085 1.90041 3.5 2.22198 3.5 2.7611Z"></path></svg><span data-processed="true">1m</span></div><div class="s3ITrd" data-processed="true" style="background: none 0% 0% / auto repeat scroll padding-box border-box rgb(255, 255, 255); opacity: 0.85; display: flex; height: 3.99375px; justify-content: center; position: absolute; z-index: 1; left: 224.944px; width: 18.225px;"><div class="PoLW7d" data-processed="true" style="position: absolute; border-left: 3.5px solid transparent; border-right: 3.5px solid transparent; border-top: 2.4px solid rgb(255, 255, 255); top: -7px;">  
</div></div></div><div class="dumoDb YkW4Kb" data-processed="true" style="z-index: 2; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0.6); border-radius: 100px; cursor: pointer; position: absolute; right: 14px; top: 12px;"><div class="CaQWce" data-processed="true" jscontroller="sRLmTc" jsuid="wAW0We_4s" style="align-items: center; color: rgb(255, 255, 255); display: flex; height: 20px; justify-content: center; transform: rotate(45deg); width: 20px;"><svg fill="currentColor" height="18px" viewbox="0 -960 960 960" width="18px" xmlns="http://www.w3.org/2000/svg"><path d="M480-120 300-300l58-58 122 122 122-122 58 58-180 180ZM358-598l-58-58 180-180 180 180-58 58-122-122-122 122Z" fill="currentColor"></path></svg></div></div></div></div></div><div data-processed="true">[<div class="RhEuY" data-processed="true" style="display: flex; padding: 16px 12px 12px; gap: 8px; align-items: center;"><div class="SWvopd" data-processed="true" jscontroller="aNJZAb" jsuid="wAW0We_4t" style="height: fit-content; width: fit-content; margin-bottom: 2px; position: relative;"><div class="Lki2rc" data-processed="true" style="width: 20px; height: 20px; line-height: 20px;"><div aria-hidden="true" class="U9BD8 Wsaimf QyEYne" data-processed="true" jscontroller="Cky8Oc" jsuid="wAW0We_4u" style="width: 19.9875px; height: 19.9875px; line-height: 16px; display: flex; flex-shrink: 0; align-items: center; justify-content: center; overflow: hidden; background-color: rgb(255, 255, 255); border-radius: 50%;">![](https://articles.ravapps.com/uploads/images/gallery/2025-12/JQQTFTduvZ5eM8wv-embedded-image-ejrdse78.png)</div></div><div class="JccCTc xG6cCf" data-processed="true" style="position: absolute; bottom: -4px; right: -4px; border-radius: 50%; line-height: 10px; padding: 2px; background-color: rgb(255, 255, 255); width: 10px; height: 10px;"><div aria-hidden="true" class="U9BD8 Wsaimf QyEYne" data-processed="true" jscontroller="Cky8Oc" jsuid="wAW0We_4v" style="width: 9.99375px; height: 9.99375px; line-height: 16px; display: flex; flex-shrink: 0; align-items: center; justify-content: center; overflow: hidden; background-color: rgb(255, 255, 255); border-radius: 50%;">![](https://articles.ravapps.com/uploads/images/gallery/2025-12/jOwVaGHhibB8yrn4-embedded-image-vrzru0wj.png)</div></div></div><div data-processed="true"><div class="SrjfCd" data-processed="true" style="color: rgb(31, 31, 31); font-size: 12px; line-height: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;">MongoDB</div><div class="Pcl3Vd" data-processed="true" style="color: rgb(31, 31, 31); letter-spacing: 0px; font-size: 11px; line-height: 13px;">YouTube • 21 Nov 2022</div></div></div>](https://www.youtube.com/watch?v=xpHjnFXICh8&t=700)</div></div></div></div></div></div>5. <span class="T286Pc" data-processed="true" data-sfc-cp="" style="overflow-wrap: break-word;">**Hardware &amp; OS (Advanced):**</span>
    - <span class="T286Pc" data-processed="true" data-sfc-cp="" style="overflow-wrap: break-word;">**NUMA Settings:** Configure BIOS/OS settings (like `iommu=pt`) for optimal CPU/memory interaction on NUMA systems.</span><span class="uJ19be notranslate" data-processed="true" data-wiz-uids="wAW0We_55,wAW0We_56,wAW0We_57"><span class="vKEkVd" data-animation-atomic="" data-processed="true" style="white-space: nowrap; position: relative;"> <button aria-label="View related links" class="rBl3me" data-amic="true" data-icl-uuid="ba6f4966-9fe1-4483-895a-ea1cea237df0" data-processed="true" data-ved="2ahUKEwj6hoq-hLaRAxV0UGwGHT4HCRsQye0OegQIDBAC" data-wiz-attrbind="disabled=wAW0We_55/C5gNJc;class=wAW0We_55/UpSNec;" style="margin: 0px 6px 0px 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgb(229, 237, 255); border: none; border-radius: 10px; height: 20px; padding: 0px; width: 28px; position: relative; outline: 0px; cursor: pointer;" tabindex="0"><span class="wiMplc ofC0Ud" data-processed="true" style="color: rgb(0, 29, 53); display: inline-block; transform: rotate(135deg);"><svg fill="currentColor" focusable="false" height="12px" style="margin-top: 3px;" viewbox="0 0 24 24" width="12px" xmlns="http://www.w3.org/2000/svg"><path d="M3.9 12c0-1.71 1.39-3.1 3.1-3.1h4V7H7c-2.76 0-5 2.24-5 5s2.24 5 5 5h4v-1.9H7c-1.71 0-3.1-1.39-3.1-3.1zM8 13h8v-2H8v2zm9-6h-4v1.9h4c1.71 0 3.1 1.39 3.1 3.1s-1.39 3.1-3.1 3.1h-4V17h4c2.76 0 5-2.24 5-5s-2.24-5-5-5z"></path></svg></span></button></span></span>

<div class="Fsg96" data-processed="true" data-sfc-cp="" id="bkmrk--6" jsaction="rcuQ6b:&wAW0We_59|npT2md" jscontroller="KHhJQ" jsuid="wAW0We_59" style="color: rgb(10, 10, 10); font-family: 'Google Sans', Roboto, Arial, sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">  
</div><div aria-level="3" class="otQkpb" data-animation-nesting="" data-processed="true" data-sfc-cp="" id="bkmrk-general-approach" jscontroller="a7qCn" jsuid="wAW0We_5a" role="heading" style="color: rgb(0, 29, 53); font-family: 'Google Sans', Roboto, Arial, sans-serif; font-size: 20px; line-height: 28px; margin: 20px 0px 10px; font-weight: 600; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">General Approach<span class="txxDge notranslate" data-processed="true" data-wiz-uids="wAW0We_5b,wAW0We_5c,wAW0We_5d" style="visibility: hidden;"><span class="vKEkVd" data-animation-atomic="" data-processed="true" style="white-space: nowrap; position: relative;"><button aria-label="View related links" class="rBl3me" data-amic="true" data-icl-uuid="ebc9d4d1-38b9-475c-b6ee-85e207af8b98" data-processed="true" data-ved="2ahUKEwj6hoq-hLaRAxV0UGwGHT4HCRsQye0OegQIDRAA" data-wiz-attrbind="disabled=wAW0We_5b/C5gNJc;class=wAW0We_5b/UpSNec;" style="margin: 0px 6px 0px 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgb(229, 237, 255); border: none; border-radius: 10px; height: 20px; padding: 0px; width: 28px; position: relative; outline: 0px; cursor: pointer;" tabindex="0"><span class="wiMplc ofC0Ud" data-processed="true" style="color: rgb(0, 29, 53); display: inline-block; transform: rotate(135deg);"><svg fill="currentColor" focusable="false" height="12px" style="margin-top: 3px;" viewbox="0 0 24 24" width="12px" xmlns="http://www.w3.org/2000/svg"><path d="M3.9 12c0-1.71 1.39-3.1 3.1-3.1h4V7H7c-2.76 0-5 2.24-5 5s2.24 5 5 5h4v-1.9H7c-1.71 0-3.1-1.39-3.1-3.1zM8 13h8v-2H8v2zm9-6h-4v1.9h4c1.71 0 3.1 1.39 3.1 3.1s-1.39 3.1-3.1 3.1h-4V17h4c2.76 0 5-2.24 5-5s-2.24-5-5-5z"></path></svg></span></button></span></span></div>- <span class="T286Pc" data-processed="true" data-sfc-cp="" style="overflow-wrap: break-word;">**Monitor:** Use MongoDB Atlas metrics or tools like `mongostat`, `mongotop`, and the profiler.</span>
- <span class="T286Pc" data-processed="true" data-sfc-cp="" style="overflow-wrap: break-word;">**Methodical Changes:** Apply changes one at a time and measure the impact.</span>
- <span class="T286Pc" data-processed="true" data-sfc-cp="" style="overflow-wrap: break-word;">**Balance:** Indexing speeds up reads but slows writes; find the right balance for your workload.</span><span class="uJ19be notranslate" data-processed="true" data-wiz-uids="wAW0We_6k,wAW0We_6l,wAW0We_6m"><span class="vKEkVd" data-animation-atomic="" data-processed="true" style="white-space: nowrap; position: relative;"> </span></span>

# Laboriosam pariatur sed sequi aut est adipisci et quos.

Doloribus perspiciatis nesciunt ipsam assumenda delectus sit. Qui id soluta libero voluptates corporis placeat. Nam veritatis aut aut debitis.

Consectetur et optio ullam reprehenderit accusantium sunt. Rerum illo saepe dolor et quia minus consequatur. Dolores hic autem delectus aspernatur sequi qui.Eius voluptas beatae voluptas ut doloremque cumque rerum. Ab asperiores dicta necessitatibus aut voluptatem.Vel commodi quo est beatae. Cumque adipisci quos vitae officiis.Omnis deleniti illo quae ut aut nemo earum. Sit qui sapiente velit qui molestiae. Distinctio enim tempora temporibus incidunt corporis.

# Nesciunt laudantium sint ut iusto nisi distinctio.

Molestias minus doloremque voluptatum id saepe dolor. Sed sint officia ut. Recusandae distinctio voluptas ut natus cum eligendi et. Placeat magni velit veniam ex labore.

Ab reprehenderit voluptatem ipsam temporibus esse. Et dolor et maxime aut voluptas consectetur expedita. Sapiente pariatur hic tempora. Hic aut assumenda quis velit accusantium dolore perferendis.Dolorum nesciunt ut sint in rerum nisi. Qui quas officiis dolore incidunt nisi facere. Enim libero explicabo optio libero ut voluptatem quos sit. Doloribus cupiditate dignissimos et molestias.Ea aut enim expedita eos voluptatum perferendis et. Sequi natus sed qui exercitationem iusto quia. Sunt quos qui voluptatem corrupti. Et soluta molestiae eum assumenda enim impedit iste inventore.Modi ipsam aut aut maiores. Sint eaque sit non sunt autem neque dicta.

# MongoDB: average value of field

<div data-hveid="CAkQBg" data-ved="2ahUKEwj4t7Ddl5yRAxUFRmcHHbfJCWEQ7uAMegQICRAG" id="bkmrk-to-calculate-the-ave"><div jsaction="rcuQ6b:npT2md;YbaXcb:oMGkAb;DfLsBc:N6Mv3e;Wyhgxe:daG3j;rkJ0hb:daG3j;j92B8:N6Mv3e" jscontroller="qwbW4b" jsmodel="k8Azyd E23uIf" jsname="Y0vxu"><div class="UxeQfc" style="display: grid; grid-template-columns: minmax(0px, 1fr) 316px; column-gap: 40px;"><div class="LT6XE" style="display: flow-root; color: rgb(10, 10, 10); --m3c9: #0a0a0a; --m3c11: #0a0a0a; overflow-y: clip; position: relative; overflow-wrap: break-word; max-width: 100%; min-width: 0px; flex: 1 1 0%;"><div class="pOOWX f5cPye" data-lht="1464" data-rl="en" jsname="dvXlsc" style="letter-spacing: normal;"><div class="Ii22Cf" data-oto="48" data-tr-cl="magi-translate" data-tr-sl="en" data-tr-tl="hi" jsaction="rcuQ6b:npT2md" jscontroller="MN6hqd" jsname="lcCwgb"><div jsname="kj7T5c"><div jsname="PLkxOb"><div><div class="WaaZC"><div class="RJPOee EIJn2" style="animation: auto ease 0s 1 normal none running none !important; color: rgb(10, 10, 10);"><div class="rPeykc" data-hveid="CAcQAQ" data-ved="2ahUKEwj4t7Ddl5yRAxUFRmcHHbfJCWEQo_EKegQIBxAB" style="margin: 0px 0px 10px;"><span data-huuid="17045499108700065023">To calculate the average value of a field in MongoDB using the shell, the aggregation framework with the `$avg` operator is utilized.</span></div></div></div><div class="WaaZC"><div class="RJPOee EIJn2" style="animation: auto ease 0s 1 normal none running none !important; color: rgb(10, 10, 10);"><div aria-level="3" class="rPeykc pyPiTc" data-hveid="CAgQAQ" data-ved="2ahUKEwj4t7Ddl5yRAxUFRmcHHbfJCWEQo_EKegQICBAB" role="heading" style="margin: 20px 0px 10px; font-size: 20px; font-weight: 600; line-height: 28px;"><span data-huuid="17045499108700064241">Example 1: Calculating the average of a field across the entire collection</span></div></div></div><div class="WaaZC"><div class="RJPOee EIJn2" style="animation: auto ease 0s 1 normal none running none !important; color: rgb(10, 10, 10);"><div class="rPeykc" data-hveid="CAQQAQ" data-ved="2ahUKEwj4t7Ddl5yRAxUFRmcHHbfJCWEQo_EKegQIBBAB" style="margin: 10px 0px;"><span data-huuid="17045499108700063459">Assume a collection named `products` with documents like:</span></div></div></div><div class="WaaZC"><div class="RJPOee EIJn2" style="animation: auto ease 0s 1 normal none running none !important; color: rgb(10, 10, 10);"><div jsaction="rcuQ6b:npT2md" jscontroller="JegcYe"><div class="ecCNFc" style="border-image: none 100% / 1 / 0 stretch; border-radius: 8px; font-size: 14px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(245, 248, 255, 0.5); margin-bottom: 20px; color: rgb(10, 10, 10); border: 0.8px solid rgb(169, 172, 170);"><div class="zYSUYd" style="display: flex; flex-direction: row; overflow: hidden; border-radius: 8px 8px 0px 0px;"><div class="FS7GEb" style="display: flex; flex-direction: column; flex-grow: 1; min-width: 38%; width: 518.4px;"><div class="dDrxod" style="height: 34px; display: flex; justify-content: space-between; align-items: center; background: none 0% 0% / auto repeat scroll padding-box border-box rgb(229, 237, 255); border-bottom: 0.8px solid rgb(169, 172, 170);"><div class="x7ndcb" style="padding-left: 16px; display: flex; align-items: center; color: rgb(10, 10, 10);">Code</div><div aria-live="polite" class="WDoJJe" style="margin-right: 4px; display: flex; align-items: center;"><button aria-label="Copy code to clipboard" class="hqI3tf B4zsNc" data-ved="2ahUKEwj4t7Ddl5yRAxUFRmcHHbfJCWEQ9MILegQIAhAB" role="button" style="margin: 0px 2px; background: none; height: 34px; border: none; color: rgb(5, 40, 97); position: relative; top: 2px; outline: 0px;" tabindex="0" title="Copy"><span class="z1asCe wm4nBd" style="display: inline-block; fill: currentcolor; height: 20px; line-height: 20px; position: relative; width: 20px;"><svg aria-hidden="true" enable-background="new 0 0 24 24" focusable="false" height="24" viewbox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><g><rect fill="none" height="24" width="24"></rect></g><g><path d="M16,20H5V6H3v14c0,1.1,0.9,2,2,2h11V20z M20,16V4c0-1.1-0.9-2-2-2H9C7.9,2,7,2.9,7,4v12c0,1.1,0.9,2,2,2h9 C19.1,18,20,17.1,20,16z M18,16H9V4h9V16z"></path></g></svg></span></button></div></div></div></div><div class="QQjpRc" style="display: flex; flex-direction: row; overflow: hidden; border-radius: 0px 0px 8px 8px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(245, 248, 255, 0.5);"><div class="FS7GEb" jsname="zEXxAd" style="display: flex; flex-direction: column; flex-grow: 1; min-width: 38%; width: 518.4px;"></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div>```
{ "_id": 1, "item": "A", "price": 10 }
{ "_id": 2, "item": "B", "price": 15 }
{ "_id": 3, "item": "C", "price": 20 }
{ "_id": 4, "item": "D", "price": 12 }
```

<div data-hveid="CAkQBg" data-ved="2ahUKEwj4t7Ddl5yRAxUFRmcHHbfJCWEQ7uAMegQICRAG" id="bkmrk-to-find-the-average%C2%A0"><div jsaction="rcuQ6b:npT2md;YbaXcb:oMGkAb;DfLsBc:N6Mv3e;Wyhgxe:daG3j;rkJ0hb:daG3j;j92B8:N6Mv3e" jscontroller="qwbW4b" jsmodel="k8Azyd E23uIf" jsname="Y0vxu"><div class="UxeQfc" style="display: grid; grid-template-columns: minmax(0px, 1fr) 316px; column-gap: 40px;"><div class="LT6XE" style="display: flow-root; color: rgb(10, 10, 10); --m3c9: #0a0a0a; --m3c11: #0a0a0a; overflow-y: clip; position: relative; overflow-wrap: break-word; max-width: 100%; min-width: 0px; flex: 1 1 0%;"><div class="pOOWX f5cPye" data-lht="1464" data-rl="en" jsname="dvXlsc" style="letter-spacing: normal;"><div class="Ii22Cf" data-oto="48" data-tr-cl="magi-translate" data-tr-sl="en" data-tr-tl="hi" jsaction="rcuQ6b:npT2md" jscontroller="MN6hqd" jsname="lcCwgb"><div jsname="kj7T5c"><div jsname="PLkxOb"><div><div class="WaaZC"><div class="RJPOee EIJn2" style="animation: auto ease 0s 1 normal none running none !important; color: rgb(10, 10, 10);"><div jsaction="rcuQ6b:npT2md" jscontroller="JegcYe"><div class="ecCNFc" style="border-image: none 100% / 1 / 0 stretch; border-radius: 8px; font-size: 14px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(245, 248, 255, 0.5); margin-bottom: 20px; color: rgb(10, 10, 10); border: 0.8px solid rgb(169, 172, 170);"><div class="QQjpRc" style="display: flex; flex-direction: row; overflow: hidden; border-radius: 0px 0px 8px 8px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(245, 248, 255, 0.5);"><div class="FS7GEb" jsname="zEXxAd" style="display: flex; flex-direction: column; flex-grow: 1; min-width: 38%; width: 518.4px;"></div></div></div></div></div></div><div class="WaaZC"><div class="RJPOee EIJn2" style="animation: auto ease 0s 1 normal none running none !important; color: rgb(10, 10, 10);"><div class="rPeykc" data-hveid="CA8QAQ" data-ved="2ahUKEwj4t7Ddl5yRAxUFRmcHHbfJCWEQo_EKegQIDxAB" style="margin: 10px 0px;"><span data-huuid="1873820521089915384">To find the average `price` of all products:</span></div></div></div><div class="WaaZC"><div class="RJPOee EIJn2" style="animation: auto ease 0s 1 normal none running none !important; color: rgb(10, 10, 10);"><div jsaction="rcuQ6b:npT2md" jscontroller="JegcYe"><div class="ecCNFc" style="border-image: none 100% / 1 / 0 stretch; border-radius: 8px; font-size: 14px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(245, 248, 255, 0.5); margin-bottom: 20px; color: rgb(10, 10, 10); border: 0.8px solid rgb(169, 172, 170);"><div class="zYSUYd" style="display: flex; flex-direction: row; overflow: hidden; border-radius: 8px 8px 0px 0px;"><div class="FS7GEb" style="display: flex; flex-direction: column; flex-grow: 1; min-width: 38%; width: 518.4px;"><div class="dDrxod" style="height: 34px; display: flex; justify-content: space-between; align-items: center; background: none 0% 0% / auto repeat scroll padding-box border-box rgb(229, 237, 255); border-bottom: 0.8px solid rgb(169, 172, 170);"><div class="x7ndcb" style="padding-left: 16px; display: flex; align-items: center; color: rgb(10, 10, 10);">JavaScript</div><div aria-live="polite" class="WDoJJe" style="margin-right: 4px; display: flex; align-items: center;"><button aria-label="Copy code to clipboard" class="hqI3tf B4zsNc" data-ved="2ahUKEwj4t7Ddl5yRAxUFRmcHHbfJCWEQ9MILegQIDhAB" role="button" style="margin: 0px 2px; background: none; height: 34px; border: none; color: rgb(5, 40, 97); position: relative; top: 2px; outline: 0px;" tabindex="0" title="Copy"><span class="z1asCe wm4nBd" style="display: inline-block; fill: currentcolor; height: 20px; line-height: 20px; position: relative; width: 20px;"><svg aria-hidden="true" enable-background="new 0 0 24 24" focusable="false" height="24" viewbox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><g><rect fill="none" height="24" width="24"></rect></g><g><path d="M16,20H5V6H3v14c0,1.1,0.9,2,2,2h11V20z M20,16V4c0-1.1-0.9-2-2-2H9C7.9,2,7,2.9,7,4v12c0,1.1,0.9,2,2,2h9 C19.1,18,20,17.1,20,16z M18,16H9V4h9V16z"></path></g></svg></span></button></div></div></div></div><div class="QQjpRc" style="display: flex; flex-direction: row; overflow: hidden; border-radius: 0px 0px 8px 8px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(245, 248, 255, 0.5);"><div class="FS7GEb" jsname="zEXxAd" style="display: flex; flex-direction: column; flex-grow: 1; min-width: 38%; width: 518.4px;"></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div>```
db.products.aggregate([
  {
    $group: {
      _id: null, // Group all documents into a single group
      averagePrice: { $avg: "$price" } // Calculate the average of the 'price' field
    }
  }
])
```

<div data-hveid="CAkQBg" data-ved="2ahUKEwj4t7Ddl5yRAxUFRmcHHbfJCWEQ7uAMegQICRAG" id="bkmrk-this-query-would-ret"><div jsaction="rcuQ6b:npT2md;YbaXcb:oMGkAb;DfLsBc:N6Mv3e;Wyhgxe:daG3j;rkJ0hb:daG3j;j92B8:N6Mv3e" jscontroller="qwbW4b" jsmodel="k8Azyd E23uIf" jsname="Y0vxu"><div class="UxeQfc" style="display: grid; grid-template-columns: minmax(0px, 1fr) 316px; column-gap: 40px;"><div class="LT6XE" style="display: flow-root; color: rgb(10, 10, 10); --m3c9: #0a0a0a; --m3c11: #0a0a0a; overflow-y: clip; position: relative; overflow-wrap: break-word; max-width: 100%; min-width: 0px; flex: 1 1 0%;"><div class="pOOWX f5cPye" data-lht="1464" data-rl="en" jsname="dvXlsc" style="letter-spacing: normal;"><div class="Ii22Cf" data-oto="48" data-tr-cl="magi-translate" data-tr-sl="en" data-tr-tl="hi" jsaction="rcuQ6b:npT2md" jscontroller="MN6hqd" jsname="lcCwgb"><div jsname="kj7T5c"><div jsname="PLkxOb"><div><div class="WaaZC"><div class="RJPOee EIJn2" style="animation: auto ease 0s 1 normal none running none !important; color: rgb(10, 10, 10);"><div jsaction="rcuQ6b:npT2md" jscontroller="JegcYe"><div class="ecCNFc" style="border-image: none 100% / 1 / 0 stretch; border-radius: 8px; font-size: 14px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(245, 248, 255, 0.5); margin-bottom: 20px; color: rgb(10, 10, 10); border: 0.8px solid rgb(169, 172, 170);"><div class="QQjpRc" style="display: flex; flex-direction: row; overflow: hidden; border-radius: 0px 0px 8px 8px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(245, 248, 255, 0.5);"><div class="FS7GEb" jsname="zEXxAd" style="display: flex; flex-direction: column; flex-grow: 1; min-width: 38%; width: 518.4px;"></div></div></div></div></div></div><div class="WaaZC"><div class="RJPOee EIJn2" style="animation: auto ease 0s 1 normal none running none !important; color: rgb(10, 10, 10);"><div class="rPeykc" data-hveid="CBUQAQ" data-ved="2ahUKEwj4t7Ddl5yRAxUFRmcHHbfJCWEQo_EKegQIFRAB" style="margin: 10px 0px;"><span data-huuid="13400715781519751995">This query would return a result similar to:</span></div></div></div><div class="WaaZC"><div class="RJPOee EIJn2" style="animation: auto ease 0s 1 normal none running none !important; color: rgb(10, 10, 10);"><div jsaction="rcuQ6b:npT2md" jscontroller="JegcYe"><div class="ecCNFc" style="border-image: none 100% / 1 / 0 stretch; border-radius: 8px; font-size: 14px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(245, 248, 255, 0.5); margin-bottom: 20px; color: rgb(10, 10, 10); border: 0.8px solid rgb(169, 172, 170);"><div class="zYSUYd" style="display: flex; flex-direction: row; overflow: hidden; border-radius: 8px 8px 0px 0px;"><div class="FS7GEb" style="display: flex; flex-direction: column; flex-grow: 1; min-width: 38%; width: 518.4px;"><div class="dDrxod" style="height: 34px; display: flex; justify-content: space-between; align-items: center; background: none 0% 0% / auto repeat scroll padding-box border-box rgb(229, 237, 255); border-bottom: 0.8px solid rgb(169, 172, 170);"><div class="x7ndcb" style="padding-left: 16px; display: flex; align-items: center; color: rgb(10, 10, 10);">Code</div><div aria-live="polite" class="WDoJJe" style="margin-right: 4px; display: flex; align-items: center;"><button aria-label="Copy code to clipboard" class="hqI3tf B4zsNc" data-ved="2ahUKEwj4t7Ddl5yRAxUFRmcHHbfJCWEQ9MILegQIExAB" role="button" style="margin: 0px 2px; background: none; height: 34px; border: none; color: rgb(5, 40, 97); position: relative; top: 2px; outline: 0px;" tabindex="0" title="Copy"><span class="z1asCe wm4nBd" style="display: inline-block; fill: currentcolor; height: 20px; line-height: 20px; position: relative; width: 20px;"><svg aria-hidden="true" enable-background="new 0 0 24 24" focusable="false" height="24" viewbox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><g><rect fill="none" height="24" width="24"></rect></g><g><path d="M16,20H5V6H3v14c0,1.1,0.9,2,2,2h11V20z M20,16V4c0-1.1-0.9-2-2-2H9C7.9,2,7,2.9,7,4v12c0,1.1,0.9,2,2,2h9 C19.1,18,20,17.1,20,16z M18,16H9V4h9V16z"></path></g></svg></span></button></div></div></div></div><div class="QQjpRc" style="display: flex; flex-direction: row; overflow: hidden; border-radius: 0px 0px 8px 8px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(245, 248, 255, 0.5);"><div class="FS7GEb" jsname="zEXxAd" style="display: flex; flex-direction: column; flex-grow: 1; min-width: 38%; width: 518.4px;"></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div>```
{ "_id": null, "averagePrice": 14.25 }
```

<div data-hveid="CAkQBg" data-ved="2ahUKEwj4t7Ddl5yRAxUFRmcHHbfJCWEQ7uAMegQICRAG" id="bkmrk-example-2%3A-calculati"><div jsaction="rcuQ6b:npT2md;YbaXcb:oMGkAb;DfLsBc:N6Mv3e;Wyhgxe:daG3j;rkJ0hb:daG3j;j92B8:N6Mv3e" jscontroller="qwbW4b" jsmodel="k8Azyd E23uIf" jsname="Y0vxu"><div class="UxeQfc" style="display: grid; grid-template-columns: minmax(0px, 1fr) 316px; column-gap: 40px;"><div class="LT6XE" style="display: flow-root; color: rgb(10, 10, 10); --m3c9: #0a0a0a; --m3c11: #0a0a0a; overflow-y: clip; position: relative; overflow-wrap: break-word; max-width: 100%; min-width: 0px; flex: 1 1 0%;"><div class="pOOWX f5cPye" data-lht="1464" data-rl="en" jsname="dvXlsc" style="letter-spacing: normal;"><div class="Ii22Cf" data-oto="48" data-tr-cl="magi-translate" data-tr-sl="en" data-tr-tl="hi" jsaction="rcuQ6b:npT2md" jscontroller="MN6hqd" jsname="lcCwgb"><div jsname="kj7T5c"><div jsname="PLkxOb"><div><div class="WaaZC"><div class="RJPOee EIJn2" style="animation: auto ease 0s 1 normal none running none !important; color: rgb(10, 10, 10);"><div jsaction="rcuQ6b:npT2md" jscontroller="JegcYe"><div class="ecCNFc" style="border-image: none 100% / 1 / 0 stretch; border-radius: 8px; font-size: 14px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(245, 248, 255, 0.5); margin-bottom: 20px; color: rgb(10, 10, 10); border: 0.8px solid rgb(169, 172, 170);"><div class="QQjpRc" style="display: flex; flex-direction: row; overflow: hidden; border-radius: 0px 0px 8px 8px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(245, 248, 255, 0.5);"><div class="FS7GEb" jsname="zEXxAd" style="display: flex; flex-direction: column; flex-grow: 1; min-width: 38%; width: 518.4px;"></div></div></div></div></div></div><div class="WaaZC"><div class="RJPOee EIJn2" style="animation: auto ease 0s 1 normal none running none !important; color: rgb(10, 10, 10);"><div aria-level="3" class="rPeykc pyPiTc" data-hveid="CBsQAQ" data-ved="2ahUKEwj4t7Ddl5yRAxUFRmcHHbfJCWEQo_EKegQIGxAB" role="heading" style="margin: 20px 0px 10px; font-size: 20px; font-weight: 600; line-height: 28px;"><span data-huuid="9763489124590071733">Example 2: Calculating the average of a field grouped by another field</span></div></div></div><div class="WaaZC"><div class="RJPOee EIJn2" style="animation: auto ease 0s 1 normal none running none !important; color: rgb(10, 10, 10);"><div class="rPeykc" data-hveid="CBkQAQ" data-ved="2ahUKEwj4t7Ddl5yRAxUFRmcHHbfJCWEQo_EKegQIGRAB" style="margin: 10px 0px;"><span data-huuid="9763489124590071143">To find the average `price` grouped by `item`:</span></div></div></div><div class="WaaZC"><div class="RJPOee EIJn2" style="animation: auto ease 0s 1 normal none running none !important; color: rgb(10, 10, 10);"><div jsaction="rcuQ6b:npT2md" jscontroller="JegcYe"><div class="ecCNFc" style="border-image: none 100% / 1 / 0 stretch; border-radius: 8px; font-size: 14px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(245, 248, 255, 0.5); margin-bottom: 20px; color: rgb(10, 10, 10); border: 0.8px solid rgb(169, 172, 170);"><div class="zYSUYd" style="display: flex; flex-direction: row; overflow: hidden; border-radius: 8px 8px 0px 0px;"><div class="FS7GEb" style="display: flex; flex-direction: column; flex-grow: 1; min-width: 38%; width: 518.4px;"><div class="dDrxod" style="height: 34px; display: flex; justify-content: space-between; align-items: center; background: none 0% 0% / auto repeat scroll padding-box border-box rgb(229, 237, 255); border-bottom: 0.8px solid rgb(169, 172, 170);"><div class="x7ndcb" style="padding-left: 16px; display: flex; align-items: center; color: rgb(10, 10, 10);">JavaScript</div><div aria-live="polite" class="WDoJJe" style="margin-right: 4px; display: flex; align-items: center;"><button aria-label="Copy code to clipboard" class="hqI3tf B4zsNc" data-ved="2ahUKEwj4t7Ddl5yRAxUFRmcHHbfJCWEQ9MILegQIGBAB" role="button" style="margin: 0px 2px; background: none; height: 34px; border: none; color: rgb(5, 40, 97); position: relative; top: 2px; outline: 0px;" tabindex="0" title="Copy"><span class="z1asCe wm4nBd" style="display: inline-block; fill: currentcolor; height: 20px; line-height: 20px; position: relative; width: 20px;"><svg aria-hidden="true" enable-background="new 0 0 24 24" focusable="false" height="24" viewbox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><g><rect fill="none" height="24" width="24"></rect></g><g><path d="M16,20H5V6H3v14c0,1.1,0.9,2,2,2h11V20z M20,16V4c0-1.1-0.9-2-2-2H9C7.9,2,7,2.9,7,4v12c0,1.1,0.9,2,2,2h9 C19.1,18,20,17.1,20,16z M18,16H9V4h9V16z"></path></g></svg></span></button></div></div></div></div><div class="QQjpRc" style="display: flex; flex-direction: row; overflow: hidden; border-radius: 0px 0px 8px 8px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(245, 248, 255, 0.5);"><div class="FS7GEb" jsname="zEXxAd" style="display: flex; flex-direction: column; flex-grow: 1; min-width: 38%; width: 518.4px;"></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div>```
db.products.aggregate([
  {
    $group: {
      _id: "$item", // Group documents by the 'item' field
      averagePrice: { $avg: "$price" } // Calculate the average of 'price' for each group
    }
  }
])
```

<div data-hveid="CAkQBg" data-ved="2ahUKEwj4t7Ddl5yRAxUFRmcHHbfJCWEQ7uAMegQICRAG" id="bkmrk-if-the%C2%A0products%C2%A0coll"><div jsaction="rcuQ6b:npT2md;YbaXcb:oMGkAb;DfLsBc:N6Mv3e;Wyhgxe:daG3j;rkJ0hb:daG3j;j92B8:N6Mv3e" jscontroller="qwbW4b" jsmodel="k8Azyd E23uIf" jsname="Y0vxu"><div class="UxeQfc" style="display: grid; grid-template-columns: minmax(0px, 1fr) 316px; column-gap: 40px;"><div class="LT6XE" style="display: flow-root; color: rgb(10, 10, 10); --m3c9: #0a0a0a; --m3c11: #0a0a0a; overflow-y: clip; position: relative; overflow-wrap: break-word; max-width: 100%; min-width: 0px; flex: 1 1 0%;"><div class="pOOWX f5cPye" data-lht="1464" data-rl="en" jsname="dvXlsc" style="letter-spacing: normal;"><div class="Ii22Cf" data-oto="48" data-tr-cl="magi-translate" data-tr-sl="en" data-tr-tl="hi" jsaction="rcuQ6b:npT2md" jscontroller="MN6hqd" jsname="lcCwgb"><div jsname="kj7T5c"><div jsname="PLkxOb"><div><div class="WaaZC"><div class="RJPOee EIJn2" style="animation: auto ease 0s 1 normal none running none !important; color: rgb(10, 10, 10);"><div jsaction="rcuQ6b:npT2md" jscontroller="JegcYe"><div class="ecCNFc" style="border-image: none 100% / 1 / 0 stretch; border-radius: 8px; font-size: 14px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(245, 248, 255, 0.5); margin-bottom: 20px; color: rgb(10, 10, 10); border: 0.8px solid rgb(169, 172, 170);"><div class="QQjpRc" style="display: flex; flex-direction: row; overflow: hidden; border-radius: 0px 0px 8px 8px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(245, 248, 255, 0.5);"><div class="FS7GEb" jsname="zEXxAd" style="display: flex; flex-direction: column; flex-grow: 1; min-width: 38%; width: 518.4px;"></div></div></div></div></div></div><div class="WaaZC"><div class="RJPOee EIJn2" style="animation: auto ease 0s 1 normal none running none !important; color: rgb(10, 10, 10);"><div class="rPeykc" data-hveid="CCIQAQ" data-ved="2ahUKEwj4t7Ddl5yRAxUFRmcHHbfJCWEQo_EKegQIIhAB" style="margin: 10px 0px;"><span data-huuid="9763489124590069963">If the `products` collection contains:</span></div></div></div><div class="WaaZC"><div class="RJPOee EIJn2" style="animation: auto ease 0s 1 normal none running none !important; color: rgb(10, 10, 10);"><div jsaction="rcuQ6b:npT2md" jscontroller="JegcYe"><div class="ecCNFc" style="border-image: none 100% / 1 / 0 stretch; border-radius: 8px; font-size: 14px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(245, 248, 255, 0.5); margin-bottom: 20px; color: rgb(10, 10, 10); border: 0.8px solid rgb(169, 172, 170);"><div class="zYSUYd" style="display: flex; flex-direction: row; overflow: hidden; border-radius: 8px 8px 0px 0px;"><div class="FS7GEb" style="display: flex; flex-direction: column; flex-grow: 1; min-width: 38%; width: 518.4px;"><div class="dDrxod" style="height: 34px; display: flex; justify-content: space-between; align-items: center; background: none 0% 0% / auto repeat scroll padding-box border-box rgb(229, 237, 255); border-bottom: 0.8px solid rgb(169, 172, 170);"><div class="x7ndcb" style="padding-left: 16px; display: flex; align-items: center; color: rgb(10, 10, 10);">Code</div><div aria-live="polite" class="WDoJJe" style="margin-right: 4px; display: flex; align-items: center;"><button aria-label="Copy code to clipboard" class="hqI3tf B4zsNc" data-ved="2ahUKEwj4t7Ddl5yRAxUFRmcHHbfJCWEQ9MILegQIIBAB" role="button" style="margin: 0px 2px; background: none; height: 34px; border: none; color: rgb(5, 40, 97); position: relative; top: 2px; outline: 0px;" tabindex="0" title="Copy"><span class="z1asCe wm4nBd" style="display: inline-block; fill: currentcolor; height: 20px; line-height: 20px; position: relative; width: 20px;"><svg aria-hidden="true" enable-background="new 0 0 24 24" focusable="false" height="24" viewbox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><g><rect fill="none" height="24" width="24"></rect></g><g><path d="M16,20H5V6H3v14c0,1.1,0.9,2,2,2h11V20z M20,16V4c0-1.1-0.9-2-2-2H9C7.9,2,7,2.9,7,4v12c0,1.1,0.9,2,2,2h9 C19.1,18,20,17.1,20,16z M18,16H9V4h9V16z"></path></g></svg></span></button></div></div></div></div><div class="QQjpRc" style="display: flex; flex-direction: row; overflow: hidden; border-radius: 0px 0px 8px 8px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(245, 248, 255, 0.5);"><div class="FS7GEb" jsname="zEXxAd" style="display: flex; flex-direction: column; flex-grow: 1; min-width: 38%; width: 518.4px;"></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div>```
{ "_id": 1, "item": "A", "price": 10 }
{ "_id": 2, "item": "B", "price": 15 }
{ "_id": 3, "item": "A", "price": 20 }
{ "_id": 4, "item": "B", "price": 12 }
```

<div data-hveid="CAkQBg" data-ved="2ahUKEwj4t7Ddl5yRAxUFRmcHHbfJCWEQ7uAMegQICRAG" id="bkmrk-this-query-would-ret-1"><div jsaction="rcuQ6b:npT2md;YbaXcb:oMGkAb;DfLsBc:N6Mv3e;Wyhgxe:daG3j;rkJ0hb:daG3j;j92B8:N6Mv3e" jscontroller="qwbW4b" jsmodel="k8Azyd E23uIf" jsname="Y0vxu"><div class="UxeQfc" style="display: grid; grid-template-columns: minmax(0px, 1fr) 316px; column-gap: 40px;"><div class="LT6XE" style="display: flow-root; color: rgb(10, 10, 10); --m3c9: #0a0a0a; --m3c11: #0a0a0a; overflow-y: clip; position: relative; overflow-wrap: break-word; max-width: 100%; min-width: 0px; flex: 1 1 0%;"><div class="pOOWX f5cPye" data-lht="1464" data-rl="en" jsname="dvXlsc" style="letter-spacing: normal;"><div class="Ii22Cf" data-oto="48" data-tr-cl="magi-translate" data-tr-sl="en" data-tr-tl="hi" jsaction="rcuQ6b:npT2md" jscontroller="MN6hqd" jsname="lcCwgb"><div jsname="kj7T5c"><div jsname="PLkxOb"><div><div class="WaaZC"><div class="RJPOee EIJn2" style="animation: auto ease 0s 1 normal none running none !important; color: rgb(10, 10, 10);"><div jsaction="rcuQ6b:npT2md" jscontroller="JegcYe"><div class="ecCNFc" style="border-image: none 100% / 1 / 0 stretch; border-radius: 8px; font-size: 14px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(245, 248, 255, 0.5); margin-bottom: 20px; color: rgb(10, 10, 10); border: 0.8px solid rgb(169, 172, 170);"><div class="QQjpRc" style="display: flex; flex-direction: row; overflow: hidden; border-radius: 0px 0px 8px 8px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(245, 248, 255, 0.5);"><div class="FS7GEb" jsname="zEXxAd" style="display: flex; flex-direction: column; flex-grow: 1; min-width: 38%; width: 518.4px;"></div></div></div></div></div></div><div class="WaaZC"><div class="RJPOee EIJn2" style="animation: auto ease 0s 1 normal none running none !important; color: rgb(10, 10, 10);"><div class="rPeykc" data-hveid="CCcQAQ" data-ved="2ahUKEwj4t7Ddl5yRAxUFRmcHHbfJCWEQo_EKegQIJxAB" style="margin: 10px 0px;"><span data-huuid="9763489124590068783">This query would return a result similar to:</span></div></div></div><div class="WaaZC"><div class="RJPOee EIJn2" style="animation: auto ease 0s 1 normal none running none !important; color: rgb(10, 10, 10);"><div jsaction="rcuQ6b:npT2md" jscontroller="JegcYe"><div class="ecCNFc" style="border-image: none 100% / 1 / 0 stretch; border-radius: 8px; font-size: 14px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(245, 248, 255, 0.5); margin-bottom: 20px; color: rgb(10, 10, 10); border: 0.8px solid rgb(169, 172, 170);"><div class="zYSUYd" style="display: flex; flex-direction: row; overflow: hidden; border-radius: 8px 8px 0px 0px;"><div class="FS7GEb" style="display: flex; flex-direction: column; flex-grow: 1; min-width: 38%; width: 518.4px;"><div class="dDrxod" style="height: 34px; display: flex; justify-content: space-between; align-items: center; background: none 0% 0% / auto repeat scroll padding-box border-box rgb(229, 237, 255); border-bottom: 0.8px solid rgb(169, 172, 170);"><div class="x7ndcb" style="padding-left: 16px; display: flex; align-items: center; color: rgb(10, 10, 10);">Code</div><div aria-live="polite" class="WDoJJe" style="margin-right: 4px; display: flex; align-items: center;"><button aria-label="Copy code to clipboard" class="hqI3tf B4zsNc" data-ved="2ahUKEwj4t7Ddl5yRAxUFRmcHHbfJCWEQ9MILegQIJRAB" role="button" style="margin: 0px 2px; background: none; height: 34px; border: none; color: rgb(5, 40, 97); position: relative; top: 2px; outline: 0px;" tabindex="0" title="Copy"><span class="z1asCe wm4nBd" style="display: inline-block; fill: currentcolor; height: 20px; line-height: 20px; position: relative; width: 20px;"><svg aria-hidden="true" enable-background="new 0 0 24 24" focusable="false" height="24" viewbox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><g><rect fill="none" height="24" width="24"></rect></g><g><path d="M16,20H5V6H3v14c0,1.1,0.9,2,2,2h11V20z M20,16V4c0-1.1-0.9-2-2-2H9C7.9,2,7,2.9,7,4v12c0,1.1,0.9,2,2,2h9 C19.1,18,20,17.1,20,16z M18,16H9V4h9V16z"></path></g></svg></span></button></div></div></div></div><div class="QQjpRc" style="display: flex; flex-direction: row; overflow: hidden; border-radius: 0px 0px 8px 8px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(245, 248, 255, 0.5);"><div class="FS7GEb" jsname="zEXxAd" style="display: flex; flex-direction: column; flex-grow: 1; min-width: 38%; width: 518.4px;"></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div>```
[
  { "_id": "B", "averagePrice": 13.5 },
  { "_id": "A", "averagePrice": 15 }
]
```

<div data-hveid="CAkQBg" data-ved="2ahUKEwj4t7Ddl5yRAxUFRmcHHbfJCWEQ7uAMegQICRAG" id="bkmrk-"><div jsaction="rcuQ6b:npT2md;YbaXcb:oMGkAb;DfLsBc:N6Mv3e;Wyhgxe:daG3j;rkJ0hb:daG3j;j92B8:N6Mv3e" jscontroller="qwbW4b" jsmodel="k8Azyd E23uIf" jsname="Y0vxu"><div class="UxeQfc" style="display: grid; grid-template-columns: minmax(0px, 1fr) 316px; column-gap: 40px;"><div class="LT6XE" style="display: flow-root; color: rgb(10, 10, 10); --m3c9: #0a0a0a; --m3c11: #0a0a0a; overflow-y: clip; position: relative; overflow-wrap: break-word; max-width: 100%; min-width: 0px; flex: 1 1 0%;"><div class="pOOWX f5cPye" data-lht="1464" data-rl="en" jsname="dvXlsc" style="letter-spacing: normal;"><div class="Ii22Cf" data-oto="48" data-tr-cl="magi-translate" data-tr-sl="en" data-tr-tl="hi" jsaction="rcuQ6b:npT2md" jscontroller="MN6hqd" jsname="lcCwgb"><div jsname="kj7T5c"><div jsname="PLkxOb"><div><div class="WaaZC"><div class="RJPOee EIJn2" style="animation: auto ease 0s 1 normal none running none !important; color: rgb(10, 10, 10);"><div jsaction="rcuQ6b:npT2md" jscontroller="JegcYe"><div class="ecCNFc" style="border-image: none 100% / 1 / 0 stretch; border-radius: 8px; font-size: 14px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(245, 248, 255, 0.5); margin-bottom: 20px; color: rgb(10, 10, 10); border: 0.8px solid rgb(169, 172, 170);"><div class="QQjpRc" style="display: flex; flex-direction: row; overflow: hidden; border-radius: 0px 0px 8px 8px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(245, 248, 255, 0.5);"><div class="FS7GEb" jsname="zEXxAd" style="display: flex; flex-direction: column; flex-grow: 1; min-width: 38%; width: 518.4px;"></div></div></div></div></div></div></div></div></div></div></div></div><div class="kLMmLc" jsname="EVe5O" style="margin-right: unset; transition: opacity 400ms; max-width: 632px;"><div jsaction="rcuQ6b:npT2md" jscontroller="a8oVod" style="height: 1690.8px;"><div class="Clk5Ib" style="display: grid; grid-template-columns: 100%; position: relative; height: 1690.8px;"><div class="IGvtd" style="grid-area: 1 / 1;"><div class="TRXNOc" style="margin-bottom: 20px; pointer-events: initial; top: 104px; position: sticky;"><div class="BOThhc" jsname="iAPbE" style="margin-right: 0px;"><div class="ifiyWc" style="display: block; opacity: 1;"><div id="bkmrk--1"></div></div></div></div></div><div class="JWc89d" style="position: absolute; top: 0px; height: 1690.8px; width: 316px; pointer-events: none;">  
</div></div></div></div></div></div></div>

# MongoDB : sorting documents by multiple fields

<div class="WaaZC" id="bkmrk-to-sort-documents-by" style="color: rgb(10, 10, 10); font-family: 'Google Sans', Arial, sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><div class="RJPOee EIJn2" style="animation: auto ease 0s 1 normal none running none !important; color: rgb(10, 10, 10);"><div class="rPeykc" data-hveid="CAkQAQ" data-ved="2ahUKEwizsujbl5yRAxV3R2wGHeJyFKYQo_EKegQICRAB" style="margin: 0px 0px 10px;"><span data-huuid="15022567425342408382">To sort documents by multiple fields in the MongoDB shell, use the `sort()` method after your `find()` query. </span><span data-huuid="15022567425342409923">The `sort()` method accepts a document where keys are the field names and values are either `1` for ascending order or `-1` for descending order. </span><span data-huuid="15022567425342407368">The order of fields within the `sort()` document determines the sorting priority.</span></div></div></div><div class="WaaZC" id="bkmrk-here%27s-an-example%3A" style="color: rgb(10, 10, 10); font-family: 'Google Sans', Arial, sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><div class="RJPOee EIJn2" style="animation: auto ease 0s 1 normal none running none !important; color: rgb(10, 10, 10);"><div class="rPeykc" data-hveid="CAYQAQ" data-ved="2ahUKEwizsujbl5yRAxV3R2wGHeJyFKYQo_EKegQIBhAB" style="margin: 10px 0px;"><span data-huuid="15022567425342410450">Here's an example:</span></div></div></div><div class="WaaZC" id="bkmrk-assume-a-collection-" style="color: rgb(10, 10, 10); font-family: 'Google Sans', Arial, sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><div class="RJPOee EIJn2" style="animation: auto ease 0s 1 normal none running none !important; color: rgb(10, 10, 10);"><div class="rPeykc" data-hveid="CAMQAQ" data-ved="2ahUKEwizsujbl5yRAxV3R2wGHeJyFKYQo_EKegQIAxAB" style="margin: 10px 0px;"><span data-huuid="15022567425342409436">Assume a collection named `students` with documents like:</span></div></div></div><div class="WaaZC" id="bkmrk-code" style="color: rgb(10, 10, 10); font-family: 'Google Sans', Arial, sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><div class="RJPOee EIJn2" style="animation: auto ease 0s 1 normal none running none !important; color: rgb(10, 10, 10);"><div jsaction="rcuQ6b:npT2md" jscontroller="JegcYe"><div class="ecCNFc" style="border-image: none 100% / 1 / 0 stretch; border-radius: 8px; font-size: 14px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(245, 248, 255, 0.5); margin-bottom: 20px; color: rgb(10, 10, 10); border: 0.8px solid rgb(169, 172, 170);"><div class="zYSUYd" style="display: flex; flex-direction: row; overflow: hidden; border-radius: 8px 8px 0px 0px;"><div class="FS7GEb" style="display: flex; flex-direction: column; flex-grow: 1; min-width: 38%; width: 518.4px;"><div class="dDrxod" style="height: 34px; display: flex; justify-content: space-between; align-items: center; background: none 0% 0% / auto repeat scroll padding-box border-box rgb(229, 237, 255); border-bottom: 0.8px solid rgb(169, 172, 170);"><div class="x7ndcb" style="padding-left: 16px; display: flex; align-items: center; color: rgb(10, 10, 10);">Code</div><div aria-live="polite" class="WDoJJe" style="margin-right: 4px; display: flex; align-items: center;"><button aria-label="Copy code to clipboard" class="hqI3tf B4zsNc" data-ved="2ahUKEwizsujbl5yRAxV3R2wGHeJyFKYQ9MILegQIAhAB" role="button" style="margin: 0px 2px; background: none; height: 34px; border: none; color: rgb(5, 40, 97); position: relative; top: 2px; outline: 0px;" tabindex="0" title="Copy"><span class="z1asCe wm4nBd" style="display: inline-block; fill: currentcolor; height: 20px; line-height: 20px; position: relative; width: 20px;"><svg aria-hidden="true" enable-background="new 0 0 24 24" focusable="false" height="24" viewbox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><g><rect fill="none" height="24" width="24"></rect></g><g><path d="M16,20H5V6H3v14c0,1.1,0.9,2,2,2h11V20z M20,16V4c0-1.1-0.9-2-2-2H9C7.9,2,7,2.9,7,4v12c0,1.1,0.9,2,2,2h9 C19.1,18,20,17.1,20,16z M18,16H9V4h9V16z"></path></g></svg></span></button></div></div></div></div><div class="QQjpRc" style="display: flex; flex-direction: row; overflow: hidden; border-radius: 0px 0px 8px 8px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(245, 248, 255, 0.5);"><div class="FS7GEb" jsname="zEXxAd" style="display: flex; flex-direction: column; flex-grow: 1; min-width: 38%; width: 518.4px;"></div></div></div></div></div></div>```
{ "name": "Alice", "grade": "A", "age": 18 }
{ "name": "Bob", "grade": "B", "age": 19 }
{ "name": "Charlie", "grade": "A", "age": 17 }
{ "name": "David", "grade": "B", "age": 18 }
```

<div class="WaaZC" id="bkmrk-to-sort-these-docume" style="color: rgb(10, 10, 10); font-family: 'Google Sans', Arial, sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><div class="RJPOee EIJn2" style="animation: auto ease 0s 1 normal none running none !important; color: rgb(10, 10, 10);"><div class="rPeykc" data-hveid="CBIQAQ" data-ved="2ahUKEwizsujbl5yRAxV3R2wGHeJyFKYQo_EKegQIEhAB" style="margin: 10px 0px;"><span data-huuid="367968116828974471">To sort these documents first by `grade` in ascending order, and then by `age` in descending order for students with the same grade:</span></div></div></div><div class="WaaZC" id="bkmrk-javascript" style="color: rgb(10, 10, 10); font-family: 'Google Sans', Arial, sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><div class="RJPOee EIJn2" style="animation: auto ease 0s 1 normal none running none !important; color: rgb(10, 10, 10);"><div jsaction="rcuQ6b:npT2md" jscontroller="JegcYe"><div class="ecCNFc" style="border-image: none 100% / 1 / 0 stretch; border-radius: 8px; font-size: 14px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(245, 248, 255, 0.5); margin-bottom: 20px; color: rgb(10, 10, 10); border: 0.8px solid rgb(169, 172, 170);"><div class="zYSUYd" style="display: flex; flex-direction: row; overflow: hidden; border-radius: 8px 8px 0px 0px;"><div class="FS7GEb" style="display: flex; flex-direction: column; flex-grow: 1; min-width: 38%; width: 518.4px;"><div class="dDrxod" style="height: 34px; display: flex; justify-content: space-between; align-items: center; background: none 0% 0% / auto repeat scroll padding-box border-box rgb(229, 237, 255); border-bottom: 0.8px solid rgb(169, 172, 170);"><div class="x7ndcb" style="padding-left: 16px; display: flex; align-items: center; color: rgb(10, 10, 10);">JavaScript</div><div aria-live="polite" class="WDoJJe" style="margin-right: 4px; display: flex; align-items: center;"><button aria-label="Copy code to clipboard" class="hqI3tf B4zsNc" data-ved="2ahUKEwizsujbl5yRAxV3R2wGHeJyFKYQ9MILegQIEBAB" role="button" style="margin: 0px 2px; background: none; height: 34px; border: none; color: rgb(5, 40, 97); position: relative; top: 2px; outline: 0px;" tabindex="0" title="Copy"><span class="z1asCe wm4nBd" style="display: inline-block; fill: currentcolor; height: 20px; line-height: 20px; position: relative; width: 20px;"><svg aria-hidden="true" enable-background="new 0 0 24 24" focusable="false" height="24" viewbox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><g><rect fill="none" height="24" width="24"></rect></g><g><path d="M16,20H5V6H3v14c0,1.1,0.9,2,2,2h11V20z M20,16V4c0-1.1-0.9-2-2-2H9C7.9,2,7,2.9,7,4v12c0,1.1,0.9,2,2,2h9 C19.1,18,20,17.1,20,16z M18,16H9V4h9V16z"></path></g></svg></span></button></div></div></div></div><div class="QQjpRc" style="display: flex; flex-direction: row; overflow: hidden; border-radius: 0px 0px 8px 8px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(245, 248, 255, 0.5);"><div class="FS7GEb" jsname="zEXxAd" style="display: flex; flex-direction: column; flex-grow: 1; min-width: 38%; width: 518.4px;"></div></div></div></div></div></div>```
db.students.find().sort({ grade: 1, age: -1 });
```

<div class="WaaZC" id="bkmrk-explanation%3A" style="color: rgb(10, 10, 10); font-family: 'Google Sans', Arial, sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><div class="RJPOee EIJn2" style="animation: auto ease 0s 1 normal none running none !important; color: rgb(10, 10, 10);"><div aria-level="3" class="rPeykc pyPiTc" data-hveid="CBUQAQ" data-ved="2ahUKEwizsujbl5yRAxV3R2wGHeJyFKYQo_EKegQIFRAB" role="heading" style="margin: 20px 0px 10px; font-size: 20px; font-weight: 600; line-height: 28px;"><span data-huuid="5002008025140162144">Explanation:</span></div></div></div><div class="WaaZC" id="bkmrk-db.students.find%28%29%3A-" style="color: rgb(10, 10, 10); font-family: 'Google Sans', Arial, sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><div class="RJPOee EIJn2" style="animation: auto ease 0s 1 normal none running none !important; color: rgb(10, 10, 10);">- <span data-huuid="5002008025140162301">`db.students.find()`: This retrieves all documents from the `students` collection.</span>
- <span data-huuid="5002008025140159675">`.sort({ grade: 1, age: -1 })`: This applies the sorting criteria.</span>
    - <span data-huuid="5002008025140159832">`grade: 1`: Documents are primarily sorted by the `grade` field in ascending order (e.g., "A" before "B").</span>
    - <span data-huuid="5002008025140161302">`age: -1`: For documents that have the same `grade`, they are then sorted by the `age` field in descending order (e.g., 19 before 18).</span>

</div></div><div class="WaaZC" id="bkmrk-example-output-%28base" style="color: rgb(10, 10, 10); font-family: 'Google Sans', Arial, sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><div class="RJPOee EIJn2" style="animation: auto ease 0s 1 normal none running none !important; color: rgb(10, 10, 10);"><div aria-level="3" class="rPeykc pyPiTc" data-hveid="CCUQAQ" data-ved="2ahUKEwizsujbl5yRAxV3R2wGHeJyFKYQo_EKegQIJRAB" role="heading" style="margin: 20px 0px 10px; font-size: 20px; font-weight: 600; line-height: 28px;"><span data-huuid="14403635772300456933">Example Output (based on the sample data):</span></div></div></div><div class="WaaZC" id="bkmrk-code-1" style="color: rgb(10, 10, 10); font-family: 'Google Sans', Arial, sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><div class="RJPOee EIJn2" style="animation: auto ease 0s 1 normal none running none !important; color: rgb(10, 10, 10);"><div jsaction="rcuQ6b:npT2md" jscontroller="JegcYe"><div class="ecCNFc" style="border-image: none 100% / 1 / 0 stretch; border-radius: 8px; font-size: 14px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(245, 248, 255, 0.5); margin-bottom: 20px; color: rgb(10, 10, 10); border: 0.8px solid rgb(169, 172, 170);"><div class="zYSUYd" style="display: flex; flex-direction: row; overflow: hidden; border-radius: 8px 8px 0px 0px;"><div class="FS7GEb" style="display: flex; flex-direction: column; flex-grow: 1; min-width: 38%; width: 518.4px;"><div class="dDrxod" style="height: 34px; display: flex; justify-content: space-between; align-items: center; background: none 0% 0% / auto repeat scroll padding-box border-box rgb(229, 237, 255); border-bottom: 0.8px solid rgb(169, 172, 170);"><div class="x7ndcb" style="padding-left: 16px; display: flex; align-items: center; color: rgb(10, 10, 10);">Code</div><div aria-live="polite" class="WDoJJe" style="margin-right: 4px; display: flex; align-items: center;"><button aria-label="Copy code to clipboard" class="hqI3tf B4zsNc" data-ved="2ahUKEwizsujbl5yRAxV3R2wGHeJyFKYQ9MILegQIIxAB" role="button" style="margin: 0px 2px; background: none; height: 34px; border: none; color: rgb(5, 40, 97); position: relative; top: 2px; outline: 0px;" tabindex="0" title="Copy"><span class="z1asCe wm4nBd" style="display: inline-block; fill: currentcolor; height: 20px; line-height: 20px; position: relative; width: 20px;"><svg aria-hidden="true" enable-background="new 0 0 24 24" focusable="false" height="24" viewbox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><g><rect fill="none" height="24" width="24"></rect></g><g><path d="M16,20H5V6H3v14c0,1.1,0.9,2,2,2h11V20z M20,16V4c0-1.1-0.9-2-2-2H9C7.9,2,7,2.9,7,4v12c0,1.1,0.9,2,2,2h9 C19.1,18,20,17.1,20,16z M18,16H9V4h9V16z"></path></g></svg></span></button></div></div></div></div><div class="QQjpRc" style="display: flex; flex-direction: row; overflow: hidden; border-radius: 0px 0px 8px 8px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(245, 248, 255, 0.5);"><div class="FS7GEb" jsname="zEXxAd" style="display: flex; flex-direction: column; flex-grow: 1; min-width: 38%; width: 518.4px;"></div></div></div></div></div></div>```
{ "name": "Charlie", "grade": "A", "age": 17 }
{ "name": "Alice", "grade": "A", "age": 18 }
{ "name": "Bob", "grade": "B", "age": 19 }
{ "name": "David", "grade": "B", "age": 18 }
```

# MongoDB: shell commands examples

<div class="WaaZC" id="bkmrk-here-are-examples-of" style="color: rgb(10, 10, 10); font-family: 'Google Sans', Arial, sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><div class="RJPOee EIJn2" style="animation: auto ease 0s 1 normal none running none !important; color: rgb(10, 10, 10);"><div class="rPeykc" data-hveid="CAsQAQ" data-ved="2ahUKEwjamMvhl5yRAxXQd2wGHWI7MdcQo_EKegQICxAB" style="margin: 0px 0px 10px;"><span data-huuid="9838753320233675986">Here are examples of common operations within the MongoDB Shell (mongosh):</span></div></div></div><div class="WaaZC" id="bkmrk-1.-database-manageme" style="color: rgb(10, 10, 10); font-family: 'Google Sans', Arial, sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><div class="RJPOee EIJn2" style="animation: auto ease 0s 1 normal none running none !important; color: rgb(10, 10, 10);"><div aria-level="3" class="rPeykc pyPiTc" data-hveid="CBIQAQ" data-ved="2ahUKEwjamMvhl5yRAxXQd2wGHWI7MdcQo_EKegQIEhAB" role="heading" style="margin: 20px 0px 10px; font-size: 20px; font-weight: 600; line-height: 28px;"><span data-huuid="9838753320233675252">1. Database Management:</span></div></div></div><div class="WaaZC" id="bkmrk-show-databases." style="color: rgb(10, 10, 10); font-family: 'Google Sans', Arial, sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><div class="RJPOee EIJn2" style="animation: auto ease 0s 1 normal none running none !important; color: rgb(10, 10, 10);"><div class="rPeykc" data-hveid="CA0QAQ" data-ved="2ahUKEwjamMvhl5yRAxXQd2wGHWI7MdcQo_EKegQIDRAB" style="margin: 10px 0px;"><span data-huuid="10119260923343865701">show databases.</span></div></div></div><div class="WaaZC" id="bkmrk-javascript" style="color: rgb(10, 10, 10); font-family: 'Google Sans', Arial, sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><div class="RJPOee EIJn2" style="animation: auto ease 0s 1 normal none running none !important; color: rgb(10, 10, 10);"><div jsaction="rcuQ6b:npT2md" jscontroller="JegcYe"><div class="ecCNFc" style="border-image: none 100% / 1 / 0 stretch; border-radius: 8px; font-size: 14px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(245, 248, 255, 0.5); margin-bottom: 20px; color: rgb(10, 10, 10); border: 0.8px solid rgb(169, 172, 170);"><div class="zYSUYd" style="display: flex; flex-direction: row; overflow: hidden; border-radius: 8px 8px 0px 0px;"><div class="FS7GEb" style="display: flex; flex-direction: column; flex-grow: 1; min-width: 38%; width: 518.4px;"><div class="dDrxod" style="height: 34px; display: flex; justify-content: space-between; align-items: center; background: none 0% 0% / auto repeat scroll padding-box border-box rgb(229, 237, 255); border-bottom: 0.8px solid rgb(169, 172, 170);"><div class="x7ndcb" style="padding-left: 16px; display: flex; align-items: center; color: rgb(10, 10, 10);">JavaScript</div><div aria-live="polite" class="WDoJJe" style="margin-right: 4px; display: flex; align-items: center;"><button aria-label="Copy code to clipboard" class="hqI3tf B4zsNc" data-ved="2ahUKEwjamMvhl5yRAxXQd2wGHWI7MdcQ9MILegQIAxAB" role="button" style="margin: 0px 2px; background: none; height: 34px; border: none; color: rgb(5, 40, 97); position: relative; top: 2px; outline: 0px;" tabindex="0" title="Copy"><span class="z1asCe wm4nBd" style="display: inline-block; fill: currentcolor; height: 20px; line-height: 20px; position: relative; width: 20px;"><svg aria-hidden="true" enable-background="new 0 0 24 24" focusable="false" height="24" viewbox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><g><rect fill="none" height="24" width="24"></rect></g><g><path d="M16,20H5V6H3v14c0,1.1,0.9,2,2,2h11V20z M20,16V4c0-1.1-0.9-2-2-2H9C7.9,2,7,2.9,7,4v12c0,1.1,0.9,2,2,2h9 C19.1,18,20,17.1,20,16z M18,16H9V4h9V16z"></path></g></svg></span></button></div></div></div></div><div class="QQjpRc" style="display: flex; flex-direction: row; overflow: hidden; border-radius: 0px 0px 8px 8px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(245, 248, 255, 0.5);"><div class="FS7GEb" jsname="zEXxAd" style="display: flex; flex-direction: column; flex-grow: 1; min-width: 38%; width: 518.4px;"></div></div></div></div></div></div>```
    show dbs
```

<div class="WaaZC" id="bkmrk-switch-to-a-database" style="color: rgb(10, 10, 10); font-family: 'Google Sans', Arial, sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><div class="RJPOee EIJn2" style="animation: auto ease 0s 1 normal none running none !important; color: rgb(10, 10, 10);">- <span data-huuid="9838753320233676412">**Switch to a database (or create if it doesn't exist):**</span>

</div></div><div class="WaaZC" id="bkmrk-javascript-1" style="color: rgb(10, 10, 10); font-family: 'Google Sans', Arial, sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><div class="RJPOee EIJn2" style="animation: auto ease 0s 1 normal none running none !important; color: rgb(10, 10, 10);"><div jsaction="rcuQ6b:npT2md" jscontroller="JegcYe"><div class="ecCNFc" style="border-image: none 100% / 1 / 0 stretch; border-radius: 8px; font-size: 14px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(245, 248, 255, 0.5); margin-bottom: 20px; color: rgb(10, 10, 10); border: 0.8px solid rgb(169, 172, 170);"><div class="zYSUYd" style="display: flex; flex-direction: row; overflow: hidden; border-radius: 8px 8px 0px 0px;"><div class="FS7GEb" style="display: flex; flex-direction: column; flex-grow: 1; min-width: 38%; width: 518.4px;"><div class="dDrxod" style="height: 34px; display: flex; justify-content: space-between; align-items: center; background: none 0% 0% / auto repeat scroll padding-box border-box rgb(229, 237, 255); border-bottom: 0.8px solid rgb(169, 172, 170);"><div class="x7ndcb" style="padding-left: 16px; display: flex; align-items: center; color: rgb(10, 10, 10);">JavaScript</div><div aria-live="polite" class="WDoJJe" style="margin-right: 4px; display: flex; align-items: center;"><button aria-label="Copy code to clipboard" class="hqI3tf B4zsNc" data-ved="2ahUKEwjamMvhl5yRAxXQd2wGHWI7MdcQ9MILegQIBBAB" role="button" style="margin: 0px 2px; background: none; height: 34px; border: none; color: rgb(5, 40, 97); position: relative; top: 2px; outline: 0px;" tabindex="0" title="Copy"><span class="z1asCe wm4nBd" style="display: inline-block; fill: currentcolor; height: 20px; line-height: 20px; position: relative; width: 20px;"><svg aria-hidden="true" enable-background="new 0 0 24 24" focusable="false" height="24" viewbox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><g><rect fill="none" height="24" width="24"></rect></g><g><path d="M16,20H5V6H3v14c0,1.1,0.9,2,2,2h11V20z M20,16V4c0-1.1-0.9-2-2-2H9C7.9,2,7,2.9,7,4v12c0,1.1,0.9,2,2,2h9 C19.1,18,20,17.1,20,16z M18,16H9V4h9V16z"></path></g></svg></span></button></div></div></div></div><div class="QQjpRc" style="display: flex; flex-direction: row; overflow: hidden; border-radius: 0px 0px 8px 8px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(245, 248, 255, 0.5);"><div class="FS7GEb" jsname="zEXxAd" style="display: flex; flex-direction: column; flex-grow: 1; min-width: 38%; width: 518.4px;"></div></div></div></div></div></div>```
    use myDatabase
```

<div class="WaaZC" id="bkmrk-show-current-databas" style="color: rgb(10, 10, 10); font-family: 'Google Sans', Arial, sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><div class="RJPOee EIJn2" style="animation: auto ease 0s 1 normal none running none !important; color: rgb(10, 10, 10);"><div class="rPeykc" data-hveid="CAcQAQ" data-ved="2ahUKEwjamMvhl5yRAxXQd2wGHWI7MdcQo_EKegQIBxAB" style="margin: 10px 0px;"><span data-huuid="10119260923343867391">Show current database.</span></div></div></div><div class="WaaZC" id="bkmrk-javascript-2" style="color: rgb(10, 10, 10); font-family: 'Google Sans', Arial, sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><div class="RJPOee EIJn2" style="animation: auto ease 0s 1 normal none running none !important; color: rgb(10, 10, 10);"><div jsaction="rcuQ6b:npT2md" jscontroller="JegcYe"><div class="ecCNFc" style="border-image: none 100% / 1 / 0 stretch; border-radius: 8px; font-size: 14px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(245, 248, 255, 0.5); margin-bottom: 20px; color: rgb(10, 10, 10); border: 0.8px solid rgb(169, 172, 170);"><div class="zYSUYd" style="display: flex; flex-direction: row; overflow: hidden; border-radius: 8px 8px 0px 0px;"><div class="FS7GEb" style="display: flex; flex-direction: column; flex-grow: 1; min-width: 38%; width: 518.4px;"><div class="dDrxod" style="height: 34px; display: flex; justify-content: space-between; align-items: center; background: none 0% 0% / auto repeat scroll padding-box border-box rgb(229, 237, 255); border-bottom: 0.8px solid rgb(169, 172, 170);"><div class="x7ndcb" style="padding-left: 16px; display: flex; align-items: center; color: rgb(10, 10, 10);">JavaScript</div><div aria-live="polite" class="WDoJJe" style="margin-right: 4px; display: flex; align-items: center;"><button aria-label="Copy code to clipboard" class="hqI3tf B4zsNc" data-ved="2ahUKEwjamMvhl5yRAxXQd2wGHWI7MdcQ9MILegQIBRAB" role="button" style="margin: 0px 2px; background: none; height: 34px; border: none; color: rgb(5, 40, 97); position: relative; top: 2px; outline: 0px;" tabindex="0" title="Copy"><span class="z1asCe wm4nBd" style="display: inline-block; fill: currentcolor; height: 20px; line-height: 20px; position: relative; width: 20px;"><svg aria-hidden="true" enable-background="new 0 0 24 24" focusable="false" height="24" viewbox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><g><rect fill="none" height="24" width="24"></rect></g><g><path d="M16,20H5V6H3v14c0,1.1,0.9,2,2,2h11V20z M20,16V4c0-1.1-0.9-2-2-2H9C7.9,2,7,2.9,7,4v12c0,1.1,0.9,2,2,2h9 C19.1,18,20,17.1,20,16z M18,16H9V4h9V16z"></path></g></svg></span></button></div></div></div></div><div class="QQjpRc" style="display: flex; flex-direction: row; overflow: hidden; border-radius: 0px 0px 8px 8px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(245, 248, 255, 0.5);"><div class="FS7GEb" jsname="zEXxAd" style="display: flex; flex-direction: column; flex-grow: 1; min-width: 38%; width: 518.4px;"></div></div></div></div></div></div>```
    db
```

<div class="WaaZC" id="bkmrk-2.-collection-manage" style="color: rgb(10, 10, 10); font-family: 'Google Sans', Arial, sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><div class="RJPOee EIJn2" style="animation: auto ease 0s 1 normal none running none !important; color: rgb(10, 10, 10);"><div aria-level="3" class="rPeykc pyPiTc" data-hveid="CBMQAQ" data-ved="2ahUKEwjamMvhl5yRAxXQd2wGHWI7MdcQo_EKegQIExAB" role="heading" style="margin: 20px 0px 10px; font-size: 20px; font-weight: 600; line-height: 28px;"><span data-huuid="9838753320233675157">2. Collection Management:</span></div></div></div><div class="WaaZC" id="bkmrk-show-collections-in-" style="color: rgb(10, 10, 10); font-family: 'Google Sans', Arial, sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><div class="RJPOee EIJn2" style="animation: auto ease 0s 1 normal none running none !important; color: rgb(10, 10, 10);"><div class="rPeykc" data-hveid="CAwQAQ" data-ved="2ahUKEwjamMvhl5yRAxXQd2wGHWI7MdcQo_EKegQIDBAB" style="margin: 10px 0px;"><span data-huuid="10119260923343864985">Show collections in the current database.</span></div></div></div><div class="WaaZC" id="bkmrk-javascript-3" style="color: rgb(10, 10, 10); font-family: 'Google Sans', Arial, sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><div class="RJPOee EIJn2" style="animation: auto ease 0s 1 normal none running none !important; color: rgb(10, 10, 10);"><div jsaction="rcuQ6b:npT2md" jscontroller="JegcYe"><div class="ecCNFc" style="border-image: none 100% / 1 / 0 stretch; border-radius: 8px; font-size: 14px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(245, 248, 255, 0.5); margin-bottom: 20px; color: rgb(10, 10, 10); border: 0.8px solid rgb(169, 172, 170);"><div class="zYSUYd" style="display: flex; flex-direction: row; overflow: hidden; border-radius: 8px 8px 0px 0px;"><div class="FS7GEb" style="display: flex; flex-direction: column; flex-grow: 1; min-width: 38%; width: 518.4px;"><div class="dDrxod" style="height: 34px; display: flex; justify-content: space-between; align-items: center; background: none 0% 0% / auto repeat scroll padding-box border-box rgb(229, 237, 255); border-bottom: 0.8px solid rgb(169, 172, 170);"><div class="x7ndcb" style="padding-left: 16px; display: flex; align-items: center; color: rgb(10, 10, 10);">JavaScript</div><div aria-live="polite" class="WDoJJe" style="margin-right: 4px; display: flex; align-items: center;"><button aria-label="Copy code to clipboard" class="hqI3tf B4zsNc" data-ved="2ahUKEwjamMvhl5yRAxXQd2wGHWI7MdcQ9MILegQIAhAB" role="button" style="margin: 0px 2px; background: none; height: 34px; border: none; color: rgb(5, 40, 97); position: relative; top: 2px; outline: 0px;" tabindex="0" title="Copy"><span class="z1asCe wm4nBd" style="display: inline-block; fill: currentcolor; height: 20px; line-height: 20px; position: relative; width: 20px;"><svg aria-hidden="true" enable-background="new 0 0 24 24" focusable="false" height="24" viewbox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><g><rect fill="none" height="24" width="24"></rect></g><g><path d="M16,20H5V6H3v14c0,1.1,0.9,2,2,2h11V20z M20,16V4c0-1.1-0.9-2-2-2H9C7.9,2,7,2.9,7,4v12c0,1.1,0.9,2,2,2h9 C19.1,18,20,17.1,20,16z M18,16H9V4h9V16z"></path></g></svg></span></button></div></div></div></div><div class="QQjpRc" style="display: flex; flex-direction: row; overflow: hidden; border-radius: 0px 0px 8px 8px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(245, 248, 255, 0.5);"><div class="FS7GEb" jsname="zEXxAd" style="display: flex; flex-direction: column; flex-grow: 1; min-width: 38%; width: 518.4px;"></div></div></div></div></div></div>```
    show collections
```

<div class="WaaZC" id="bkmrk-create-a-new-collect" style="color: rgb(10, 10, 10); font-family: 'Google Sans', Arial, sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><div class="RJPOee EIJn2" style="animation: auto ease 0s 1 normal none running none !important; color: rgb(10, 10, 10);"><div class="rPeykc" data-hveid="CCIQAQ" data-ved="2ahUKEwjamMvhl5yRAxXQd2wGHWI7MdcQo_EKegQIIhAB" style="margin: 10px 0px;"><span data-huuid="10119260923343864040">Create a new collection.</span></div></div></div><div class="WaaZC" id="bkmrk-javascript-4" style="color: rgb(10, 10, 10); font-family: 'Google Sans', Arial, sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><div class="RJPOee EIJn2" style="animation: auto ease 0s 1 normal none running none !important; color: rgb(10, 10, 10);"><div jsaction="rcuQ6b:npT2md" jscontroller="JegcYe"><div class="ecCNFc" style="border-image: none 100% / 1 / 0 stretch; border-radius: 8px; font-size: 14px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(245, 248, 255, 0.5); margin-bottom: 20px; color: rgb(10, 10, 10); border: 0.8px solid rgb(169, 172, 170);"><div class="zYSUYd" style="display: flex; flex-direction: row; overflow: hidden; border-radius: 8px 8px 0px 0px;"><div class="FS7GEb" style="display: flex; flex-direction: column; flex-grow: 1; min-width: 38%; width: 518.4px;"><div class="dDrxod" style="height: 34px; display: flex; justify-content: space-between; align-items: center; background: none 0% 0% / auto repeat scroll padding-box border-box rgb(229, 237, 255); border-bottom: 0.8px solid rgb(169, 172, 170);"><div class="x7ndcb" style="padding-left: 16px; display: flex; align-items: center; color: rgb(10, 10, 10);">JavaScript</div><div aria-live="polite" class="WDoJJe" style="margin-right: 4px; display: flex; align-items: center;"><button aria-label="Copy code to clipboard" class="hqI3tf B4zsNc" data-ved="2ahUKEwjamMvhl5yRAxXQd2wGHWI7MdcQ9MILegQIJBAB" role="button" style="margin: 0px 2px; background: none; height: 34px; border: none; color: rgb(5, 40, 97); position: relative; top: 2px; outline: 0px;" tabindex="0" title="Copy"><span class="z1asCe wm4nBd" style="display: inline-block; fill: currentcolor; height: 20px; line-height: 20px; position: relative; width: 20px;"><svg aria-hidden="true" enable-background="new 0 0 24 24" focusable="false" height="24" viewbox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><g><rect fill="none" height="24" width="24"></rect></g><g><path d="M16,20H5V6H3v14c0,1.1,0.9,2,2,2h11V20z M20,16V4c0-1.1-0.9-2-2-2H9C7.9,2,7,2.9,7,4v12c0,1.1,0.9,2,2,2h9 C19.1,18,20,17.1,20,16z M18,16H9V4h9V16z"></path></g></svg></span></button></div></div></div></div><div class="QQjpRc" style="display: flex; flex-direction: row; overflow: hidden; border-radius: 0px 0px 8px 8px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(245, 248, 255, 0.5);"><div class="FS7GEb" jsname="zEXxAd" style="display: flex; flex-direction: column; flex-grow: 1; min-width: 38%; width: 518.4px;"></div></div></div></div></div></div>```
    db.createCollection("myCollection")
```

<div class="WaaZC" id="bkmrk-3.-data-manipulation" style="color: rgb(10, 10, 10); font-family: 'Google Sans', Arial, sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><div class="RJPOee EIJn2" style="animation: auto ease 0s 1 normal none running none !important; color: rgb(10, 10, 10);"><div aria-level="3" class="rPeykc pyPiTc" data-hveid="CCkQAQ" data-ved="2ahUKEwjamMvhl5yRAxXQd2wGHWI7MdcQo_EKegQIKRAB" role="heading" style="margin: 20px 0px 10px; font-size: 20px; font-weight: 600; line-height: 28px;"><span data-huuid="18333693548007933693">3. Data Manipulation (CRUD Operations):</span></div></div></div><div class="WaaZC" id="bkmrk-insert-a-single-docu" style="color: rgb(10, 10, 10); font-family: 'Google Sans', Arial, sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><div class="RJPOee EIJn2" style="animation: auto ease 0s 1 normal none running none !important; color: rgb(10, 10, 10);"><div class="rPeykc" data-hveid="CCcQAQ" data-ved="2ahUKEwjamMvhl5yRAxXQd2wGHWI7MdcQo_EKegQIJxAB" style="margin: 10px 0px;"><span data-huuid="10119260923343865014">Insert a single document.</span></div></div></div><div class="WaaZC" id="bkmrk-javascript-5" style="color: rgb(10, 10, 10); font-family: 'Google Sans', Arial, sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><div class="RJPOee EIJn2" style="animation: auto ease 0s 1 normal none running none !important; color: rgb(10, 10, 10);"><div jsaction="rcuQ6b:npT2md" jscontroller="JegcYe"><div class="ecCNFc" style="border-image: none 100% / 1 / 0 stretch; border-radius: 8px; font-size: 14px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(245, 248, 255, 0.5); margin-bottom: 20px; color: rgb(10, 10, 10); border: 0.8px solid rgb(169, 172, 170);"><div class="zYSUYd" style="display: flex; flex-direction: row; overflow: hidden; border-radius: 8px 8px 0px 0px;"><div class="FS7GEb" style="display: flex; flex-direction: column; flex-grow: 1; min-width: 38%; width: 518.4px;"><div class="dDrxod" style="height: 34px; display: flex; justify-content: space-between; align-items: center; background: none 0% 0% / auto repeat scroll padding-box border-box rgb(229, 237, 255); border-bottom: 0.8px solid rgb(169, 172, 170);"><div class="x7ndcb" style="padding-left: 16px; display: flex; align-items: center; color: rgb(10, 10, 10);">JavaScript</div><div aria-live="polite" class="WDoJJe" style="margin-right: 4px; display: flex; align-items: center;"><button aria-label="Copy code to clipboard" class="hqI3tf B4zsNc" data-ved="2ahUKEwjamMvhl5yRAxXQd2wGHWI7MdcQ9MILegQILBAB" role="button" style="margin: 0px 2px; background: none; height: 34px; border: none; color: rgb(5, 40, 97); position: relative; top: 2px; outline: 0px;" tabindex="0" title="Copy"><span class="z1asCe wm4nBd" style="display: inline-block; fill: currentcolor; height: 20px; line-height: 20px; position: relative; width: 20px;"><svg aria-hidden="true" enable-background="new 0 0 24 24" focusable="false" height="24" viewbox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><g><rect fill="none" height="24" width="24"></rect></g><g><path d="M16,20H5V6H3v14c0,1.1,0.9,2,2,2h11V20z M20,16V4c0-1.1-0.9-2-2-2H9C7.9,2,7,2.9,7,4v12c0,1.1,0.9,2,2,2h9 C19.1,18,20,17.1,20,16z M18,16H9V4h9V16z"></path></g></svg></span></button></div></div></div></div><div class="QQjpRc" style="display: flex; flex-direction: row; overflow: hidden; border-radius: 0px 0px 8px 8px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(245, 248, 255, 0.5);"><div class="FS7GEb" jsname="zEXxAd" style="display: flex; flex-direction: column; flex-grow: 1; min-width: 38%; width: 518.4px;"></div></div></div></div></div></div>```
    db.myCollection.insertOne({ name: "Alice", age: 30, city: "New York" })
```

<div class="WaaZC" id="bkmrk-insert-multiple-docu" style="color: rgb(10, 10, 10); font-family: 'Google Sans', Arial, sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><div class="RJPOee EIJn2" style="animation: auto ease 0s 1 normal none running none !important; color: rgb(10, 10, 10);"><div class="rPeykc" data-hveid="CC8QAQ" data-ved="2ahUKEwjamMvhl5yRAxXQd2wGHWI7MdcQo_EKegQILxAB" style="margin: 10px 0px;"><span data-huuid="10119260923343865988">Insert multiple documents.</span></div></div></div><div class="WaaZC" id="bkmrk-javascript-6" style="color: rgb(10, 10, 10); font-family: 'Google Sans', Arial, sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><div class="RJPOee EIJn2" style="animation: auto ease 0s 1 normal none running none !important; color: rgb(10, 10, 10);"><div jsaction="rcuQ6b:npT2md" jscontroller="JegcYe"><div class="ecCNFc" style="border-image: none 100% / 1 / 0 stretch; border-radius: 8px; font-size: 14px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(245, 248, 255, 0.5); margin-bottom: 20px; color: rgb(10, 10, 10); border: 0.8px solid rgb(169, 172, 170);"><div class="zYSUYd" style="display: flex; flex-direction: row; overflow: hidden; border-radius: 8px 8px 0px 0px;"><div class="FS7GEb" style="display: flex; flex-direction: column; flex-grow: 1; min-width: 38%; width: 518.4px;"><div class="dDrxod" style="height: 34px; display: flex; justify-content: space-between; align-items: center; background: none 0% 0% / auto repeat scroll padding-box border-box rgb(229, 237, 255); border-bottom: 0.8px solid rgb(169, 172, 170);"><div class="x7ndcb" style="padding-left: 16px; display: flex; align-items: center; color: rgb(10, 10, 10);">JavaScript</div><div aria-live="polite" class="WDoJJe" style="margin-right: 4px; display: flex; align-items: center;"><button aria-label="Copy code to clipboard" class="hqI3tf B4zsNc" data-ved="2ahUKEwjamMvhl5yRAxXQd2wGHWI7MdcQ9MILegQIMRAB" role="button" style="margin: 0px 2px; background: none; height: 34px; border: none; color: rgb(5, 40, 97); position: relative; top: 2px; outline: 0px;" tabindex="0" title="Copy"><span class="z1asCe wm4nBd" style="display: inline-block; fill: currentcolor; height: 20px; line-height: 20px; position: relative; width: 20px;"><svg aria-hidden="true" enable-background="new 0 0 24 24" focusable="false" height="24" viewbox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><g><rect fill="none" height="24" width="24"></rect></g><g><path d="M16,20H5V6H3v14c0,1.1,0.9,2,2,2h11V20z M20,16V4c0-1.1-0.9-2-2-2H9C7.9,2,7,2.9,7,4v12c0,1.1,0.9,2,2,2h9 C19.1,18,20,17.1,20,16z M18,16H9V4h9V16z"></path></g></svg></span></button></div></div></div></div><div class="QQjpRc" style="display: flex; flex-direction: row; overflow: hidden; border-radius: 0px 0px 8px 8px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(245, 248, 255, 0.5);"><div class="FS7GEb" jsname="zEXxAd" style="display: flex; flex-direction: column; flex-grow: 1; min-width: 38%; width: 518.4px;"></div></div></div></div></div></div>```
    db.myCollection.insertMany([
        { name: "Bob", age: 25, city: "London" },
        { name: "Charlie", age: 35, city: "Paris" }
    ])
```

<div class="WaaZC" id="bkmrk-find-all-documents-i" style="color: rgb(10, 10, 10); font-family: 'Google Sans', Arial, sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><div class="RJPOee EIJn2" style="animation: auto ease 0s 1 normal none running none !important; color: rgb(10, 10, 10);"><div class="rPeykc" data-hveid="CDQQAQ" data-ved="2ahUKEwjamMvhl5yRAxXQd2wGHWI7MdcQo_EKegQINBAB" style="margin: 10px 0px;"><span data-huuid="10119260923343866962">Find all documents in a collection.</span></div></div></div><div class="WaaZC" id="bkmrk-javascript-7" style="color: rgb(10, 10, 10); font-family: 'Google Sans', Arial, sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><div class="RJPOee EIJn2" style="animation: auto ease 0s 1 normal none running none !important; color: rgb(10, 10, 10);"><div jsaction="rcuQ6b:npT2md" jscontroller="JegcYe"><div class="ecCNFc" style="border-image: none 100% / 1 / 0 stretch; border-radius: 8px; font-size: 14px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(245, 248, 255, 0.5); margin-bottom: 20px; color: rgb(10, 10, 10); border: 0.8px solid rgb(169, 172, 170);"><div class="zYSUYd" style="display: flex; flex-direction: row; overflow: hidden; border-radius: 8px 8px 0px 0px;"><div class="FS7GEb" style="display: flex; flex-direction: column; flex-grow: 1; min-width: 38%; width: 518.4px;"><div class="dDrxod" style="height: 34px; display: flex; justify-content: space-between; align-items: center; background: none 0% 0% / auto repeat scroll padding-box border-box rgb(229, 237, 255); border-bottom: 0.8px solid rgb(169, 172, 170);"><div class="x7ndcb" style="padding-left: 16px; display: flex; align-items: center; color: rgb(10, 10, 10);">JavaScript</div><div aria-live="polite" class="WDoJJe" style="margin-right: 4px; display: flex; align-items: center;"><button aria-label="Copy code to clipboard" class="hqI3tf B4zsNc" data-ved="2ahUKEwjamMvhl5yRAxXQd2wGHWI7MdcQ9MILegQINhAB" role="button" style="margin: 0px 2px; background: none; height: 34px; border: none; color: rgb(5, 40, 97); position: relative; top: 2px; outline: 0px;" tabindex="0" title="Copy"><span class="z1asCe wm4nBd" style="display: inline-block; fill: currentcolor; height: 20px; line-height: 20px; position: relative; width: 20px;"><svg aria-hidden="true" enable-background="new 0 0 24 24" focusable="false" height="24" viewbox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><g><rect fill="none" height="24" width="24"></rect></g><g><path d="M16,20H5V6H3v14c0,1.1,0.9,2,2,2h11V20z M20,16V4c0-1.1-0.9-2-2-2H9C7.9,2,7,2.9,7,4v12c0,1.1,0.9,2,2,2h9 C19.1,18,20,17.1,20,16z M18,16H9V4h9V16z"></path></g></svg></span></button></div></div></div></div><div class="QQjpRc" style="display: flex; flex-direction: row; overflow: hidden; border-radius: 0px 0px 8px 8px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(245, 248, 255, 0.5);"><div class="FS7GEb" jsname="zEXxAd" style="display: flex; flex-direction: column; flex-grow: 1; min-width: 38%; width: 518.4px;"></div></div></div></div></div></div>```
    db.myCollection.find()
```

<div class="WaaZC" id="bkmrk-find-documents-with-" style="color: rgb(10, 10, 10); font-family: 'Google Sans', Arial, sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><div class="RJPOee EIJn2" style="animation: auto ease 0s 1 normal none running none !important; color: rgb(10, 10, 10);"><div class="rPeykc" data-hveid="CDkQAQ" data-ved="2ahUKEwjamMvhl5yRAxXQd2wGHWI7MdcQo_EKegQIORAB" style="margin: 10px 0px;"><span data-huuid="10119260923343863840">Find documents with specific criteria.</span></div></div></div><div class="WaaZC" id="bkmrk-javascript-8" style="color: rgb(10, 10, 10); font-family: 'Google Sans', Arial, sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><div class="RJPOee EIJn2" style="animation: auto ease 0s 1 normal none running none !important; color: rgb(10, 10, 10);"><div jsaction="rcuQ6b:npT2md" jscontroller="JegcYe"><div class="ecCNFc" style="border-image: none 100% / 1 / 0 stretch; border-radius: 8px; font-size: 14px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(245, 248, 255, 0.5); margin-bottom: 20px; color: rgb(10, 10, 10); border: 0.8px solid rgb(169, 172, 170);"><div class="zYSUYd" style="display: flex; flex-direction: row; overflow: hidden; border-radius: 8px 8px 0px 0px;"><div class="FS7GEb" style="display: flex; flex-direction: column; flex-grow: 1; min-width: 38%; width: 518.4px;"><div class="dDrxod" style="height: 34px; display: flex; justify-content: space-between; align-items: center; background: none 0% 0% / auto repeat scroll padding-box border-box rgb(229, 237, 255); border-bottom: 0.8px solid rgb(169, 172, 170);"><div class="x7ndcb" style="padding-left: 16px; display: flex; align-items: center; color: rgb(10, 10, 10);">JavaScript</div><div aria-live="polite" class="WDoJJe" style="margin-right: 4px; display: flex; align-items: center;"><button aria-label="Copy code to clipboard" class="hqI3tf B4zsNc" data-ved="2ahUKEwjamMvhl5yRAxXQd2wGHWI7MdcQ9MILegQIOxAB" role="button" style="margin: 0px 2px; background: none; height: 34px; border: none; color: rgb(5, 40, 97); position: relative; top: 2px; outline: 0px;" tabindex="0" title="Copy"><span class="z1asCe wm4nBd" style="display: inline-block; fill: currentcolor; height: 20px; line-height: 20px; position: relative; width: 20px;"><svg aria-hidden="true" enable-background="new 0 0 24 24" focusable="false" height="24" viewbox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><g><rect fill="none" height="24" width="24"></rect></g><g><path d="M16,20H5V6H3v14c0,1.1,0.9,2,2,2h11V20z M20,16V4c0-1.1-0.9-2-2-2H9C7.9,2,7,2.9,7,4v12c0,1.1,0.9,2,2,2h9 C19.1,18,20,17.1,20,16z M18,16H9V4h9V16z"></path></g></svg></span></button></div></div></div></div><div class="QQjpRc" style="display: flex; flex-direction: row; overflow: hidden; border-radius: 0px 0px 8px 8px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(245, 248, 255, 0.5);"><div class="FS7GEb" jsname="zEXxAd" style="display: flex; flex-direction: column; flex-grow: 1; min-width: 38%; width: 518.4px;"></div></div></div></div></div></div>```
    db.myCollection.find({ age: { $gt: 28 } }) // Find documents where age is greater than 28
```

<div class="WaaZC" id="bkmrk-find-documents-and-p" style="color: rgb(10, 10, 10); font-family: 'Google Sans', Arial, sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><div class="RJPOee EIJn2" style="animation: auto ease 0s 1 normal none running none !important; color: rgb(10, 10, 10);"><div class="rPeykc" data-hveid="CD0QAQ" data-ved="2ahUKEwjamMvhl5yRAxXQd2wGHWI7MdcQo_EKegQIPRAB" style="margin: 10px 0px;"><span data-huuid="10119260923343864814">Find documents and project specific fields.</span></div></div></div><div class="WaaZC" id="bkmrk-javascript-9" style="color: rgb(10, 10, 10); font-family: 'Google Sans', Arial, sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><div class="RJPOee EIJn2" style="animation: auto ease 0s 1 normal none running none !important; color: rgb(10, 10, 10);"><div jsaction="rcuQ6b:npT2md" jscontroller="JegcYe"><div class="ecCNFc" style="border-image: none 100% / 1 / 0 stretch; border-radius: 8px; font-size: 14px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(245, 248, 255, 0.5); margin-bottom: 20px; color: rgb(10, 10, 10); border: 0.8px solid rgb(169, 172, 170);"><div class="zYSUYd" style="display: flex; flex-direction: row; overflow: hidden; border-radius: 8px 8px 0px 0px;"><div class="FS7GEb" style="display: flex; flex-direction: column; flex-grow: 1; min-width: 38%; width: 518.4px;"><div class="dDrxod" style="height: 34px; display: flex; justify-content: space-between; align-items: center; background: none 0% 0% / auto repeat scroll padding-box border-box rgb(229, 237, 255); border-bottom: 0.8px solid rgb(169, 172, 170);"><div class="x7ndcb" style="padding-left: 16px; display: flex; align-items: center; color: rgb(10, 10, 10);">JavaScript</div><div aria-live="polite" class="WDoJJe" style="margin-right: 4px; display: flex; align-items: center;"><button aria-label="Copy code to clipboard" class="hqI3tf B4zsNc" data-ved="2ahUKEwjamMvhl5yRAxXQd2wGHWI7MdcQ9MILegQIQBAB" role="button" style="margin: 0px 2px; background: none; height: 34px; border: none; color: rgb(5, 40, 97); position: relative; top: 2px; outline: 0px;" tabindex="0" title="Copy"><span class="z1asCe wm4nBd" style="display: inline-block; fill: currentcolor; height: 20px; line-height: 20px; position: relative; width: 20px;"><svg aria-hidden="true" enable-background="new 0 0 24 24" focusable="false" height="24" viewbox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><g><rect fill="none" height="24" width="24"></rect></g><g><path d="M16,20H5V6H3v14c0,1.1,0.9,2,2,2h11V20z M20,16V4c0-1.1-0.9-2-2-2H9C7.9,2,7,2.9,7,4v12c0,1.1,0.9,2,2,2h9 C19.1,18,20,17.1,20,16z M18,16H9V4h9V16z"></path></g></svg></span></button></div></div></div></div><div class="QQjpRc" style="display: flex; flex-direction: row; overflow: hidden; border-radius: 0px 0px 8px 8px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(245, 248, 255, 0.5);"><div class="FS7GEb" jsname="zEXxAd" style="display: flex; flex-direction: column; flex-grow: 1; min-width: 38%; width: 518.4px;"></div></div></div></div></div></div>```
    db.myCollection.find({}, { name: 1, city: 1, _id: 0 }) // Include name and city, exclude _id
```

<div class="WaaZC" id="bkmrk-update-a-single-docu" style="color: rgb(10, 10, 10); font-family: 'Google Sans', Arial, sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><div class="RJPOee EIJn2" style="animation: auto ease 0s 1 normal none running none !important; color: rgb(10, 10, 10);"><div class="rPeykc" data-hveid="CEMQAQ" data-ved="2ahUKEwjamMvhl5yRAxXQd2wGHWI7MdcQo_EKegQIQxAB" style="margin: 10px 0px;"><span data-huuid="10119260923343865788">Update a single document.</span></div></div></div><div class="WaaZC" id="bkmrk-javascript-10" style="color: rgb(10, 10, 10); font-family: 'Google Sans', Arial, sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><div class="RJPOee EIJn2" style="animation: auto ease 0s 1 normal none running none !important; color: rgb(10, 10, 10);"><div jsaction="rcuQ6b:npT2md" jscontroller="JegcYe"><div class="ecCNFc" style="border-image: none 100% / 1 / 0 stretch; border-radius: 8px; font-size: 14px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(245, 248, 255, 0.5); margin-bottom: 20px; color: rgb(10, 10, 10); border: 0.8px solid rgb(169, 172, 170);"><div class="zYSUYd" style="display: flex; flex-direction: row; overflow: hidden; border-radius: 8px 8px 0px 0px;"><div class="FS7GEb" style="display: flex; flex-direction: column; flex-grow: 1; min-width: 38%; width: 518.4px;"><div class="dDrxod" style="height: 34px; display: flex; justify-content: space-between; align-items: center; background: none 0% 0% / auto repeat scroll padding-box border-box rgb(229, 237, 255); border-bottom: 0.8px solid rgb(169, 172, 170);"><div class="x7ndcb" style="padding-left: 16px; display: flex; align-items: center; color: rgb(10, 10, 10);">JavaScript</div><div aria-live="polite" class="WDoJJe" style="margin-right: 4px; display: flex; align-items: center;"><button aria-label="Copy code to clipboard" class="hqI3tf B4zsNc" data-ved="2ahUKEwjamMvhl5yRAxXQd2wGHWI7MdcQ9MILegQIRRAB" role="button" style="margin: 0px 2px; background: none; height: 34px; border: none; color: rgb(5, 40, 97); position: relative; top: 2px; outline: 0px;" tabindex="0" title="Copy"><span class="z1asCe wm4nBd" style="display: inline-block; fill: currentcolor; height: 20px; line-height: 20px; position: relative; width: 20px;"><svg aria-hidden="true" enable-background="new 0 0 24 24" focusable="false" height="24" viewbox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><g><rect fill="none" height="24" width="24"></rect></g><g><path d="M16,20H5V6H3v14c0,1.1,0.9,2,2,2h11V20z M20,16V4c0-1.1-0.9-2-2-2H9C7.9,2,7,2.9,7,4v12c0,1.1,0.9,2,2,2h9 C19.1,18,20,17.1,20,16z M18,16H9V4h9V16z"></path></g></svg></span></button></div></div></div></div><div class="QQjpRc" style="display: flex; flex-direction: row; overflow: hidden; border-radius: 0px 0px 8px 8px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(245, 248, 255, 0.5);"><div class="FS7GEb" jsname="zEXxAd" style="display: flex; flex-direction: column; flex-grow: 1; min-width: 38%; width: 518.4px;"></div></div></div></div></div></div>```
    db.myCollection.updateOne({ name: "Alice" }, { $set: { age: 31 } })
```

<div class="WaaZC" id="bkmrk-update-multiple-docu" style="color: rgb(10, 10, 10); font-family: 'Google Sans', Arial, sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><div class="RJPOee EIJn2" style="animation: auto ease 0s 1 normal none running none !important; color: rgb(10, 10, 10);"><div class="rPeykc" data-hveid="CEgQAQ" data-ved="2ahUKEwjamMvhl5yRAxXQd2wGHWI7MdcQo_EKegQISBAB" style="margin: 10px 0px;"><span data-huuid="10119260923343866762">Update multiple documents.</span></div></div></div><div class="WaaZC" id="bkmrk-javascript-11" style="color: rgb(10, 10, 10); font-family: 'Google Sans', Arial, sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><div class="RJPOee EIJn2" style="animation: auto ease 0s 1 normal none running none !important; color: rgb(10, 10, 10);"><div jsaction="rcuQ6b:npT2md" jscontroller="JegcYe"><div class="ecCNFc" style="border-image: none 100% / 1 / 0 stretch; border-radius: 8px; font-size: 14px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(245, 248, 255, 0.5); margin-bottom: 20px; color: rgb(10, 10, 10); border: 0.8px solid rgb(169, 172, 170);"><div class="zYSUYd" style="display: flex; flex-direction: row; overflow: hidden; border-radius: 8px 8px 0px 0px;"><div class="FS7GEb" style="display: flex; flex-direction: column; flex-grow: 1; min-width: 38%; width: 518.4px;"><div class="dDrxod" style="height: 34px; display: flex; justify-content: space-between; align-items: center; background: none 0% 0% / auto repeat scroll padding-box border-box rgb(229, 237, 255); border-bottom: 0.8px solid rgb(169, 172, 170);"><div class="x7ndcb" style="padding-left: 16px; display: flex; align-items: center; color: rgb(10, 10, 10);">JavaScript</div><div aria-live="polite" class="WDoJJe" style="margin-right: 4px; display: flex; align-items: center;"><button aria-label="Copy code to clipboard" class="hqI3tf B4zsNc" data-ved="2ahUKEwjamMvhl5yRAxXQd2wGHWI7MdcQ9MILegQIShAB" role="button" style="margin: 0px 2px; background: none; height: 34px; border: none; color: rgb(5, 40, 97); position: relative; top: 2px; outline: 0px;" tabindex="0" title="Copy"><span class="z1asCe wm4nBd" style="display: inline-block; fill: currentcolor; height: 20px; line-height: 20px; position: relative; width: 20px;"><svg aria-hidden="true" enable-background="new 0 0 24 24" focusable="false" height="24" viewbox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><g><rect fill="none" height="24" width="24"></rect></g><g><path d="M16,20H5V6H3v14c0,1.1,0.9,2,2,2h11V20z M20,16V4c0-1.1-0.9-2-2-2H9C7.9,2,7,2.9,7,4v12c0,1.1,0.9,2,2,2h9 C19.1,18,20,17.1,20,16z M18,16H9V4h9V16z"></path></g></svg></span></button></div></div></div></div><div class="QQjpRc" style="display: flex; flex-direction: row; overflow: hidden; border-radius: 0px 0px 8px 8px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(245, 248, 255, 0.5);"><div class="FS7GEb" jsname="zEXxAd" style="display: flex; flex-direction: column; flex-grow: 1; min-width: 38%; width: 518.4px;"></div></div></div></div></div></div>```
    db.myCollection.updateMany({ city: "London" }, { $set: { status: "active" } })
```

<div class="WaaZC" id="bkmrk-delete-a-single-docu" style="color: rgb(10, 10, 10); font-family: 'Google Sans', Arial, sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><div class="RJPOee EIJn2" style="animation: auto ease 0s 1 normal none running none !important; color: rgb(10, 10, 10);"><div class="rPeykc" data-hveid="CE0QAQ" data-ved="2ahUKEwjamMvhl5yRAxXQd2wGHWI7MdcQo_EKegQITRAB" style="margin: 10px 0px;"><span data-huuid="10119260923343867736">Delete a single document.</span></div></div></div><div class="WaaZC" id="bkmrk-javascript-12" style="color: rgb(10, 10, 10); font-family: 'Google Sans', Arial, sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><div class="RJPOee EIJn2" style="animation: auto ease 0s 1 normal none running none !important; color: rgb(10, 10, 10);"><div jsaction="rcuQ6b:npT2md" jscontroller="JegcYe"><div class="ecCNFc" style="border-image: none 100% / 1 / 0 stretch; border-radius: 8px; font-size: 14px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(245, 248, 255, 0.5); margin-bottom: 20px; color: rgb(10, 10, 10); border: 0.8px solid rgb(169, 172, 170);"><div class="zYSUYd" style="display: flex; flex-direction: row; overflow: hidden; border-radius: 8px 8px 0px 0px;"><div class="FS7GEb" style="display: flex; flex-direction: column; flex-grow: 1; min-width: 38%; width: 518.4px;"><div class="dDrxod" style="height: 34px; display: flex; justify-content: space-between; align-items: center; background: none 0% 0% / auto repeat scroll padding-box border-box rgb(229, 237, 255); border-bottom: 0.8px solid rgb(169, 172, 170);"><div class="x7ndcb" style="padding-left: 16px; display: flex; align-items: center; color: rgb(10, 10, 10);">JavaScript</div><div aria-live="polite" class="WDoJJe" style="margin-right: 4px; display: flex; align-items: center;"><button aria-label="Copy code to clipboard" class="hqI3tf B4zsNc" data-ved="2ahUKEwjamMvhl5yRAxXQd2wGHWI7MdcQ9MILegQITxAB" role="button" style="margin: 0px 2px; background: none; height: 34px; border: none; color: rgb(5, 40, 97); position: relative; top: 2px; outline: 0px;" tabindex="0" title="Copy"><span class="z1asCe wm4nBd" style="display: inline-block; fill: currentcolor; height: 20px; line-height: 20px; position: relative; width: 20px;"><svg aria-hidden="true" enable-background="new 0 0 24 24" focusable="false" height="24" viewbox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><g><rect fill="none" height="24" width="24"></rect></g><g><path d="M16,20H5V6H3v14c0,1.1,0.9,2,2,2h11V20z M20,16V4c0-1.1-0.9-2-2-2H9C7.9,2,7,2.9,7,4v12c0,1.1,0.9,2,2,2h9 C19.1,18,20,17.1,20,16z M18,16H9V4h9V16z"></path></g></svg></span></button></div></div></div></div><div class="QQjpRc" style="display: flex; flex-direction: row; overflow: hidden; border-radius: 0px 0px 8px 8px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(245, 248, 255, 0.5);"><div class="FS7GEb" jsname="zEXxAd" style="display: flex; flex-direction: column; flex-grow: 1; min-width: 38%; width: 518.4px;"></div></div></div></div></div></div>```
    db.myCollection.deleteOne({ name: "Bob" })
```

<div class="WaaZC" id="bkmrk-delete-multiple-docu" style="color: rgb(10, 10, 10); font-family: 'Google Sans', Arial, sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><div class="RJPOee EIJn2" style="animation: auto ease 0s 1 normal none running none !important; color: rgb(10, 10, 10);"><div class="rPeykc" data-hveid="CFIQAQ" data-ved="2ahUKEwjamMvhl5yRAxXQd2wGHWI7MdcQo_EKegQIUhAB" style="margin: 10px 0px;"><span data-huuid="10119260923343864614">Delete multiple documents.</span></div></div></div><div class="WaaZC" id="bkmrk-javascript-13" style="color: rgb(10, 10, 10); font-family: 'Google Sans', Arial, sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><div class="RJPOee EIJn2" style="animation: auto ease 0s 1 normal none running none !important; color: rgb(10, 10, 10);"><div jsaction="rcuQ6b:npT2md" jscontroller="JegcYe"><div class="ecCNFc" style="border-image: none 100% / 1 / 0 stretch; border-radius: 8px; font-size: 14px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(245, 248, 255, 0.5); margin-bottom: 20px; color: rgb(10, 10, 10); border: 0.8px solid rgb(169, 172, 170);"><div class="zYSUYd" style="display: flex; flex-direction: row; overflow: hidden; border-radius: 8px 8px 0px 0px;"><div class="FS7GEb" style="display: flex; flex-direction: column; flex-grow: 1; min-width: 38%; width: 518.4px;"><div class="dDrxod" style="height: 34px; display: flex; justify-content: space-between; align-items: center; background: none 0% 0% / auto repeat scroll padding-box border-box rgb(229, 237, 255); border-bottom: 0.8px solid rgb(169, 172, 170);"><div class="x7ndcb" style="padding-left: 16px; display: flex; align-items: center; color: rgb(10, 10, 10);">JavaScript</div><div aria-live="polite" class="WDoJJe" style="margin-right: 4px; display: flex; align-items: center;"><button aria-label="Copy code to clipboard" class="hqI3tf B4zsNc" data-ved="2ahUKEwjamMvhl5yRAxXQd2wGHWI7MdcQ9MILegQIVBAB" role="button" style="margin: 0px 2px; background: none; height: 34px; border: none; color: rgb(5, 40, 97); position: relative; top: 2px; outline: 0px;" tabindex="0" title="Copy"><span class="z1asCe wm4nBd" style="display: inline-block; fill: currentcolor; height: 20px; line-height: 20px; position: relative; width: 20px;"><svg aria-hidden="true" enable-background="new 0 0 24 24" focusable="false" height="24" viewbox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><g><rect fill="none" height="24" width="24"></rect></g><g><path d="M16,20H5V6H3v14c0,1.1,0.9,2,2,2h11V20z M20,16V4c0-1.1-0.9-2-2-2H9C7.9,2,7,2.9,7,4v12c0,1.1,0.9,2,2,2h9 C19.1,18,20,17.1,20,16z M18,16H9V4h9V16z"></path></g></svg></span></button></div></div></div></div><div class="QQjpRc" style="display: flex; flex-direction: row; overflow: hidden; border-radius: 0px 0px 8px 8px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(245, 248, 255, 0.5);"><div class="FS7GEb" jsname="zEXxAd" style="display: flex; flex-direction: column; flex-grow: 1; min-width: 38%; width: 518.4px;"></div></div></div></div></div></div>```
    db.myCollection.deleteMany({ status: "inactive" })
```

<div class="WaaZC" id="bkmrk-4.-utility-commands%3A" style="color: rgb(10, 10, 10); font-family: 'Google Sans', Arial, sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><div class="RJPOee EIJn2" style="animation: auto ease 0s 1 normal none running none !important; color: rgb(10, 10, 10);"><div aria-level="3" class="rPeykc pyPiTc" data-hveid="CFgQAQ" data-ved="2ahUKEwjamMvhl5yRAxXQd2wGHWI7MdcQo_EKegQIWBAB" role="heading" style="margin: 20px 0px 10px; font-size: 20px; font-weight: 600; line-height: 28px;"><span data-huuid="7295150558515138088">4. Utility Commands:</span></div></div></div><div class="WaaZC" id="bkmrk-clear-the-shell-scre" style="color: rgb(10, 10, 10); font-family: 'Google Sans', Arial, sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><div class="RJPOee EIJn2" style="animation: auto ease 0s 1 normal none running none !important; color: rgb(10, 10, 10);"><div class="rPeykc" data-hveid="CFcQAQ" data-ved="2ahUKEwjamMvhl5yRAxXQd2wGHWI7MdcQo_EKegQIVxAB" style="margin: 10px 0px;"><span data-huuid="10119260923343865588">Clear the shell screen.</span></div></div></div><div class="WaaZC" id="bkmrk-javascript-14" style="color: rgb(10, 10, 10); font-family: 'Google Sans', Arial, sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><div class="RJPOee EIJn2" style="animation: auto ease 0s 1 normal none running none !important; color: rgb(10, 10, 10);"><div jsaction="rcuQ6b:npT2md" jscontroller="JegcYe"><div class="ecCNFc" style="border-image: none 100% / 1 / 0 stretch; border-radius: 8px; font-size: 14px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(245, 248, 255, 0.5); margin-bottom: 20px; color: rgb(10, 10, 10); border: 0.8px solid rgb(169, 172, 170);"><div class="zYSUYd" style="display: flex; flex-direction: row; overflow: hidden; border-radius: 8px 8px 0px 0px;"><div class="FS7GEb" style="display: flex; flex-direction: column; flex-grow: 1; min-width: 38%; width: 518.4px;"><div class="dDrxod" style="height: 34px; display: flex; justify-content: space-between; align-items: center; background: none 0% 0% / auto repeat scroll padding-box border-box rgb(229, 237, 255); border-bottom: 0.8px solid rgb(169, 172, 170);"><div class="x7ndcb" style="padding-left: 16px; display: flex; align-items: center; color: rgb(10, 10, 10);">JavaScript</div><div aria-live="polite" class="WDoJJe" style="margin-right: 4px; display: flex; align-items: center;"><button aria-label="Copy code to clipboard" class="hqI3tf B4zsNc" data-ved="2ahUKEwjamMvhl5yRAxXQd2wGHWI7MdcQ9MILegQIXBAB" role="button" style="margin: 0px 2px; background: none; height: 34px; border: none; color: rgb(5, 40, 97); position: relative; top: 2px; outline: 0px;" tabindex="0" title="Copy"><span class="z1asCe wm4nBd" style="display: inline-block; fill: currentcolor; height: 20px; line-height: 20px; position: relative; width: 20px;"><svg aria-hidden="true" enable-background="new 0 0 24 24" focusable="false" height="24" viewbox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><g><rect fill="none" height="24" width="24"></rect></g><g><path d="M16,20H5V6H3v14c0,1.1,0.9,2,2,2h11V20z M20,16V4c0-1.1-0.9-2-2-2H9C7.9,2,7,2.9,7,4v12c0,1.1,0.9,2,2,2h9 C19.1,18,20,17.1,20,16z M18,16H9V4h9V16z"></path></g></svg></span></button></div></div></div></div><div class="QQjpRc" style="display: flex; flex-direction: row; overflow: hidden; border-radius: 0px 0px 8px 8px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(245, 248, 255, 0.5);"><div class="FS7GEb" jsname="zEXxAd" style="display: flex; flex-direction: column; flex-grow: 1; min-width: 38%; width: 518.4px;"></div></div></div></div></div></div>```
    cls
```

<div class="WaaZC" id="bkmrk-exit-the-shell." style="color: rgb(10, 10, 10); font-family: 'Google Sans', Arial, sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><div class="RJPOee EIJn2" style="animation: auto ease 0s 1 normal none running none !important; color: rgb(10, 10, 10);"><div class="rPeykc" data-hveid="CF4QAQ" data-ved="2ahUKEwjamMvhl5yRAxXQd2wGHWI7MdcQo_EKegQIXhAB" style="margin: 10px 0px;"><span data-huuid="10119260923343866562">exit the shell.</span></div></div></div><div class="WaaZC" id="bkmrk-javascript-15" style="color: rgb(10, 10, 10); font-family: 'Google Sans', Arial, sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><div class="RJPOee EIJn2" style="animation: auto ease 0s 1 normal none running none !important; color: rgb(10, 10, 10);"><div jsaction="rcuQ6b:npT2md" jscontroller="JegcYe"><div class="ecCNFc" style="border-image: none 100% / 1 / 0 stretch; border-radius: 8px; font-size: 14px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(245, 248, 255, 0.5); margin-bottom: 20px; color: rgb(10, 10, 10); border: 0.8px solid rgb(169, 172, 170);"><div class="zYSUYd" style="display: flex; flex-direction: row; overflow: hidden; border-radius: 8px 8px 0px 0px;"><div class="FS7GEb" style="display: flex; flex-direction: column; flex-grow: 1; min-width: 38%; width: 518.4px;"><div class="dDrxod" style="height: 34px; display: flex; justify-content: space-between; align-items: center; background: none 0% 0% / auto repeat scroll padding-box border-box rgb(229, 237, 255); border-bottom: 0.8px solid rgb(169, 172, 170);"><div class="x7ndcb" style="padding-left: 16px; display: flex; align-items: center; color: rgb(10, 10, 10);">JavaScript</div><div aria-live="polite" class="WDoJJe" style="margin-right: 4px; display: flex; align-items: center;"><button aria-label="Copy code to clipboard" class="hqI3tf B4zsNc" data-ved="2ahUKEwjamMvhl5yRAxXQd2wGHWI7MdcQ9MILegQIYRAB" role="button" style="margin: 0px 2px; background: none; height: 34px; border: none; color: rgb(5, 40, 97); position: relative; top: 2px; outline: 0px;" tabindex="0" title="Copy"><span class="z1asCe wm4nBd" style="display: inline-block; fill: currentcolor; height: 20px; line-height: 20px; position: relative; width: 20px;"><svg aria-hidden="true" enable-background="new 0 0 24 24" focusable="false" height="24" viewbox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><g><rect fill="none" height="24" width="24"></rect></g><g><path d="M16,20H5V6H3v14c0,1.1,0.9,2,2,2h11V20z M20,16V4c0-1.1-0.9-2-2-2H9C7.9,2,7,2.9,7,4v12c0,1.1,0.9,2,2,2h9 C19.1,18,20,17.1,20,16z M18,16H9V4h9V16z"></path></g></svg></span></button></div></div></div></div><div class="QQjpRc" style="display: flex; flex-direction: row; overflow: hidden; border-radius: 0px 0px 8px 8px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(245, 248, 255, 0.5);"><div class="FS7GEb" jsname="zEXxAd" style="display: flex; flex-direction: column; flex-grow: 1; min-width: 38%; width: 518.4px;"></div></div></div></div></div></div>```
    exit
```

# MongoDB: find documents matching regular expression

<div class="WaaZC" id="bkmrk-to-find-documents-ma" style="color: rgb(10, 10, 10); font-family: 'Google Sans', Arial, sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><div class="RJPOee EIJn2" style="animation: auto ease 0s 1 normal none running none !important; color: rgb(10, 10, 10);"><div class="rPeykc" data-hveid="CAYQAQ" data-ved="2ahUKEwjn8sfel5yRAxUFRmcHHbfJCWEQo_EKegQIBhAB" style="margin: 0px 0px 10px;"><span data-huuid="18296117462275676405">To find documents matching a regular expression in the MongoDB shell, use the `find()` method with the `$regex` operator or a regex literal.</span></div></div></div><div class="WaaZC" id="bkmrk-using-a-regex-litera" style="color: rgb(10, 10, 10); font-family: 'Google Sans', Arial, sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><div class="RJPOee EIJn2" style="animation: auto ease 0s 1 normal none running none !important; color: rgb(10, 10, 10);"><div aria-level="3" class="rPeykc pyPiTc" data-hveid="CAgQAQ" data-ved="2ahUKEwjn8sfel5yRAxUFRmcHHbfJCWEQo_EKegQICBAB" role="heading" style="margin: 20px 0px 10px; font-size: 20px; font-weight: 600; line-height: 28px;"><span data-huuid="18296117462275677343">Using a Regex Literal:</span></div></div></div><div class="WaaZC" id="bkmrk-javascript" style="color: rgb(10, 10, 10); font-family: 'Google Sans', Arial, sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><div class="RJPOee EIJn2" style="animation: auto ease 0s 1 normal none running none !important; color: rgb(10, 10, 10);"><div jsaction="rcuQ6b:npT2md" jscontroller="JegcYe"><div class="ecCNFc" style="border-image: none 100% / 1 / 0 stretch; border-radius: 8px; font-size: 14px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(245, 248, 255, 0.5); margin-bottom: 20px; color: rgb(10, 10, 10); border: 0.8px solid rgb(169, 172, 170);"><div class="zYSUYd" style="display: flex; flex-direction: row; overflow: hidden; border-radius: 8px 8px 0px 0px;"><div class="FS7GEb" style="display: flex; flex-direction: column; flex-grow: 1; min-width: 38%; width: 518.4px;"><div class="dDrxod" style="height: 34px; display: flex; justify-content: space-between; align-items: center; background: none 0% 0% / auto repeat scroll padding-box border-box rgb(229, 237, 255); border-bottom: 0.8px solid rgb(169, 172, 170);"><div class="x7ndcb" style="padding-left: 16px; display: flex; align-items: center; color: rgb(10, 10, 10);">JavaScript</div><div aria-live="polite" class="WDoJJe" style="margin-right: 4px; display: flex; align-items: center;"><button aria-label="Copy code to clipboard" class="hqI3tf B4zsNc" data-ved="2ahUKEwjn8sfel5yRAxUFRmcHHbfJCWEQ9MILegQIAhAB" role="button" style="margin: 0px 2px; background: none; height: 34px; border: none; color: rgb(5, 40, 97); position: relative; top: 2px; outline: 0px;" tabindex="0" title="Copy"><span class="z1asCe wm4nBd" style="display: inline-block; fill: currentcolor; height: 20px; line-height: 20px; position: relative; width: 20px;"><svg aria-hidden="true" enable-background="new 0 0 24 24" focusable="false" height="24" viewbox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><g><rect fill="none" height="24" width="24"></rect></g><g><path d="M16,20H5V6H3v14c0,1.1,0.9,2,2,2h11V20z M20,16V4c0-1.1-0.9-2-2-2H9C7.9,2,7,2.9,7,4v12c0,1.1,0.9,2,2,2h9 C19.1,18,20,17.1,20,16z M18,16H9V4h9V16z"></path></g></svg></span></button></div></div></div></div><div class="QQjpRc" style="display: flex; flex-direction: row; overflow: hidden; border-radius: 0px 0px 8px 8px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(245, 248, 255, 0.5);"><div class="FS7GEb" jsname="zEXxAd" style="display: flex; flex-direction: column; flex-grow: 1; min-width: 38%; width: 518.4px;"></div></div></div></div></div></div>```
db.collectionName.find({ fieldName: /pattern/options });
```

<div class="WaaZC" id="bkmrk-example%3A-find-docume" style="color: rgb(10, 10, 10); font-family: 'Google Sans', Arial, sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><div class="RJPOee EIJn2" style="animation: auto ease 0s 1 normal none running none !important; color: rgb(10, 10, 10);"><div class="rPeykc" data-hveid="CAUQAQ" data-ved="2ahUKEwjn8sfel5yRAxUFRmcHHbfJCWEQo_EKegQIBRAB" style="margin: 10px 0px;"><span data-huuid="18296117462275675123">Example: Find documents in the `users` collection where the `name` field contains "john" (case-insensitive).<span class="pjBG2e" data-cid="185a15d5-14f2-4174-bbcc-b23c42423d38"><span class="UV3uM" style="white-space: nowrap;"> </span></span></span><div class="NPrrbc" data-cid="185a15d5-14f2-4174-bbcc-b23c42423d38" data-uuids="18296117462275675123" style="margin-inline-end: 6px; vertical-align: middle; display: inline-flex;"><div aria-label="View related links" class="BMebGe btku5b LwdV0e FR7ZSc OJeuxf" data-hveid="CAkQAQ" data-ved="2ahUKEwjn8sfel5yRAxUFRmcHHbfJCWEQ3fYKegQICRAB" jsaction="KjsqPd" jsname="HtgYJd" role="button" style="display: inline-block; vertical-align: middle; cursor: pointer; outline: 0px; -webkit-tap-highlight-color: transparent; color: rgb(28, 65, 154);" tabindex="0"><div class="niO4u" style="display: flex; justify-content: center; position: relative; align-items: center; width: 28px; z-index: 0; box-sizing: border-box; border-radius: 9999px; padding: 0px; border: 1px solid transparent; background: transparent; height: 20px; margin: 0px auto; min-height: 20px;"><span class="TwMgNb Hkv2Pe" style="color: rgb(31, 31, 31) !important; background: unset !important; display: flex; align-items: center;"><span class="iPjmzb Sorfoc gNGSDf" style="display: flex; height: unset; rotate: 135deg;"><span class="z1asCe Sb7k4e" style="display: inline-block; fill: currentcolor; height: 18px; line-height: 18px; position: relative; width: 18px;"><svg aria-hidden="true" focusable="false" viewbox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M3.9 12c0-1.71 1.39-3.1 3.1-3.1h4V7H7c-2.76 0-5 2.24-5 5s2.24 5 5 5h4v-1.9H7c-1.71 0-3.1-1.39-3.1-3.1zM8 13h8v-2H8v2zm9-6h-4v1.9h4c1.71 0 3.1 1.39 3.1 3.1s-1.39 3.1-3.1 3.1h-4V17h4c2.76 0 5-2.24 5-5s-2.24-5-5-5z"></path></svg></span></span></span></div></div></div></div></div></div><div class="WaaZC" id="bkmrk-javascript-1" style="color: rgb(10, 10, 10); font-family: 'Google Sans', Arial, sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><div class="RJPOee EIJn2" style="animation: auto ease 0s 1 normal none running none !important; color: rgb(10, 10, 10);"><div jsaction="rcuQ6b:npT2md" jscontroller="JegcYe"><div class="ecCNFc" style="border-image: none 100% / 1 / 0 stretch; border-radius: 8px; font-size: 14px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(245, 248, 255, 0.5); margin-bottom: 20px; color: rgb(10, 10, 10); border: 0.8px solid rgb(169, 172, 170);"><div class="zYSUYd" style="display: flex; flex-direction: row; overflow: hidden; border-radius: 8px 8px 0px 0px;"><div class="FS7GEb" style="display: flex; flex-direction: column; flex-grow: 1; min-width: 38%; width: 518.4px;"><div class="dDrxod" style="height: 34px; display: flex; justify-content: space-between; align-items: center; background: none 0% 0% / auto repeat scroll padding-box border-box rgb(229, 237, 255); border-bottom: 0.8px solid rgb(169, 172, 170);"><div class="x7ndcb" style="padding-left: 16px; display: flex; align-items: center; color: rgb(10, 10, 10);">JavaScript</div><div aria-live="polite" class="WDoJJe" style="margin-right: 4px; display: flex; align-items: center;"><button aria-label="Copy code to clipboard" class="hqI3tf B4zsNc" data-ved="2ahUKEwjn8sfel5yRAxUFRmcHHbfJCWEQ9MILegQIAxAB" role="button" style="margin: 0px 2px; background: none; height: 34px; border: none; color: rgb(5, 40, 97); position: relative; top: 2px; outline: 0px;" tabindex="0" title="Copy"><span class="z1asCe wm4nBd" style="display: inline-block; fill: currentcolor; height: 20px; line-height: 20px; position: relative; width: 20px;"><svg aria-hidden="true" enable-background="new 0 0 24 24" focusable="false" height="24" viewbox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><g><rect fill="none" height="24" width="24"></rect></g><g><path d="M16,20H5V6H3v14c0,1.1,0.9,2,2,2h11V20z M20,16V4c0-1.1-0.9-2-2-2H9C7.9,2,7,2.9,7,4v12c0,1.1,0.9,2,2,2h9 C19.1,18,20,17.1,20,16z M18,16H9V4h9V16z"></path></g></svg></span></button></div></div></div></div><div class="QQjpRc" style="display: flex; flex-direction: row; overflow: hidden; border-radius: 0px 0px 8px 8px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(245, 248, 255, 0.5);"><div class="FS7GEb" jsname="zEXxAd" style="display: flex; flex-direction: column; flex-grow: 1; min-width: 38%; width: 518.4px;"></div></div></div></div></div></div>```
db.users.find({ name: /john/i });
```

<div class="WaaZC" id="bkmrk-using-the%C2%A0%24regex%C2%A0ope" style="color: rgb(10, 10, 10); font-family: 'Google Sans', Arial, sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><div class="RJPOee EIJn2" style="animation: auto ease 0s 1 normal none running none !important; color: rgb(10, 10, 10);"><div aria-level="3" class="rPeykc pyPiTc" data-hveid="CBIQAQ" data-ved="2ahUKEwjn8sfel5yRAxUFRmcHHbfJCWEQo_EKegQIEhAB" role="heading" style="margin: 20px 0px 10px; font-size: 20px; font-weight: 600; line-height: 28px;"><span data-huuid="2390380601864167977">Using the `$regex` Operator:</span></div></div></div><div class="WaaZC" id="bkmrk-javascript-2" style="color: rgb(10, 10, 10); font-family: 'Google Sans', Arial, sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><div class="RJPOee EIJn2" style="animation: auto ease 0s 1 normal none running none !important; color: rgb(10, 10, 10);"><div jsaction="rcuQ6b:npT2md" jscontroller="JegcYe"><div class="ecCNFc" style="border-image: none 100% / 1 / 0 stretch; border-radius: 8px; font-size: 14px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(245, 248, 255, 0.5); margin-bottom: 20px; color: rgb(10, 10, 10); border: 0.8px solid rgb(169, 172, 170);"><div class="zYSUYd" style="display: flex; flex-direction: row; overflow: hidden; border-radius: 8px 8px 0px 0px;"><div class="FS7GEb" style="display: flex; flex-direction: column; flex-grow: 1; min-width: 38%; width: 518.4px;"><div class="dDrxod" style="height: 34px; display: flex; justify-content: space-between; align-items: center; background: none 0% 0% / auto repeat scroll padding-box border-box rgb(229, 237, 255); border-bottom: 0.8px solid rgb(169, 172, 170);"><div class="x7ndcb" style="padding-left: 16px; display: flex; align-items: center; color: rgb(10, 10, 10);">JavaScript</div><div aria-live="polite" class="WDoJJe" style="margin-right: 4px; display: flex; align-items: center;"><button aria-label="Copy code to clipboard" class="hqI3tf B4zsNc" data-ved="2ahUKEwjn8sfel5yRAxUFRmcHHbfJCWEQ9MILegQIERAB" role="button" style="margin: 0px 2px; background: none; height: 34px; border: none; color: rgb(5, 40, 97); position: relative; top: 2px; outline: 0px;" tabindex="0" title="Copy"><span class="z1asCe wm4nBd" style="display: inline-block; fill: currentcolor; height: 20px; line-height: 20px; position: relative; width: 20px;"><svg aria-hidden="true" enable-background="new 0 0 24 24" focusable="false" height="24" viewbox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><g><rect fill="none" height="24" width="24"></rect></g><g><path d="M16,20H5V6H3v14c0,1.1,0.9,2,2,2h11V20z M20,16V4c0-1.1-0.9-2-2-2H9C7.9,2,7,2.9,7,4v12c0,1.1,0.9,2,2,2h9 C19.1,18,20,17.1,20,16z M18,16H9V4h9V16z"></path></g></svg></span></button></div></div></div></div><div class="QQjpRc" style="display: flex; flex-direction: row; overflow: hidden; border-radius: 0px 0px 8px 8px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(245, 248, 255, 0.5);"><div class="FS7GEb" jsname="zEXxAd" style="display: flex; flex-direction: column; flex-grow: 1; min-width: 38%; width: 518.4px;"></div></div></div></div></div></div>```
db.collectionName.find({ fieldName: { $regex: "pattern", $options: "options" } });
```

<div class="WaaZC" id="bkmrk-example%3A-find-docume-1" style="color: rgb(10, 10, 10); font-family: 'Google Sans', Arial, sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><div class="RJPOee EIJn2" style="animation: auto ease 0s 1 normal none running none !important; color: rgb(10, 10, 10);"><div class="rPeykc" data-hveid="CBcQAQ" data-ved="2ahUKEwjn8sfel5yRAxUFRmcHHbfJCWEQo_EKegQIFxAB" style="margin: 10px 0px;"><span data-huuid="860535635466021435">Example: Find documents in the `products` collection where the `description` field contains "eco-friendly" (case-insensitive).</span></div></div></div><div class="WaaZC" id="bkmrk-javascript-3" style="color: rgb(10, 10, 10); font-family: 'Google Sans', Arial, sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><div class="RJPOee EIJn2" style="animation: auto ease 0s 1 normal none running none !important; color: rgb(10, 10, 10);"><div jsaction="rcuQ6b:npT2md" jscontroller="JegcYe"><div class="ecCNFc" style="border-image: none 100% / 1 / 0 stretch; border-radius: 8px; font-size: 14px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(245, 248, 255, 0.5); margin-bottom: 20px; color: rgb(10, 10, 10); border: 0.8px solid rgb(169, 172, 170);"><div class="zYSUYd" style="display: flex; flex-direction: row; overflow: hidden; border-radius: 8px 8px 0px 0px;"><div class="FS7GEb" style="display: flex; flex-direction: column; flex-grow: 1; min-width: 38%; width: 518.4px;"><div class="dDrxod" style="height: 34px; display: flex; justify-content: space-between; align-items: center; background: none 0% 0% / auto repeat scroll padding-box border-box rgb(229, 237, 255); border-bottom: 0.8px solid rgb(169, 172, 170);"><div class="x7ndcb" style="padding-left: 16px; display: flex; align-items: center; color: rgb(10, 10, 10);">JavaScript</div><div aria-live="polite" class="WDoJJe" style="margin-right: 4px; display: flex; align-items: center;"><button aria-label="Copy code to clipboard" class="hqI3tf B4zsNc" data-ved="2ahUKEwjn8sfel5yRAxUFRmcHHbfJCWEQ9MILegQIGRAB" role="button" style="margin: 0px 2px; background: none; height: 34px; border: none; color: rgb(5, 40, 97); position: relative; top: 2px; outline: 0px;" tabindex="0" title="Copy"><span class="z1asCe wm4nBd" style="display: inline-block; fill: currentcolor; height: 20px; line-height: 20px; position: relative; width: 20px;"><svg aria-hidden="true" enable-background="new 0 0 24 24" focusable="false" height="24" viewbox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><g><rect fill="none" height="24" width="24"></rect></g><g><path d="M16,20H5V6H3v14c0,1.1,0.9,2,2,2h11V20z M20,16V4c0-1.1-0.9-2-2-2H9C7.9,2,7,2.9,7,4v12c0,1.1,0.9,2,2,2h9 C19.1,18,20,17.1,20,16z M18,16H9V4h9V16z"></path></g></svg></span></button></div></div></div></div><div class="QQjpRc" style="display: flex; flex-direction: row; overflow: hidden; border-radius: 0px 0px 8px 8px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(245, 248, 255, 0.5);"><div class="FS7GEb" jsname="zEXxAd" style="display: flex; flex-direction: column; flex-grow: 1; min-width: 38%; width: 518.4px;"></div></div></div></div></div></div>```
db.products.find({ description: { $regex: "eco-friendly", $options: "i" } });
```

<div class="WaaZC" id="bkmrk-explanation%3A" style="color: rgb(10, 10, 10); font-family: 'Google Sans', Arial, sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><div class="RJPOee EIJn2" style="animation: auto ease 0s 1 normal none running none !important; color: rgb(10, 10, 10);"><div aria-level="3" class="rPeykc pyPiTc" data-hveid="CBwQAQ" data-ved="2ahUKEwjn8sfel5yRAxUFRmcHHbfJCWEQo_EKegQIHBAB" role="heading" style="margin: 20px 0px 10px; font-size: 20px; font-weight: 600; line-height: 28px;"><span data-huuid="14920847425488760521">Explanation:</span></div></div></div><div class="WaaZC" id="bkmrk-collectionname%3A-the-" style="color: rgb(10, 10, 10); font-family: 'Google Sans', Arial, sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><div class="RJPOee EIJn2" style="animation: auto ease 0s 1 normal none running none !important; color: rgb(10, 10, 10);">- <span data-huuid="14920847425488759614">`collectionName`: The name of the collection to query.</span>
- <span data-huuid="14920847425488757644">`fieldName`: The field within the documents to apply the regular expression to.</span>
- <span data-huuid="14920847425488759770">`pattern`: The regular expression pattern to match.</span>
- <span data-huuid="14920847425488757800">`options`: Optional flags to modify the regex behavior. </span><span data-huuid="14920847425488758863">Common options include:</span>
    - <span data-huuid="14920847425488757956">`i`: Case-insensitive matching.</span>
    - <span data-huuid="14920847425488760082">`m`: Multi-line matching.</span>
    - <span data-huuid="14920847425488758112">`s`: Allows the dot (`.`) to match newline characters.</span>
    - <span data-huuid="14920847425488760238">`x`: Ignores whitespace characters in the pattern unless escaped.</span>

</div></div>