mirror of
https://github.com/m-lamonaca/dev-notes.git
synced 2025-04-06 02:46:39 +00:00
5918 lines
No EOL
217 KiB
HTML
5918 lines
No EOL
217 KiB
HTML
|
|
<!doctype html>
|
|
<html lang="en" class="no-js">
|
|
<head>
|
|
|
|
<meta charset="utf-8">
|
|
<meta name="viewport" content="width=device-width,initial-scale=1">
|
|
|
|
|
|
<meta name="author" content="Marcello Lamonaca">
|
|
|
|
|
|
<link rel="canonical" href="http://m-lamonaca.github.io/dev-notes/databases/mongo-db.html">
|
|
|
|
|
|
<link rel="prev" href="sql.html">
|
|
|
|
|
|
<link rel="next" href="../languages/html/html.html">
|
|
|
|
|
|
<link rel="icon" href="../assets/images/favicon.png">
|
|
<meta name="generator" content="mkdocs-1.6.1, mkdocs-material-9.5.34">
|
|
|
|
|
|
|
|
<title>MongoDB - Dev Notes</title>
|
|
|
|
|
|
|
|
<link rel="stylesheet" href="../assets/stylesheets/main.35f28582.min.css">
|
|
|
|
|
|
<link rel="stylesheet" href="../assets/stylesheets/palette.06af60db.min.css">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<script src="https://unpkg.com/iframe-worker/shim"></script>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
|
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,300i,400,400i,700,700i%7CRoboto+Mono:400,400i,700,700i&display=fallback">
|
|
<style>:root{--md-text-font:"Roboto";--md-code-font:"Roboto Mono"}</style>
|
|
|
|
|
|
|
|
<script>__md_scope=new URL("..",location),__md_hash=e=>[...e].reduce(((e,_)=>(e<<5)-e+_.charCodeAt(0)),0),__md_get=(e,_=localStorage,t=__md_scope)=>JSON.parse(_.getItem(t.pathname+"."+e)),__md_set=(e,_,t=localStorage,a=__md_scope)=>{try{t.setItem(a.pathname+"."+e,JSON.stringify(_))}catch(e){}}</script>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<meta property="og:type" content="website" >
|
|
|
|
<meta property="og:title" content="MongoDB - Dev Notes" >
|
|
|
|
<meta property="og:description" content="None" >
|
|
|
|
<meta property="og:image" content="http://m-lamonaca.github.io/dev-notes/assets/images/social/databases/mongo-db.png" >
|
|
|
|
<meta property="og:image:type" content="image/png" >
|
|
|
|
<meta property="og:image:width" content="1200" >
|
|
|
|
<meta property="og:image:height" content="630" >
|
|
|
|
<meta property="og:url" content="http://m-lamonaca.github.io/dev-notes/databases/mongo-db.html" >
|
|
|
|
<meta name="twitter:card" content="summary_large_image" >
|
|
|
|
<meta name="twitter:title" content="MongoDB - Dev Notes" >
|
|
|
|
<meta name="twitter:description" content="None" >
|
|
|
|
<meta name="twitter:image" content="http://m-lamonaca.github.io/dev-notes/assets/images/social/databases/mongo-db.png" >
|
|
|
|
|
|
|
|
</head>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<body dir="ltr" data-md-color-scheme="default" data-md-color-primary="orange" data-md-color-accent="deep-orange">
|
|
|
|
|
|
<input class="md-toggle" data-md-toggle="drawer" type="checkbox" id="__drawer" autocomplete="off">
|
|
<input class="md-toggle" data-md-toggle="search" type="checkbox" id="__search" autocomplete="off">
|
|
<label class="md-overlay" for="__drawer"></label>
|
|
<div data-md-component="skip">
|
|
|
|
|
|
<a href="#mongodb" class="md-skip">
|
|
Skip to content
|
|
</a>
|
|
|
|
</div>
|
|
<div data-md-component="announce">
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<header class="md-header md-header--shadow md-header--lifted" data-md-component="header">
|
|
<nav class="md-header__inner md-grid" aria-label="Header">
|
|
<a href="../index.html" title="Dev Notes" class="md-header__button md-logo" aria-label="Dev Notes" data-md-component="logo">
|
|
|
|
|
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 512"><!--! Font Awesome Free 6.6.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2024 Fonticons, Inc.--><path d="M392.8 1.2c-17-4.9-34.7 5-39.6 22l-128 448c-4.9 17 5 34.7 22 39.6s34.7-5 39.6-22l128-448c4.9-17-5-34.7-22-39.6m80.6 120.1c-12.5 12.5-12.5 32.8 0 45.3l89.3 89.4-89.4 89.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0l112-112c12.5-12.5 12.5-32.8 0-45.3l-112-112c-12.5-12.5-32.8-12.5-45.3 0zm-306.7 0c-12.5-12.5-32.8-12.5-45.3 0l-112 112c-12.5 12.5-12.5 32.8 0 45.3l112 112c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3L77.3 256l89.4-89.4c12.5-12.5 12.5-32.8 0-45.3"/></svg>
|
|
|
|
</a>
|
|
<label class="md-header__button md-icon" for="__drawer">
|
|
|
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M3 6h18v2H3zm0 5h18v2H3zm0 5h18v2H3z"/></svg>
|
|
</label>
|
|
<div class="md-header__title" data-md-component="header-title">
|
|
<div class="md-header__ellipsis">
|
|
<div class="md-header__topic">
|
|
<span class="md-ellipsis">
|
|
Dev Notes
|
|
</span>
|
|
</div>
|
|
<div class="md-header__topic" data-md-component="header-topic">
|
|
<span class="md-ellipsis">
|
|
|
|
MongoDB
|
|
|
|
</span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<form class="md-header__option" data-md-component="palette">
|
|
|
|
|
|
|
|
|
|
<input class="md-option" data-md-color-media="(prefers-color-scheme: light)" data-md-color-scheme="default" data-md-color-primary="orange" data-md-color-accent="deep-orange" aria-label="Switch to dark mode" type="radio" name="__palette" id="__palette_0">
|
|
|
|
<label class="md-header__button md-icon" title="Switch to dark mode" for="__palette_1" hidden>
|
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M12 8a4 4 0 0 0-4 4 4 4 0 0 0 4 4 4 4 0 0 0 4-4 4 4 0 0 0-4-4m0 10a6 6 0 0 1-6-6 6 6 0 0 1 6-6 6 6 0 0 1 6 6 6 6 0 0 1-6 6m8-9.31V4h-4.69L12 .69 8.69 4H4v4.69L.69 12 4 15.31V20h4.69L12 23.31 15.31 20H20v-4.69L23.31 12z"/></svg>
|
|
</label>
|
|
|
|
|
|
|
|
|
|
|
|
<input class="md-option" data-md-color-media="(prefers-color-scheme: dark)" data-md-color-scheme="slate" data-md-color-primary="orange" data-md-color-accent="deep-orange" aria-label="Switch to light mode" type="radio" name="__palette" id="__palette_1">
|
|
|
|
<label class="md-header__button md-icon" title="Switch to light mode" for="__palette_0" hidden>
|
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M12 18c-.89 0-1.74-.2-2.5-.55C11.56 16.5 13 14.42 13 12s-1.44-4.5-3.5-5.45C10.26 6.2 11.11 6 12 6a6 6 0 0 1 6 6 6 6 0 0 1-6 6m8-9.31V4h-4.69L12 .69 8.69 4H4v4.69L.69 12 4 15.31V20h4.69L12 23.31 15.31 20H20v-4.69L23.31 12z"/></svg>
|
|
</label>
|
|
|
|
|
|
</form>
|
|
|
|
|
|
|
|
<script>var palette=__md_get("__palette");if(palette&&palette.color){if("(prefers-color-scheme)"===palette.color.media){var media=matchMedia("(prefers-color-scheme: light)"),input=document.querySelector(media.matches?"[data-md-color-media='(prefers-color-scheme: light)']":"[data-md-color-media='(prefers-color-scheme: dark)']");palette.color.media=input.getAttribute("data-md-color-media"),palette.color.scheme=input.getAttribute("data-md-color-scheme"),palette.color.primary=input.getAttribute("data-md-color-primary"),palette.color.accent=input.getAttribute("data-md-color-accent")}for(var[key,value]of Object.entries(palette.color))document.body.setAttribute("data-md-color-"+key,value)}</script>
|
|
|
|
|
|
|
|
<label class="md-header__button md-icon" for="__search">
|
|
|
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M9.5 3A6.5 6.5 0 0 1 16 9.5c0 1.61-.59 3.09-1.56 4.23l.27.27h.79l5 5-1.5 1.5-5-5v-.79l-.27-.27A6.52 6.52 0 0 1 9.5 16 6.5 6.5 0 0 1 3 9.5 6.5 6.5 0 0 1 9.5 3m0 2C7 5 5 7 5 9.5S7 14 9.5 14 14 12 14 9.5 12 5 9.5 5"/></svg>
|
|
</label>
|
|
<div class="md-search" data-md-component="search" role="dialog">
|
|
<label class="md-search__overlay" for="__search"></label>
|
|
<div class="md-search__inner" role="search">
|
|
<form class="md-search__form" name="search">
|
|
<input type="text" class="md-search__input" name="query" aria-label="Search" placeholder="Search" autocapitalize="off" autocorrect="off" autocomplete="off" spellcheck="false" data-md-component="search-query" required>
|
|
<label class="md-search__icon md-icon" for="__search">
|
|
|
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M9.5 3A6.5 6.5 0 0 1 16 9.5c0 1.61-.59 3.09-1.56 4.23l.27.27h.79l5 5-1.5 1.5-5-5v-.79l-.27-.27A6.52 6.52 0 0 1 9.5 16 6.5 6.5 0 0 1 3 9.5 6.5 6.5 0 0 1 9.5 3m0 2C7 5 5 7 5 9.5S7 14 9.5 14 14 12 14 9.5 12 5 9.5 5"/></svg>
|
|
|
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M20 11v2H8l5.5 5.5-1.42 1.42L4.16 12l7.92-7.92L13.5 5.5 8 11z"/></svg>
|
|
</label>
|
|
<nav class="md-search__options" aria-label="Search">
|
|
|
|
<button type="reset" class="md-search__icon md-icon" title="Clear" aria-label="Clear" tabindex="-1">
|
|
|
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M19 6.41 17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"/></svg>
|
|
</button>
|
|
</nav>
|
|
|
|
</form>
|
|
<div class="md-search__output">
|
|
<div class="md-search__scrollwrap" tabindex="0" data-md-scrollfix>
|
|
<div class="md-search-result" data-md-component="search-result">
|
|
<div class="md-search-result__meta">
|
|
Initializing search
|
|
</div>
|
|
<ol class="md-search-result__list" role="presentation"></ol>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<div class="md-header__source">
|
|
<a href="https://github.com/m-lamonaca/dev-notes" title="Go to repository" class="md-source" data-md-component="source">
|
|
<div class="md-source__icon md-icon">
|
|
|
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><!--! Font Awesome Free 6.6.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2024 Fonticons, Inc.--><path d="M439.55 236.05 244 40.45a28.87 28.87 0 0 0-40.81 0l-40.66 40.63 51.52 51.52c27.06-9.14 52.68 16.77 43.39 43.68l49.66 49.66c34.23-11.8 61.18 31 35.47 56.69-26.49 26.49-70.21-2.87-56-37.34L240.22 199v121.85c25.3 12.54 22.26 41.85 9.08 55a34.34 34.34 0 0 1-48.55 0c-17.57-17.6-11.07-46.91 11.25-56v-123c-20.8-8.51-24.6-30.74-18.64-45L142.57 101 8.45 235.14a28.86 28.86 0 0 0 0 40.81l195.61 195.6a28.86 28.86 0 0 0 40.8 0l194.69-194.69a28.86 28.86 0 0 0 0-40.81"/></svg>
|
|
</div>
|
|
<div class="md-source__repository">
|
|
GitHub
|
|
</div>
|
|
</a>
|
|
</div>
|
|
|
|
</nav>
|
|
|
|
|
|
|
|
<nav class="md-tabs" aria-label="Tabs" data-md-component="tabs">
|
|
<div class="md-grid">
|
|
<ul class="md-tabs__list">
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-tabs__item">
|
|
<a href="../index.html" class="md-tabs__link">
|
|
|
|
|
|
|
|
|
|
Home
|
|
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-tabs__item">
|
|
<a href="../containers/docker.html" class="md-tabs__link">
|
|
|
|
|
|
|
|
|
|
Containers
|
|
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-tabs__item md-tabs__item--active">
|
|
<a href="redis.html" class="md-tabs__link">
|
|
|
|
|
|
|
|
|
|
Databases
|
|
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-tabs__item">
|
|
<a href="../languages/html/html.html" class="md-tabs__link">
|
|
|
|
|
|
|
|
|
|
Languages
|
|
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-tabs__item">
|
|
<a href="../misc/git.html" class="md-tabs__link">
|
|
|
|
|
|
|
|
|
|
Misc
|
|
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-tabs__item">
|
|
<a href="../linux/filesystem/file-links.html" class="md-tabs__link">
|
|
|
|
|
|
|
|
|
|
Linux
|
|
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</ul>
|
|
</div>
|
|
</nav>
|
|
|
|
|
|
</header>
|
|
|
|
<div class="md-container" data-md-component="container">
|
|
|
|
|
|
|
|
|
|
<main class="md-main" data-md-component="main">
|
|
<div class="md-main__inner md-grid">
|
|
|
|
|
|
|
|
<div class="md-sidebar md-sidebar--primary" data-md-component="sidebar" data-md-type="navigation" >
|
|
<div class="md-sidebar__scrollwrap">
|
|
<div class="md-sidebar__inner">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<nav class="md-nav md-nav--primary md-nav--lifted" aria-label="Navigation" data-md-level="0">
|
|
<label class="md-nav__title" for="__drawer">
|
|
<a href="../index.html" title="Dev Notes" class="md-nav__button md-logo" aria-label="Dev Notes" data-md-component="logo">
|
|
|
|
|
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 512"><!--! Font Awesome Free 6.6.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2024 Fonticons, Inc.--><path d="M392.8 1.2c-17-4.9-34.7 5-39.6 22l-128 448c-4.9 17 5 34.7 22 39.6s34.7-5 39.6-22l128-448c4.9-17-5-34.7-22-39.6m80.6 120.1c-12.5 12.5-12.5 32.8 0 45.3l89.3 89.4-89.4 89.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0l112-112c12.5-12.5 12.5-32.8 0-45.3l-112-112c-12.5-12.5-32.8-12.5-45.3 0zm-306.7 0c-12.5-12.5-32.8-12.5-45.3 0l-112 112c-12.5 12.5-12.5 32.8 0 45.3l112 112c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3L77.3 256l89.4-89.4c12.5-12.5 12.5-32.8 0-45.3"/></svg>
|
|
|
|
</a>
|
|
Dev Notes
|
|
</label>
|
|
|
|
<div class="md-nav__source">
|
|
<a href="https://github.com/m-lamonaca/dev-notes" title="Go to repository" class="md-source" data-md-component="source">
|
|
<div class="md-source__icon md-icon">
|
|
|
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><!--! Font Awesome Free 6.6.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2024 Fonticons, Inc.--><path d="M439.55 236.05 244 40.45a28.87 28.87 0 0 0-40.81 0l-40.66 40.63 51.52 51.52c27.06-9.14 52.68 16.77 43.39 43.68l49.66 49.66c34.23-11.8 61.18 31 35.47 56.69-26.49 26.49-70.21-2.87-56-37.34L240.22 199v121.85c25.3 12.54 22.26 41.85 9.08 55a34.34 34.34 0 0 1-48.55 0c-17.57-17.6-11.07-46.91 11.25-56v-123c-20.8-8.51-24.6-30.74-18.64-45L142.57 101 8.45 235.14a28.86 28.86 0 0 0 0 40.81l195.61 195.6a28.86 28.86 0 0 0 40.8 0l194.69-194.69a28.86 28.86 0 0 0 0-40.81"/></svg>
|
|
</div>
|
|
<div class="md-source__repository">
|
|
GitHub
|
|
</div>
|
|
</a>
|
|
</div>
|
|
|
|
<ul class="md-nav__list" data-md-scrollfix>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../index.html" class="md-nav__link">
|
|
|
|
|
|
<span class="md-ellipsis">
|
|
Home
|
|
</span>
|
|
|
|
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item md-nav__item--nested">
|
|
|
|
|
|
|
|
<input class="md-nav__toggle md-toggle " type="checkbox" id="__nav_2" >
|
|
|
|
|
|
<label class="md-nav__link" for="__nav_2" id="__nav_2_label" tabindex="0">
|
|
|
|
|
|
<span class="md-ellipsis">
|
|
Containers
|
|
</span>
|
|
|
|
|
|
<span class="md-nav__icon md-icon"></span>
|
|
</label>
|
|
|
|
<nav class="md-nav" data-md-level="1" aria-labelledby="__nav_2_label" aria-expanded="false">
|
|
<label class="md-nav__title" for="__nav_2">
|
|
<span class="md-nav__icon md-icon"></span>
|
|
Containers
|
|
</label>
|
|
<ul class="md-nav__list" data-md-scrollfix>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../containers/docker.html" class="md-nav__link">
|
|
|
|
|
|
<span class="md-ellipsis">
|
|
Docker
|
|
</span>
|
|
|
|
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../containers/kubernetes.html" class="md-nav__link">
|
|
|
|
|
|
<span class="md-ellipsis">
|
|
Kubernetes
|
|
</span>
|
|
|
|
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
</ul>
|
|
</nav>
|
|
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item md-nav__item--active md-nav__item--section md-nav__item--nested">
|
|
|
|
|
|
|
|
<input class="md-nav__toggle md-toggle " type="checkbox" id="__nav_3" checked>
|
|
|
|
|
|
<label class="md-nav__link" for="__nav_3" id="__nav_3_label" tabindex="">
|
|
|
|
|
|
<span class="md-ellipsis">
|
|
Databases
|
|
</span>
|
|
|
|
|
|
<span class="md-nav__icon md-icon"></span>
|
|
</label>
|
|
|
|
<nav class="md-nav" data-md-level="1" aria-labelledby="__nav_3_label" aria-expanded="true">
|
|
<label class="md-nav__title" for="__nav_3">
|
|
<span class="md-nav__icon md-icon"></span>
|
|
Databases
|
|
</label>
|
|
<ul class="md-nav__list" data-md-scrollfix>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="redis.html" class="md-nav__link">
|
|
|
|
|
|
<span class="md-ellipsis">
|
|
Redis
|
|
</span>
|
|
|
|
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="sql.html" class="md-nav__link">
|
|
|
|
|
|
<span class="md-ellipsis">
|
|
SQL
|
|
</span>
|
|
|
|
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item md-nav__item--active">
|
|
|
|
<input class="md-nav__toggle md-toggle" type="checkbox" id="__toc">
|
|
|
|
|
|
|
|
|
|
|
|
<label class="md-nav__link md-nav__link--active" for="__toc">
|
|
|
|
|
|
<span class="md-ellipsis">
|
|
MongoDB
|
|
</span>
|
|
|
|
|
|
<span class="md-nav__icon md-icon"></span>
|
|
</label>
|
|
|
|
<a href="mongo-db.html" class="md-nav__link md-nav__link--active">
|
|
|
|
|
|
<span class="md-ellipsis">
|
|
MongoDB
|
|
</span>
|
|
|
|
|
|
</a>
|
|
|
|
|
|
|
|
<nav class="md-nav md-nav--secondary" aria-label="Table of contents">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<label class="md-nav__title" for="__toc">
|
|
<span class="md-nav__icon md-icon"></span>
|
|
Table of contents
|
|
</label>
|
|
<ul class="md-nav__list" data-md-component="toc" data-md-scrollfix>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#data-types" class="md-nav__link">
|
|
<span class="md-ellipsis">
|
|
Data Types
|
|
</span>
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#databases-collections-usage" class="md-nav__link">
|
|
<span class="md-ellipsis">
|
|
Databases & Collections Usage
|
|
</span>
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#operators-mql-syntax" class="md-nav__link">
|
|
<span class="md-ellipsis">
|
|
Operators (MQL Syntax)
|
|
</span>
|
|
</a>
|
|
|
|
<nav class="md-nav" aria-label="Operators (MQL Syntax)">
|
|
<ul class="md-nav__list">
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#expressive-query-operator" class="md-nav__link">
|
|
<span class="md-ellipsis">
|
|
Expressive Query Operator
|
|
</span>
|
|
</a>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
</nav>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#mongo-query-language-mql" class="md-nav__link">
|
|
<span class="md-ellipsis">
|
|
Mongo Query Language (MQL)
|
|
</span>
|
|
</a>
|
|
|
|
<nav class="md-nav" aria-label="Mongo Query Language (MQL)">
|
|
<ul class="md-nav__list">
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#insertion" class="md-nav__link">
|
|
<span class="md-ellipsis">
|
|
Insertion
|
|
</span>
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#querying" class="md-nav__link">
|
|
<span class="md-ellipsis">
|
|
Querying
|
|
</span>
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#updating" class="md-nav__link">
|
|
<span class="md-ellipsis">
|
|
Updating
|
|
</span>
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#deletion" class="md-nav__link">
|
|
<span class="md-ellipsis">
|
|
Deletion
|
|
</span>
|
|
</a>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
</nav>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#mongodb-database-tools" class="md-nav__link">
|
|
<span class="md-ellipsis">
|
|
MongoDB Database Tools
|
|
</span>
|
|
</a>
|
|
|
|
<nav class="md-nav" aria-label="MongoDB Database Tools">
|
|
<ul class="md-nav__list">
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#mongoimport" class="md-nav__link">
|
|
<span class="md-ellipsis">
|
|
Mongoimport
|
|
</span>
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#mongoexport" class="md-nav__link">
|
|
<span class="md-ellipsis">
|
|
Mongoexport
|
|
</span>
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#mongodump-mongorestore" class="md-nav__link">
|
|
<span class="md-ellipsis">
|
|
Mongodump & Mongorestore
|
|
</span>
|
|
</a>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
</nav>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#indexes" class="md-nav__link">
|
|
<span class="md-ellipsis">
|
|
Indexes
|
|
</span>
|
|
</a>
|
|
|
|
<nav class="md-nav" aria-label="Indexes">
|
|
<ul class="md-nav__list">
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#index-types" class="md-nav__link">
|
|
<span class="md-ellipsis">
|
|
Index Types
|
|
</span>
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#diagnosis-and-query-planning" class="md-nav__link">
|
|
<span class="md-ellipsis">
|
|
Diagnosis and query planning
|
|
</span>
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#index-creation" class="md-nav__link">
|
|
<span class="md-ellipsis">
|
|
Index Creation
|
|
</span>
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#index-management" class="md-nav__link">
|
|
<span class="md-ellipsis">
|
|
Index Management
|
|
</span>
|
|
</a>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
</nav>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#cluster-administration" class="md-nav__link">
|
|
<span class="md-ellipsis">
|
|
Cluster Administration
|
|
</span>
|
|
</a>
|
|
|
|
<nav class="md-nav" aria-label="Cluster Administration">
|
|
<ul class="md-nav__list">
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#mongod" class="md-nav__link">
|
|
<span class="md-ellipsis">
|
|
mongod
|
|
</span>
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#basic-shell-helpers" class="md-nav__link">
|
|
<span class="md-ellipsis">
|
|
Basic Shell Helpers
|
|
</span>
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#logging" class="md-nav__link">
|
|
<span class="md-ellipsis">
|
|
Logging
|
|
</span>
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#database-profiling" class="md-nav__link">
|
|
<span class="md-ellipsis">
|
|
Database Profiling
|
|
</span>
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#authentication" class="md-nav__link">
|
|
<span class="md-ellipsis">
|
|
Authentication
|
|
</span>
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#authorization-role-based-access-control-rbac" class="md-nav__link">
|
|
<span class="md-ellipsis">
|
|
Authorization: Role Based Access Control (RBAC)
|
|
</span>
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#replica-set" class="md-nav__link">
|
|
<span class="md-ellipsis">
|
|
Replica set
|
|
</span>
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#sharding" class="md-nav__link">
|
|
<span class="md-ellipsis">
|
|
Sharding
|
|
</span>
|
|
</a>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
</nav>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#aggregation-framework" class="md-nav__link">
|
|
<span class="md-ellipsis">
|
|
Aggregation Framework
|
|
</span>
|
|
</a>
|
|
|
|
<nav class="md-nav" aria-label="Aggregation Framework">
|
|
<ul class="md-nav__list">
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#variables" class="md-nav__link">
|
|
<span class="md-ellipsis">
|
|
Variables
|
|
</span>
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#match-aggregation-stage" class="md-nav__link">
|
|
<span class="md-ellipsis">
|
|
$match Aggregation Stage
|
|
</span>
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#project-aggregation-stage" class="md-nav__link">
|
|
<span class="md-ellipsis">
|
|
$project Aggregation Stage
|
|
</span>
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#addfields-aggregation-stage" class="md-nav__link">
|
|
<span class="md-ellipsis">
|
|
$addFields Aggregation Stage
|
|
</span>
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#group-aggregation-stage" class="md-nav__link">
|
|
<span class="md-ellipsis">
|
|
$group Aggregation Stage
|
|
</span>
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#unwind-aggregation-stage" class="md-nav__link">
|
|
<span class="md-ellipsis">
|
|
$unwind Aggregation Stage
|
|
</span>
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#count-aggregation-stage" class="md-nav__link">
|
|
<span class="md-ellipsis">
|
|
$count Aggregation Stage
|
|
</span>
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#sort-aggregation-stage" class="md-nav__link">
|
|
<span class="md-ellipsis">
|
|
$sort Aggregation Stage
|
|
</span>
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#skip-aggregation-stage" class="md-nav__link">
|
|
<span class="md-ellipsis">
|
|
$skip Aggregation Stage
|
|
</span>
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#limit-aggregation-stage" class="md-nav__link">
|
|
<span class="md-ellipsis">
|
|
$limit Aggregation Stage
|
|
</span>
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#lookup-aggregation-stage" class="md-nav__link">
|
|
<span class="md-ellipsis">
|
|
$lookup Aggregation Stage
|
|
</span>
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#graphlookup-aggregation-stage" class="md-nav__link">
|
|
<span class="md-ellipsis">
|
|
$graphLookup Aggregation Stage
|
|
</span>
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#sortbycount-aggregation-stage" class="md-nav__link">
|
|
<span class="md-ellipsis">
|
|
$sortByCount Aggregation Stage
|
|
</span>
|
|
</a>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
</nav>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</nav>
|
|
|
|
</li>
|
|
|
|
|
|
|
|
|
|
</ul>
|
|
</nav>
|
|
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item md-nav__item--nested">
|
|
|
|
|
|
|
|
<input class="md-nav__toggle md-toggle " type="checkbox" id="__nav_4" >
|
|
|
|
|
|
<label class="md-nav__link" for="__nav_4" id="__nav_4_label" tabindex="0">
|
|
|
|
|
|
<span class="md-ellipsis">
|
|
Languages
|
|
</span>
|
|
|
|
|
|
<span class="md-nav__icon md-icon"></span>
|
|
</label>
|
|
|
|
<nav class="md-nav" data-md-level="1" aria-labelledby="__nav_4_label" aria-expanded="false">
|
|
<label class="md-nav__title" for="__nav_4">
|
|
<span class="md-nav__icon md-icon"></span>
|
|
Languages
|
|
</label>
|
|
<ul class="md-nav__list" data-md-scrollfix>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../languages/html/html.html" class="md-nav__link">
|
|
|
|
|
|
<span class="md-ellipsis">
|
|
HTML
|
|
</span>
|
|
|
|
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../languages/markdown.html" class="md-nav__link">
|
|
|
|
|
|
<span class="md-ellipsis">
|
|
Markdown
|
|
</span>
|
|
|
|
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../languages/css/css.html" class="md-nav__link">
|
|
|
|
|
|
<span class="md-ellipsis">
|
|
CSS
|
|
</span>
|
|
|
|
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../languages/c/c.html" class="md-nav__link">
|
|
|
|
|
|
<span class="md-ellipsis">
|
|
C
|
|
</span>
|
|
|
|
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../languages/kotlin/kotlin.html" class="md-nav__link">
|
|
|
|
|
|
<span class="md-ellipsis">
|
|
Kotlin
|
|
</span>
|
|
|
|
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../languages/swift/swift.html" class="md-nav__link">
|
|
|
|
|
|
<span class="md-ellipsis">
|
|
Swift
|
|
</span>
|
|
|
|
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item md-nav__item--nested">
|
|
|
|
|
|
|
|
<input class="md-nav__toggle md-toggle " type="checkbox" id="__nav_4_7" >
|
|
|
|
|
|
<label class="md-nav__link" for="__nav_4_7" id="__nav_4_7_label" tabindex="0">
|
|
|
|
|
|
<span class="md-ellipsis">
|
|
Assembly
|
|
</span>
|
|
|
|
|
|
<span class="md-nav__icon md-icon"></span>
|
|
</label>
|
|
|
|
<nav class="md-nav" data-md-level="2" aria-labelledby="__nav_4_7_label" aria-expanded="false">
|
|
<label class="md-nav__title" for="__nav_4_7">
|
|
<span class="md-nav__icon md-icon"></span>
|
|
Assembly
|
|
</label>
|
|
<ul class="md-nav__list" data-md-scrollfix>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../languages/assembly/intel.html" class="md-nav__link">
|
|
|
|
|
|
<span class="md-ellipsis">
|
|
Intel
|
|
</span>
|
|
|
|
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../languages/assembly/riscv.html" class="md-nav__link">
|
|
|
|
|
|
<span class="md-ellipsis">
|
|
RISC-V
|
|
</span>
|
|
|
|
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
</ul>
|
|
</nav>
|
|
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item md-nav__item--nested">
|
|
|
|
|
|
|
|
<input class="md-nav__toggle md-toggle " type="checkbox" id="__nav_4_8" >
|
|
|
|
|
|
<label class="md-nav__link" for="__nav_4_8" id="__nav_4_8_label" tabindex="0">
|
|
|
|
|
|
<span class="md-ellipsis">
|
|
Python
|
|
</span>
|
|
|
|
|
|
<span class="md-nav__icon md-icon"></span>
|
|
</label>
|
|
|
|
<nav class="md-nav" data-md-level="2" aria-labelledby="__nav_4_8_label" aria-expanded="false">
|
|
<label class="md-nav__title" for="__nav_4_8">
|
|
<span class="md-nav__icon md-icon"></span>
|
|
Python
|
|
</label>
|
|
<ul class="md-nav__list" data-md-scrollfix>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../languages/python/python.html" class="md-nav__link">
|
|
|
|
|
|
<span class="md-ellipsis">
|
|
Python
|
|
</span>
|
|
|
|
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item md-nav__item--nested">
|
|
|
|
|
|
|
|
<input class="md-nav__toggle md-toggle " type="checkbox" id="__nav_4_8_2" >
|
|
|
|
|
|
<label class="md-nav__link" for="__nav_4_8_2" id="__nav_4_8_2_label" tabindex="0">
|
|
|
|
|
|
<span class="md-ellipsis">
|
|
Modules
|
|
</span>
|
|
|
|
|
|
<span class="md-nav__icon md-icon"></span>
|
|
</label>
|
|
|
|
<nav class="md-nav" data-md-level="3" aria-labelledby="__nav_4_8_2_label" aria-expanded="false">
|
|
<label class="md-nav__title" for="__nav_4_8_2">
|
|
<span class="md-nav__icon md-icon"></span>
|
|
Modules
|
|
</label>
|
|
<ul class="md-nav__list" data-md-scrollfix>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../languages/python/modules/argparse.html" class="md-nav__link">
|
|
|
|
|
|
<span class="md-ellipsis">
|
|
argparse
|
|
</span>
|
|
|
|
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../languages/python/modules/collections.html" class="md-nav__link">
|
|
|
|
|
|
<span class="md-ellipsis">
|
|
collection
|
|
</span>
|
|
|
|
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../languages/python/modules/csv.html" class="md-nav__link">
|
|
|
|
|
|
<span class="md-ellipsis">
|
|
csv
|
|
</span>
|
|
|
|
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../languages/python/modules/ftplib.html" class="md-nav__link">
|
|
|
|
|
|
<span class="md-ellipsis">
|
|
ftplib
|
|
</span>
|
|
|
|
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../languages/python/modules/itertools.html" class="md-nav__link">
|
|
|
|
|
|
<span class="md-ellipsis">
|
|
itertools
|
|
</span>
|
|
|
|
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../languages/python/modules/json.html" class="md-nav__link">
|
|
|
|
|
|
<span class="md-ellipsis">
|
|
json
|
|
</span>
|
|
|
|
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../languages/python/modules/logging.html" class="md-nav__link">
|
|
|
|
|
|
<span class="md-ellipsis">
|
|
logging
|
|
</span>
|
|
|
|
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../languages/python/modules/shutil.html" class="md-nav__link">
|
|
|
|
|
|
<span class="md-ellipsis">
|
|
shutil
|
|
</span>
|
|
|
|
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../languages/python/modules/smtplib.html" class="md-nav__link">
|
|
|
|
|
|
<span class="md-ellipsis">
|
|
smtplib
|
|
</span>
|
|
|
|
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../languages/python/modules/socket.html" class="md-nav__link">
|
|
|
|
|
|
<span class="md-ellipsis">
|
|
socket
|
|
</span>
|
|
|
|
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../languages/python/modules/sqlite.html" class="md-nav__link">
|
|
|
|
|
|
<span class="md-ellipsis">
|
|
sqlite
|
|
</span>
|
|
|
|
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../languages/python/modules/time-datetime.html" class="md-nav__link">
|
|
|
|
|
|
<span class="md-ellipsis">
|
|
time & datetime
|
|
</span>
|
|
|
|
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../languages/python/modules/unittest.html" class="md-nav__link">
|
|
|
|
|
|
<span class="md-ellipsis">
|
|
unittest
|
|
</span>
|
|
|
|
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
</ul>
|
|
</nav>
|
|
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item md-nav__item--nested">
|
|
|
|
|
|
|
|
<input class="md-nav__toggle md-toggle " type="checkbox" id="__nav_4_8_3" >
|
|
|
|
|
|
<label class="md-nav__link" for="__nav_4_8_3" id="__nav_4_8_3_label" tabindex="0">
|
|
|
|
|
|
<span class="md-ellipsis">
|
|
Libraries
|
|
</span>
|
|
|
|
|
|
<span class="md-nav__icon md-icon"></span>
|
|
</label>
|
|
|
|
<nav class="md-nav" data-md-level="3" aria-labelledby="__nav_4_8_3_label" aria-expanded="false">
|
|
<label class="md-nav__title" for="__nav_4_8_3">
|
|
<span class="md-nav__icon md-icon"></span>
|
|
Libraries
|
|
</label>
|
|
<ul class="md-nav__list" data-md-scrollfix>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../languages/python/libs/tkinter.html" class="md-nav__link">
|
|
|
|
|
|
<span class="md-ellipsis">
|
|
TKinter
|
|
</span>
|
|
|
|
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../languages/python/libs/numpy.html" class="md-nav__link">
|
|
|
|
|
|
<span class="md-ellipsis">
|
|
Numpy
|
|
</span>
|
|
|
|
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../languages/python/libs/pandas.html" class="md-nav__link">
|
|
|
|
|
|
<span class="md-ellipsis">
|
|
Pandas
|
|
</span>
|
|
|
|
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../languages/python/libs/seaborn.html" class="md-nav__link">
|
|
|
|
|
|
<span class="md-ellipsis">
|
|
Seaborn
|
|
</span>
|
|
|
|
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../languages/python/libs/requests.html" class="md-nav__link">
|
|
|
|
|
|
<span class="md-ellipsis">
|
|
Requests
|
|
</span>
|
|
|
|
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../languages/python/libs/beautiful-soup.html" class="md-nav__link">
|
|
|
|
|
|
<span class="md-ellipsis">
|
|
Beatiful Soup
|
|
</span>
|
|
|
|
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
</ul>
|
|
</nav>
|
|
|
|
</li>
|
|
|
|
|
|
|
|
|
|
</ul>
|
|
</nav>
|
|
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item md-nav__item--nested">
|
|
|
|
|
|
|
|
<input class="md-nav__toggle md-toggle " type="checkbox" id="__nav_4_9" >
|
|
|
|
|
|
<label class="md-nav__link" for="__nav_4_9" id="__nav_4_9_label" tabindex="0">
|
|
|
|
|
|
<span class="md-ellipsis">
|
|
.NET
|
|
</span>
|
|
|
|
|
|
<span class="md-nav__icon md-icon"></span>
|
|
</label>
|
|
|
|
<nav class="md-nav" data-md-level="2" aria-labelledby="__nav_4_9_label" aria-expanded="false">
|
|
<label class="md-nav__title" for="__nav_4_9">
|
|
<span class="md-nav__icon md-icon"></span>
|
|
.NET
|
|
</label>
|
|
<ul class="md-nav__list" data-md-scrollfix>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item md-nav__item--nested">
|
|
|
|
|
|
|
|
<input class="md-nav__toggle md-toggle " type="checkbox" id="__nav_4_9_1" >
|
|
|
|
|
|
<label class="md-nav__link" for="__nav_4_9_1" id="__nav_4_9_1_label" tabindex="0">
|
|
|
|
|
|
<span class="md-ellipsis">
|
|
C#
|
|
</span>
|
|
|
|
|
|
<span class="md-nav__icon md-icon"></span>
|
|
</label>
|
|
|
|
<nav class="md-nav" data-md-level="3" aria-labelledby="__nav_4_9_1_label" aria-expanded="false">
|
|
<label class="md-nav__title" for="__nav_4_9_1">
|
|
<span class="md-nav__icon md-icon"></span>
|
|
C#
|
|
</label>
|
|
<ul class="md-nav__list" data-md-scrollfix>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../languages/dotnet/csharp/csharp.html" class="md-nav__link">
|
|
|
|
|
|
<span class="md-ellipsis">
|
|
C#
|
|
</span>
|
|
|
|
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../languages/dotnet/csharp/linq.html" class="md-nav__link">
|
|
|
|
|
|
<span class="md-ellipsis">
|
|
Linq
|
|
</span>
|
|
|
|
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../languages/dotnet/csharp/collections.html" class="md-nav__link">
|
|
|
|
|
|
<span class="md-ellipsis">
|
|
Collections
|
|
</span>
|
|
|
|
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../languages/dotnet/csharp/reactive-extensions.html" class="md-nav__link">
|
|
|
|
|
|
<span class="md-ellipsis">
|
|
Reactive Extensions
|
|
</span>
|
|
|
|
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../languages/dotnet/csharp/async-programming.html" class="md-nav__link">
|
|
|
|
|
|
<span class="md-ellipsis">
|
|
Async Programming
|
|
</span>
|
|
|
|
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../languages/dotnet/csharp/unit-tests.html" class="md-nav__link">
|
|
|
|
|
|
<span class="md-ellipsis">
|
|
Unit Tests
|
|
</span>
|
|
|
|
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
</ul>
|
|
</nav>
|
|
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item md-nav__item--nested">
|
|
|
|
|
|
|
|
<input class="md-nav__toggle md-toggle " type="checkbox" id="__nav_4_9_2" >
|
|
|
|
|
|
<label class="md-nav__link" for="__nav_4_9_2" id="__nav_4_9_2_label" tabindex="0">
|
|
|
|
|
|
<span class="md-ellipsis">
|
|
ASP.NET
|
|
</span>
|
|
|
|
|
|
<span class="md-nav__icon md-icon"></span>
|
|
</label>
|
|
|
|
<nav class="md-nav" data-md-level="3" aria-labelledby="__nav_4_9_2_label" aria-expanded="false">
|
|
<label class="md-nav__title" for="__nav_4_9_2">
|
|
<span class="md-nav__icon md-icon"></span>
|
|
ASP.NET
|
|
</label>
|
|
<ul class="md-nav__list" data-md-scrollfix>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../languages/dotnet/asp.net/minimal-api.html" class="md-nav__link">
|
|
|
|
|
|
<span class="md-ellipsis">
|
|
Minimal API
|
|
</span>
|
|
|
|
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../languages/dotnet/asp.net/filters.html" class="md-nav__link">
|
|
|
|
|
|
<span class="md-ellipsis">
|
|
FIlters
|
|
</span>
|
|
|
|
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../languages/dotnet/asp.net/middleware.html" class="md-nav__link">
|
|
|
|
|
|
<span class="md-ellipsis">
|
|
Middleware
|
|
</span>
|
|
|
|
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../languages/dotnet/asp.net/razor-syntax.html" class="md-nav__link">
|
|
|
|
|
|
<span class="md-ellipsis">
|
|
Razor Syntax
|
|
</span>
|
|
|
|
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../languages/dotnet/asp.net/blazor.html" class="md-nav__link">
|
|
|
|
|
|
<span class="md-ellipsis">
|
|
Blazor
|
|
</span>
|
|
|
|
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../languages/dotnet/asp.net/signalr.html" class="md-nav__link">
|
|
|
|
|
|
<span class="md-ellipsis">
|
|
SignalR
|
|
</span>
|
|
|
|
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../languages/dotnet/asp.net/web-forms.html" class="md-nav__link">
|
|
|
|
|
|
<span class="md-ellipsis">
|
|
Web Forms
|
|
</span>
|
|
|
|
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
</ul>
|
|
</nav>
|
|
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item md-nav__item--nested">
|
|
|
|
|
|
|
|
<input class="md-nav__toggle md-toggle " type="checkbox" id="__nav_4_9_3" >
|
|
|
|
|
|
<label class="md-nav__link" for="__nav_4_9_3" id="__nav_4_9_3_label" tabindex="0">
|
|
|
|
|
|
<span class="md-ellipsis">
|
|
Database
|
|
</span>
|
|
|
|
|
|
<span class="md-nav__icon md-icon"></span>
|
|
</label>
|
|
|
|
<nav class="md-nav" data-md-level="3" aria-labelledby="__nav_4_9_3_label" aria-expanded="false">
|
|
<label class="md-nav__title" for="__nav_4_9_3">
|
|
<span class="md-nav__icon md-icon"></span>
|
|
Database
|
|
</label>
|
|
<ul class="md-nav__list" data-md-scrollfix>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../languages/dotnet/database/ado.net.html" class="md-nav__link">
|
|
|
|
|
|
<span class="md-ellipsis">
|
|
ADO.NET
|
|
</span>
|
|
|
|
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../languages/dotnet/database/entity-framework.html" class="md-nav__link">
|
|
|
|
|
|
<span class="md-ellipsis">
|
|
Entity Framework
|
|
</span>
|
|
|
|
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
</ul>
|
|
</nav>
|
|
|
|
</li>
|
|
|
|
|
|
|
|
|
|
</ul>
|
|
</nav>
|
|
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item md-nav__item--nested">
|
|
|
|
|
|
|
|
<input class="md-nav__toggle md-toggle " type="checkbox" id="__nav_4_10" >
|
|
|
|
|
|
<label class="md-nav__link" for="__nav_4_10" id="__nav_4_10_label" tabindex="0">
|
|
|
|
|
|
<span class="md-ellipsis">
|
|
Java
|
|
</span>
|
|
|
|
|
|
<span class="md-nav__icon md-icon"></span>
|
|
</label>
|
|
|
|
<nav class="md-nav" data-md-level="2" aria-labelledby="__nav_4_10_label" aria-expanded="false">
|
|
<label class="md-nav__title" for="__nav_4_10">
|
|
<span class="md-nav__icon md-icon"></span>
|
|
Java
|
|
</label>
|
|
<ul class="md-nav__list" data-md-scrollfix>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../languages/java/java.html" class="md-nav__link">
|
|
|
|
|
|
<span class="md-ellipsis">
|
|
Java
|
|
</span>
|
|
|
|
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../languages/java/java-collection-framework.html" class="md-nav__link">
|
|
|
|
|
|
<span class="md-ellipsis">
|
|
Java Collection Framework
|
|
</span>
|
|
|
|
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../languages/java/dao.html" class="md-nav__link">
|
|
|
|
|
|
<span class="md-ellipsis">
|
|
DAO
|
|
</span>
|
|
|
|
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item md-nav__item--nested">
|
|
|
|
|
|
|
|
<input class="md-nav__toggle md-toggle " type="checkbox" id="__nav_4_10_4" >
|
|
|
|
|
|
<label class="md-nav__link" for="__nav_4_10_4" id="__nav_4_10_4_label" tabindex="0">
|
|
|
|
|
|
<span class="md-ellipsis">
|
|
Web
|
|
</span>
|
|
|
|
|
|
<span class="md-nav__icon md-icon"></span>
|
|
</label>
|
|
|
|
<nav class="md-nav" data-md-level="3" aria-labelledby="__nav_4_10_4_label" aria-expanded="false">
|
|
<label class="md-nav__title" for="__nav_4_10_4">
|
|
<span class="md-nav__icon md-icon"></span>
|
|
Web
|
|
</label>
|
|
<ul class="md-nav__list" data-md-scrollfix>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../languages/java/web/servlet.html" class="md-nav__link">
|
|
|
|
|
|
<span class="md-ellipsis">
|
|
Serverlet
|
|
</span>
|
|
|
|
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item md-nav__item--nested">
|
|
|
|
|
|
|
|
<input class="md-nav__toggle md-toggle " type="checkbox" id="__nav_4_10_4_2" >
|
|
|
|
|
|
<label class="md-nav__link" for="__nav_4_10_4_2" id="__nav_4_10_4_2_label" tabindex="0">
|
|
|
|
|
|
<span class="md-ellipsis">
|
|
Spring
|
|
</span>
|
|
|
|
|
|
<span class="md-nav__icon md-icon"></span>
|
|
</label>
|
|
|
|
<nav class="md-nav" data-md-level="4" aria-labelledby="__nav_4_10_4_2_label" aria-expanded="false">
|
|
<label class="md-nav__title" for="__nav_4_10_4_2">
|
|
<span class="md-nav__icon md-icon"></span>
|
|
Spring
|
|
</label>
|
|
<ul class="md-nav__list" data-md-scrollfix>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../languages/java/spring/pom.xml.html" class="md-nav__link">
|
|
|
|
|
|
<span class="md-ellipsis">
|
|
POM
|
|
</span>
|
|
|
|
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../languages/java/spring/spring-project.html" class="md-nav__link">
|
|
|
|
|
|
<span class="md-ellipsis">
|
|
Project Structure
|
|
</span>
|
|
|
|
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
</ul>
|
|
</nav>
|
|
|
|
</li>
|
|
|
|
|
|
|
|
|
|
</ul>
|
|
</nav>
|
|
|
|
</li>
|
|
|
|
|
|
|
|
|
|
</ul>
|
|
</nav>
|
|
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item md-nav__item--nested">
|
|
|
|
|
|
|
|
<input class="md-nav__toggle md-toggle " type="checkbox" id="__nav_4_11" >
|
|
|
|
|
|
<label class="md-nav__link" for="__nav_4_11" id="__nav_4_11_label" tabindex="0">
|
|
|
|
|
|
<span class="md-ellipsis">
|
|
PHP
|
|
</span>
|
|
|
|
|
|
<span class="md-nav__icon md-icon"></span>
|
|
</label>
|
|
|
|
<nav class="md-nav" data-md-level="2" aria-labelledby="__nav_4_11_label" aria-expanded="false">
|
|
<label class="md-nav__title" for="__nav_4_11">
|
|
<span class="md-nav__icon md-icon"></span>
|
|
PHP
|
|
</label>
|
|
<ul class="md-nav__list" data-md-scrollfix>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../languages/php/php.html" class="md-nav__link">
|
|
|
|
|
|
<span class="md-ellipsis">
|
|
PHP
|
|
</span>
|
|
|
|
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../languages/php/database.html" class="md-nav__link">
|
|
|
|
|
|
<span class="md-ellipsis">
|
|
Database
|
|
</span>
|
|
|
|
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../languages/php/web.html" class="md-nav__link">
|
|
|
|
|
|
<span class="md-ellipsis">
|
|
Web
|
|
</span>
|
|
|
|
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../languages/php/dependency-injection.html" class="md-nav__link">
|
|
|
|
|
|
<span class="md-ellipsis">
|
|
Dependency Injection
|
|
</span>
|
|
|
|
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../languages/php/unit-tests.html" class="md-nav__link">
|
|
|
|
|
|
<span class="md-ellipsis">
|
|
Unit Tests
|
|
</span>
|
|
|
|
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../languages/php/composer.html" class="md-nav__link">
|
|
|
|
|
|
<span class="md-ellipsis">
|
|
Composer
|
|
</span>
|
|
|
|
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../languages/php/psr-7.html" class="md-nav__link">
|
|
|
|
|
|
<span class="md-ellipsis">
|
|
PSR 7
|
|
</span>
|
|
|
|
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../languages/php/plates-templating.html" class="md-nav__link">
|
|
|
|
|
|
<span class="md-ellipsis">
|
|
Plates
|
|
</span>
|
|
|
|
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item md-nav__item--nested">
|
|
|
|
|
|
|
|
<input class="md-nav__toggle md-toggle " type="checkbox" id="__nav_4_11_9" >
|
|
|
|
|
|
<label class="md-nav__link" for="__nav_4_11_9" id="__nav_4_11_9_label" tabindex="0">
|
|
|
|
|
|
<span class="md-ellipsis">
|
|
Simple MVC
|
|
</span>
|
|
|
|
|
|
<span class="md-nav__icon md-icon"></span>
|
|
</label>
|
|
|
|
<nav class="md-nav" data-md-level="3" aria-labelledby="__nav_4_11_9_label" aria-expanded="false">
|
|
<label class="md-nav__title" for="__nav_4_11_9">
|
|
<span class="md-nav__icon md-icon"></span>
|
|
Simple MVC
|
|
</label>
|
|
<ul class="md-nav__list" data-md-scrollfix>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../languages/php/simple-mvc/simple-mvc.html" class="md-nav__link">
|
|
|
|
|
|
<span class="md-ellipsis">
|
|
Simple MVC
|
|
</span>
|
|
|
|
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../languages/php/simple-mvc/rest-api.html" class="md-nav__link">
|
|
|
|
|
|
<span class="md-ellipsis">
|
|
REST API
|
|
</span>
|
|
|
|
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
</ul>
|
|
</nav>
|
|
|
|
</li>
|
|
|
|
|
|
|
|
|
|
</ul>
|
|
</nav>
|
|
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item md-nav__item--nested">
|
|
|
|
|
|
|
|
<input class="md-nav__toggle md-toggle " type="checkbox" id="__nav_4_12" >
|
|
|
|
|
|
<label class="md-nav__link" for="__nav_4_12" id="__nav_4_12_label" tabindex="0">
|
|
|
|
|
|
<span class="md-ellipsis">
|
|
Rust
|
|
</span>
|
|
|
|
|
|
<span class="md-nav__icon md-icon"></span>
|
|
</label>
|
|
|
|
<nav class="md-nav" data-md-level="2" aria-labelledby="__nav_4_12_label" aria-expanded="false">
|
|
<label class="md-nav__title" for="__nav_4_12">
|
|
<span class="md-nav__icon md-icon"></span>
|
|
Rust
|
|
</label>
|
|
<ul class="md-nav__list" data-md-scrollfix>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../languages/rust/rust.html" class="md-nav__link">
|
|
|
|
|
|
<span class="md-ellipsis">
|
|
Rust
|
|
</span>
|
|
|
|
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../languages/rust/macros.html" class="md-nav__link">
|
|
|
|
|
|
<span class="md-ellipsis">
|
|
Macros
|
|
</span>
|
|
|
|
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../languages/rust/cargo.html" class="md-nav__link">
|
|
|
|
|
|
<span class="md-ellipsis">
|
|
Cargo
|
|
</span>
|
|
|
|
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../languages/rust/concurrency.html" class="md-nav__link">
|
|
|
|
|
|
<span class="md-ellipsis">
|
|
Concurrency
|
|
</span>
|
|
|
|
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../languages/rust/unit-tests.html" class="md-nav__link">
|
|
|
|
|
|
<span class="md-ellipsis">
|
|
Unit Tests
|
|
</span>
|
|
|
|
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
</ul>
|
|
</nav>
|
|
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item md-nav__item--nested">
|
|
|
|
|
|
|
|
<input class="md-nav__toggle md-toggle " type="checkbox" id="__nav_4_13" >
|
|
|
|
|
|
<label class="md-nav__link" for="__nav_4_13" id="__nav_4_13_label" tabindex="0">
|
|
|
|
|
|
<span class="md-ellipsis">
|
|
Javascript
|
|
</span>
|
|
|
|
|
|
<span class="md-nav__icon md-icon"></span>
|
|
</label>
|
|
|
|
<nav class="md-nav" data-md-level="2" aria-labelledby="__nav_4_13_label" aria-expanded="false">
|
|
<label class="md-nav__title" for="__nav_4_13">
|
|
<span class="md-nav__icon md-icon"></span>
|
|
Javascript
|
|
</label>
|
|
<ul class="md-nav__list" data-md-scrollfix>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../languages/javascript/javascript.html" class="md-nav__link">
|
|
|
|
|
|
<span class="md-ellipsis">
|
|
Javascript
|
|
</span>
|
|
|
|
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../languages/javascript/dom.html" class="md-nav__link">
|
|
|
|
|
|
<span class="md-ellipsis">
|
|
DOM
|
|
</span>
|
|
|
|
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../languages/javascript/events-animation.html" class="md-nav__link">
|
|
|
|
|
|
<span class="md-ellipsis">
|
|
Events & Animation
|
|
</span>
|
|
|
|
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../languages/javascript/ajax.html" class="md-nav__link">
|
|
|
|
|
|
<span class="md-ellipsis">
|
|
AJAX
|
|
</span>
|
|
|
|
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../languages/javascript/jquery.html" class="md-nav__link">
|
|
|
|
|
|
<span class="md-ellipsis">
|
|
jQuery
|
|
</span>
|
|
|
|
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item md-nav__item--nested">
|
|
|
|
|
|
|
|
<input class="md-nav__toggle md-toggle " type="checkbox" id="__nav_4_13_6" >
|
|
|
|
|
|
<label class="md-nav__link" for="__nav_4_13_6" id="__nav_4_13_6_label" tabindex="0">
|
|
|
|
|
|
<span class="md-ellipsis">
|
|
React
|
|
</span>
|
|
|
|
|
|
<span class="md-nav__icon md-icon"></span>
|
|
</label>
|
|
|
|
<nav class="md-nav" data-md-level="3" aria-labelledby="__nav_4_13_6_label" aria-expanded="false">
|
|
<label class="md-nav__title" for="__nav_4_13_6">
|
|
<span class="md-nav__icon md-icon"></span>
|
|
React
|
|
</label>
|
|
<ul class="md-nav__list" data-md-scrollfix>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../languages/javascript/react/react.html" class="md-nav__link">
|
|
|
|
|
|
<span class="md-ellipsis">
|
|
React
|
|
</span>
|
|
|
|
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../languages/javascript/react/react-router.html" class="md-nav__link">
|
|
|
|
|
|
<span class="md-ellipsis">
|
|
React Router
|
|
</span>
|
|
|
|
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../languages/javascript/react/react-tests.html" class="md-nav__link">
|
|
|
|
|
|
<span class="md-ellipsis">
|
|
React Tests
|
|
</span>
|
|
|
|
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../languages/javascript/react/redux.html" class="md-nav__link">
|
|
|
|
|
|
<span class="md-ellipsis">
|
|
Redux
|
|
</span>
|
|
|
|
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../languages/javascript/react/redux-tests.html" class="md-nav__link">
|
|
|
|
|
|
<span class="md-ellipsis">
|
|
Redux Tests
|
|
</span>
|
|
|
|
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
</ul>
|
|
</nav>
|
|
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../languages/javascript/svelte/svelte.html" class="md-nav__link">
|
|
|
|
|
|
<span class="md-ellipsis">
|
|
Svelte
|
|
</span>
|
|
|
|
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
</ul>
|
|
</nav>
|
|
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item md-nav__item--nested">
|
|
|
|
|
|
|
|
<input class="md-nav__toggle md-toggle " type="checkbox" id="__nav_4_14" >
|
|
|
|
|
|
<label class="md-nav__link" for="__nav_4_14" id="__nav_4_14_label" tabindex="0">
|
|
|
|
|
|
<span class="md-ellipsis">
|
|
PowerShell
|
|
</span>
|
|
|
|
|
|
<span class="md-nav__icon md-icon"></span>
|
|
</label>
|
|
|
|
<nav class="md-nav" data-md-level="2" aria-labelledby="__nav_4_14_label" aria-expanded="false">
|
|
<label class="md-nav__title" for="__nav_4_14">
|
|
<span class="md-nav__icon md-icon"></span>
|
|
PowerShell
|
|
</label>
|
|
<ul class="md-nav__list" data-md-scrollfix>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../languages/powershell/scripting.html" class="md-nav__link">
|
|
|
|
|
|
<span class="md-ellipsis">
|
|
Scripting
|
|
</span>
|
|
|
|
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../languages/powershell/commands.html" class="md-nav__link">
|
|
|
|
|
|
<span class="md-ellipsis">
|
|
Commands
|
|
</span>
|
|
|
|
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
</ul>
|
|
</nav>
|
|
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item md-nav__item--nested">
|
|
|
|
|
|
|
|
<input class="md-nav__toggle md-toggle " type="checkbox" id="__nav_4_15" >
|
|
|
|
|
|
<label class="md-nav__link" for="__nav_4_15" id="__nav_4_15_label" tabindex="0">
|
|
|
|
|
|
<span class="md-ellipsis">
|
|
Bash
|
|
</span>
|
|
|
|
|
|
<span class="md-nav__icon md-icon"></span>
|
|
</label>
|
|
|
|
<nav class="md-nav" data-md-level="2" aria-labelledby="__nav_4_15_label" aria-expanded="false">
|
|
<label class="md-nav__title" for="__nav_4_15">
|
|
<span class="md-nav__icon md-icon"></span>
|
|
Bash
|
|
</label>
|
|
<ul class="md-nav__list" data-md-scrollfix>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../languages/bash/scripting.html" class="md-nav__link">
|
|
|
|
|
|
<span class="md-ellipsis">
|
|
Scripting
|
|
</span>
|
|
|
|
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../languages/bash/commands.html" class="md-nav__link">
|
|
|
|
|
|
<span class="md-ellipsis">
|
|
Commands
|
|
</span>
|
|
|
|
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
</ul>
|
|
</nav>
|
|
|
|
</li>
|
|
|
|
|
|
|
|
|
|
</ul>
|
|
</nav>
|
|
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item md-nav__item--nested">
|
|
|
|
|
|
|
|
<input class="md-nav__toggle md-toggle " type="checkbox" id="__nav_5" >
|
|
|
|
|
|
<label class="md-nav__link" for="__nav_5" id="__nav_5_label" tabindex="0">
|
|
|
|
|
|
<span class="md-ellipsis">
|
|
Misc
|
|
</span>
|
|
|
|
|
|
<span class="md-nav__icon md-icon"></span>
|
|
</label>
|
|
|
|
<nav class="md-nav" data-md-level="1" aria-labelledby="__nav_5_label" aria-expanded="false">
|
|
<label class="md-nav__title" for="__nav_5">
|
|
<span class="md-nav__icon md-icon"></span>
|
|
Misc
|
|
</label>
|
|
<ul class="md-nav__list" data-md-scrollfix>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../misc/git.html" class="md-nav__link">
|
|
|
|
|
|
<span class="md-ellipsis">
|
|
Git
|
|
</span>
|
|
|
|
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../misc/graph-ql.html" class="md-nav__link">
|
|
|
|
|
|
<span class="md-ellipsis">
|
|
GraphQL
|
|
</span>
|
|
|
|
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../misc/regular-expressions.html" class="md-nav__link">
|
|
|
|
|
|
<span class="md-ellipsis">
|
|
RegEx
|
|
</span>
|
|
|
|
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../misc/ssh.html" class="md-nav__link">
|
|
|
|
|
|
<span class="md-ellipsis">
|
|
SSH
|
|
</span>
|
|
|
|
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../misc/web-components.html" class="md-nav__link">
|
|
|
|
|
|
<span class="md-ellipsis">
|
|
WebComponents
|
|
</span>
|
|
|
|
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
</ul>
|
|
</nav>
|
|
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item md-nav__item--nested">
|
|
|
|
|
|
|
|
<input class="md-nav__toggle md-toggle " type="checkbox" id="__nav_6" >
|
|
|
|
|
|
<label class="md-nav__link" for="__nav_6" id="__nav_6_label" tabindex="0">
|
|
|
|
|
|
<span class="md-ellipsis">
|
|
Linux
|
|
</span>
|
|
|
|
|
|
<span class="md-nav__icon md-icon"></span>
|
|
</label>
|
|
|
|
<nav class="md-nav" data-md-level="1" aria-labelledby="__nav_6_label" aria-expanded="false">
|
|
<label class="md-nav__title" for="__nav_6">
|
|
<span class="md-nav__icon md-icon"></span>
|
|
Linux
|
|
</label>
|
|
<ul class="md-nav__list" data-md-scrollfix>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item md-nav__item--nested">
|
|
|
|
|
|
|
|
<input class="md-nav__toggle md-toggle " type="checkbox" id="__nav_6_1" >
|
|
|
|
|
|
<label class="md-nav__link" for="__nav_6_1" id="__nav_6_1_label" tabindex="0">
|
|
|
|
|
|
<span class="md-ellipsis">
|
|
Filesystem
|
|
</span>
|
|
|
|
|
|
<span class="md-nav__icon md-icon"></span>
|
|
</label>
|
|
|
|
<nav class="md-nav" data-md-level="2" aria-labelledby="__nav_6_1_label" aria-expanded="false">
|
|
<label class="md-nav__title" for="__nav_6_1">
|
|
<span class="md-nav__icon md-icon"></span>
|
|
Filesystem
|
|
</label>
|
|
<ul class="md-nav__list" data-md-scrollfix>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../linux/filesystem/file-links.html" class="md-nav__link">
|
|
|
|
|
|
<span class="md-ellipsis">
|
|
File Links
|
|
</span>
|
|
|
|
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../linux/filesystem/procfs.html" class="md-nav__link">
|
|
|
|
|
|
<span class="md-ellipsis">
|
|
/proc
|
|
</span>
|
|
|
|
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../linux/filesystem/sysfs.html" class="md-nav__link">
|
|
|
|
|
|
<span class="md-ellipsis">
|
|
/sys
|
|
</span>
|
|
|
|
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
</ul>
|
|
</nav>
|
|
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item md-nav__item--nested">
|
|
|
|
|
|
|
|
<input class="md-nav__toggle md-toggle " type="checkbox" id="__nav_6_2" >
|
|
|
|
|
|
<label class="md-nav__link" for="__nav_6_2" id="__nav_6_2_label" tabindex="0">
|
|
|
|
|
|
<span class="md-ellipsis">
|
|
System Init
|
|
</span>
|
|
|
|
|
|
<span class="md-nav__icon md-icon"></span>
|
|
</label>
|
|
|
|
<nav class="md-nav" data-md-level="2" aria-labelledby="__nav_6_2_label" aria-expanded="false">
|
|
<label class="md-nav__title" for="__nav_6_2">
|
|
<span class="md-nav__icon md-icon"></span>
|
|
System Init
|
|
</label>
|
|
<ul class="md-nav__list" data-md-scrollfix>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../linux/init/systemd.html" class="md-nav__link">
|
|
|
|
|
|
<span class="md-ellipsis">
|
|
Systemd
|
|
</span>
|
|
|
|
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../linux/init/open-rc.html" class="md-nav__link">
|
|
|
|
|
|
<span class="md-ellipsis">
|
|
OpenRC
|
|
</span>
|
|
|
|
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
</ul>
|
|
</nav>
|
|
|
|
</li>
|
|
|
|
|
|
|
|
|
|
</ul>
|
|
</nav>
|
|
|
|
</li>
|
|
|
|
|
|
|
|
</ul>
|
|
</nav>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
|
<div class="md-sidebar md-sidebar--secondary" data-md-component="sidebar" data-md-type="toc" >
|
|
<div class="md-sidebar__scrollwrap">
|
|
<div class="md-sidebar__inner">
|
|
|
|
|
|
<nav class="md-nav md-nav--secondary" aria-label="Table of contents">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<label class="md-nav__title" for="__toc">
|
|
<span class="md-nav__icon md-icon"></span>
|
|
Table of contents
|
|
</label>
|
|
<ul class="md-nav__list" data-md-component="toc" data-md-scrollfix>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#data-types" class="md-nav__link">
|
|
<span class="md-ellipsis">
|
|
Data Types
|
|
</span>
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#databases-collections-usage" class="md-nav__link">
|
|
<span class="md-ellipsis">
|
|
Databases & Collections Usage
|
|
</span>
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#operators-mql-syntax" class="md-nav__link">
|
|
<span class="md-ellipsis">
|
|
Operators (MQL Syntax)
|
|
</span>
|
|
</a>
|
|
|
|
<nav class="md-nav" aria-label="Operators (MQL Syntax)">
|
|
<ul class="md-nav__list">
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#expressive-query-operator" class="md-nav__link">
|
|
<span class="md-ellipsis">
|
|
Expressive Query Operator
|
|
</span>
|
|
</a>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
</nav>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#mongo-query-language-mql" class="md-nav__link">
|
|
<span class="md-ellipsis">
|
|
Mongo Query Language (MQL)
|
|
</span>
|
|
</a>
|
|
|
|
<nav class="md-nav" aria-label="Mongo Query Language (MQL)">
|
|
<ul class="md-nav__list">
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#insertion" class="md-nav__link">
|
|
<span class="md-ellipsis">
|
|
Insertion
|
|
</span>
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#querying" class="md-nav__link">
|
|
<span class="md-ellipsis">
|
|
Querying
|
|
</span>
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#updating" class="md-nav__link">
|
|
<span class="md-ellipsis">
|
|
Updating
|
|
</span>
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#deletion" class="md-nav__link">
|
|
<span class="md-ellipsis">
|
|
Deletion
|
|
</span>
|
|
</a>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
</nav>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#mongodb-database-tools" class="md-nav__link">
|
|
<span class="md-ellipsis">
|
|
MongoDB Database Tools
|
|
</span>
|
|
</a>
|
|
|
|
<nav class="md-nav" aria-label="MongoDB Database Tools">
|
|
<ul class="md-nav__list">
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#mongoimport" class="md-nav__link">
|
|
<span class="md-ellipsis">
|
|
Mongoimport
|
|
</span>
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#mongoexport" class="md-nav__link">
|
|
<span class="md-ellipsis">
|
|
Mongoexport
|
|
</span>
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#mongodump-mongorestore" class="md-nav__link">
|
|
<span class="md-ellipsis">
|
|
Mongodump & Mongorestore
|
|
</span>
|
|
</a>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
</nav>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#indexes" class="md-nav__link">
|
|
<span class="md-ellipsis">
|
|
Indexes
|
|
</span>
|
|
</a>
|
|
|
|
<nav class="md-nav" aria-label="Indexes">
|
|
<ul class="md-nav__list">
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#index-types" class="md-nav__link">
|
|
<span class="md-ellipsis">
|
|
Index Types
|
|
</span>
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#diagnosis-and-query-planning" class="md-nav__link">
|
|
<span class="md-ellipsis">
|
|
Diagnosis and query planning
|
|
</span>
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#index-creation" class="md-nav__link">
|
|
<span class="md-ellipsis">
|
|
Index Creation
|
|
</span>
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#index-management" class="md-nav__link">
|
|
<span class="md-ellipsis">
|
|
Index Management
|
|
</span>
|
|
</a>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
</nav>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#cluster-administration" class="md-nav__link">
|
|
<span class="md-ellipsis">
|
|
Cluster Administration
|
|
</span>
|
|
</a>
|
|
|
|
<nav class="md-nav" aria-label="Cluster Administration">
|
|
<ul class="md-nav__list">
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#mongod" class="md-nav__link">
|
|
<span class="md-ellipsis">
|
|
mongod
|
|
</span>
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#basic-shell-helpers" class="md-nav__link">
|
|
<span class="md-ellipsis">
|
|
Basic Shell Helpers
|
|
</span>
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#logging" class="md-nav__link">
|
|
<span class="md-ellipsis">
|
|
Logging
|
|
</span>
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#database-profiling" class="md-nav__link">
|
|
<span class="md-ellipsis">
|
|
Database Profiling
|
|
</span>
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#authentication" class="md-nav__link">
|
|
<span class="md-ellipsis">
|
|
Authentication
|
|
</span>
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#authorization-role-based-access-control-rbac" class="md-nav__link">
|
|
<span class="md-ellipsis">
|
|
Authorization: Role Based Access Control (RBAC)
|
|
</span>
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#replica-set" class="md-nav__link">
|
|
<span class="md-ellipsis">
|
|
Replica set
|
|
</span>
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#sharding" class="md-nav__link">
|
|
<span class="md-ellipsis">
|
|
Sharding
|
|
</span>
|
|
</a>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
</nav>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#aggregation-framework" class="md-nav__link">
|
|
<span class="md-ellipsis">
|
|
Aggregation Framework
|
|
</span>
|
|
</a>
|
|
|
|
<nav class="md-nav" aria-label="Aggregation Framework">
|
|
<ul class="md-nav__list">
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#variables" class="md-nav__link">
|
|
<span class="md-ellipsis">
|
|
Variables
|
|
</span>
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#match-aggregation-stage" class="md-nav__link">
|
|
<span class="md-ellipsis">
|
|
$match Aggregation Stage
|
|
</span>
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#project-aggregation-stage" class="md-nav__link">
|
|
<span class="md-ellipsis">
|
|
$project Aggregation Stage
|
|
</span>
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#addfields-aggregation-stage" class="md-nav__link">
|
|
<span class="md-ellipsis">
|
|
$addFields Aggregation Stage
|
|
</span>
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#group-aggregation-stage" class="md-nav__link">
|
|
<span class="md-ellipsis">
|
|
$group Aggregation Stage
|
|
</span>
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#unwind-aggregation-stage" class="md-nav__link">
|
|
<span class="md-ellipsis">
|
|
$unwind Aggregation Stage
|
|
</span>
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#count-aggregation-stage" class="md-nav__link">
|
|
<span class="md-ellipsis">
|
|
$count Aggregation Stage
|
|
</span>
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#sort-aggregation-stage" class="md-nav__link">
|
|
<span class="md-ellipsis">
|
|
$sort Aggregation Stage
|
|
</span>
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#skip-aggregation-stage" class="md-nav__link">
|
|
<span class="md-ellipsis">
|
|
$skip Aggregation Stage
|
|
</span>
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#limit-aggregation-stage" class="md-nav__link">
|
|
<span class="md-ellipsis">
|
|
$limit Aggregation Stage
|
|
</span>
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#lookup-aggregation-stage" class="md-nav__link">
|
|
<span class="md-ellipsis">
|
|
$lookup Aggregation Stage
|
|
</span>
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#graphlookup-aggregation-stage" class="md-nav__link">
|
|
<span class="md-ellipsis">
|
|
$graphLookup Aggregation Stage
|
|
</span>
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#sortbycount-aggregation-stage" class="md-nav__link">
|
|
<span class="md-ellipsis">
|
|
$sortByCount Aggregation Stage
|
|
</span>
|
|
</a>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
</nav>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</nav>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
|
<div class="md-content" data-md-component="content">
|
|
<article class="md-content__inner md-typeset">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<h1 id="mongodb">MongoDB</h1>
|
|
<p>The database is a container of <strong>collections</strong>. The collections are containers of <strong>documents</strong>.</p>
|
|
<p>The documents are <em>schema-less</em> that is they have a dynamic structure that can change between documents in the same collection.</p>
|
|
<h2 id="data-types">Data Types</h2>
|
|
<table>
|
|
<thead>
|
|
<tr>
|
|
<th>Type</th>
|
|
<th>Example Value</th>
|
|
<th>Function</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<tr>
|
|
<td>Text</td>
|
|
<td><code>"Text"</code></td>
|
|
<td></td>
|
|
</tr>
|
|
<tr>
|
|
<td>Boolean</td>
|
|
<td><code>true</code></td>
|
|
<td></td>
|
|
</tr>
|
|
<tr>
|
|
<td>Number</td>
|
|
<td><code>42</code></td>
|
|
<td></td>
|
|
</tr>
|
|
<tr>
|
|
<td>Objectid</td>
|
|
<td><code>"_id": {"$oid": "<id>"}</code></td>
|
|
<td><code>ObjectId("<id>")</code></td>
|
|
</tr>
|
|
<tr>
|
|
<td>ISODate</td>
|
|
<td><code>"<key>": {"$date": "YYYY-MM-DDThh:mm:ss.sssZ"}</code></td>
|
|
<td><code>ISODate("YYYY-MM-DD")</code></td>
|
|
</tr>
|
|
<tr>
|
|
<td>Timestamp</td>
|
|
<td></td>
|
|
<td><code>Timestamp(11421532)</code></td>
|
|
</tr>
|
|
<tr>
|
|
<td>Embedded Document</td>
|
|
<td><code>{"a": {...}}</code></td>
|
|
<td></td>
|
|
</tr>
|
|
<tr>
|
|
<td>Embedded Array</td>
|
|
<td><code>{"b": [...]}</code></td>
|
|
<td></td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<p>It's mandatory for each document ot have an unique field <code>_id</code>.
|
|
MongoDB automatically creates an <code>ObjectId()</code> if it's not provided.</p>
|
|
<h2 id="databases-collections-usage">Databases & Collections Usage</h2>
|
|
<p>To create a database is sufficient to switch towards a non existing one with <code>use <database></code> (implicit creation).
|
|
The database is not actually created until a document is inserted.</p>
|
|
<div class="highlight"><table class="highlighttable"><tr><th colspan="2" class="filename"><span class="filename">Bash</span></th></tr><tr><td class="linenos"><div class="linenodiv"><pre><span></span><span class="normal"><a href="#__codelineno-0-1">1</a></span>
|
|
<span class="normal"><a href="#__codelineno-0-2">2</a></span>
|
|
<span class="normal"><a href="#__codelineno-0-3">3</a></span>
|
|
<span class="normal"><a href="#__codelineno-0-4">4</a></span>
|
|
<span class="normal"><a href="#__codelineno-0-5">5</a></span>
|
|
<span class="normal"><a href="#__codelineno-0-6">6</a></span>
|
|
<span class="normal"><a href="#__codelineno-0-7">7</a></span>
|
|
<span class="normal"><a href="#__codelineno-0-8">8</a></span></pre></div></td><td class="code"><div><pre><span></span><code><a id="__codelineno-0-1" name="__codelineno-0-1"></a>show<span class="w"> </span>dbs<span class="w"> </span><span class="c1"># list all databases</span>
|
|
<a id="__codelineno-0-2" name="__codelineno-0-2"></a>use<span class="w"> </span><database><span class="w"> </span><span class="c1"># use a particular database</span>
|
|
<a id="__codelineno-0-3" name="__codelineno-0-3"></a>show<span class="w"> </span>collections<span class="w"> </span><span class="c1"># list all collection for the current database</span>
|
|
<a id="__codelineno-0-4" name="__codelineno-0-4"></a>
|
|
<a id="__codelineno-0-5" name="__codelineno-0-5"></a>dbs.dropDatabase<span class="o">()</span><span class="w"> </span><span class="c1"># delete current database</span>
|
|
<a id="__codelineno-0-6" name="__codelineno-0-6"></a>
|
|
<a id="__codelineno-0-7" name="__codelineno-0-7"></a>db.createCollection<span class="o">(</span>name,<span class="w"> </span><span class="o">{</span>options<span class="o">})</span><span class="w"> </span><span class="c1"># explicit collection creation</span>
|
|
<a id="__codelineno-0-8" name="__codelineno-0-8"></a>db.<collection>.insertOne<span class="o">({</span>document<span class="o">})</span><span class="w"> </span><span class="c1"># implicit collection creation</span>
|
|
</code></pre></div></td></tr></table></div>
|
|
<h2 id="operators-mql-syntax">Operators (MQL Syntax)</h2>
|
|
<div class="highlight"><table class="highlighttable"><tr><th colspan="2" class="filename"><span class="filename">JSON</span></th></tr><tr><td class="linenos"><div class="linenodiv"><pre><span></span><span class="normal"><a href="#__codelineno-1-1"> 1</a></span>
|
|
<span class="normal"><a href="#__codelineno-1-2"> 2</a></span>
|
|
<span class="normal"><a href="#__codelineno-1-3"> 3</a></span>
|
|
<span class="normal"><a href="#__codelineno-1-4"> 4</a></span>
|
|
<span class="normal"><a href="#__codelineno-1-5"> 5</a></span>
|
|
<span class="normal"><a href="#__codelineno-1-6"> 6</a></span>
|
|
<span class="normal"><a href="#__codelineno-1-7"> 7</a></span>
|
|
<span class="normal"><a href="#__codelineno-1-8"> 8</a></span>
|
|
<span class="normal"><a href="#__codelineno-1-9"> 9</a></span>
|
|
<span class="normal"><a href="#__codelineno-1-10">10</a></span>
|
|
<span class="normal"><a href="#__codelineno-1-11">11</a></span>
|
|
<span class="normal"><a href="#__codelineno-1-12">12</a></span>
|
|
<span class="normal"><a href="#__codelineno-1-13">13</a></span>
|
|
<span class="normal"><a href="#__codelineno-1-14">14</a></span>
|
|
<span class="normal"><a href="#__codelineno-1-15">15</a></span>
|
|
<span class="normal"><a href="#__codelineno-1-16">16</a></span>
|
|
<span class="normal"><a href="#__codelineno-1-17">17</a></span>
|
|
<span class="normal"><a href="#__codelineno-1-18">18</a></span>
|
|
<span class="normal"><a href="#__codelineno-1-19">19</a></span>
|
|
<span class="normal"><a href="#__codelineno-1-20">20</a></span>
|
|
<span class="normal"><a href="#__codelineno-1-21">21</a></span>
|
|
<span class="normal"><a href="#__codelineno-1-22">22</a></span>
|
|
<span class="normal"><a href="#__codelineno-1-23">23</a></span>
|
|
<span class="normal"><a href="#__codelineno-1-24">24</a></span>
|
|
<span class="normal"><a href="#__codelineno-1-25">25</a></span>
|
|
<span class="normal"><a href="#__codelineno-1-26">26</a></span>
|
|
<span class="normal"><a href="#__codelineno-1-27">27</a></span>
|
|
<span class="normal"><a href="#__codelineno-1-28">28</a></span>
|
|
<span class="normal"><a href="#__codelineno-1-29">29</a></span>
|
|
<span class="normal"><a href="#__codelineno-1-30">30</a></span>
|
|
<span class="normal"><a href="#__codelineno-1-31">31</a></span>
|
|
<span class="normal"><a href="#__codelineno-1-32">32</a></span>
|
|
<span class="normal"><a href="#__codelineno-1-33">33</a></span>
|
|
<span class="normal"><a href="#__codelineno-1-34">34</a></span>
|
|
<span class="normal"><a href="#__codelineno-1-35">35</a></span>
|
|
<span class="normal"><a href="#__codelineno-1-36">36</a></span>
|
|
<span class="normal"><a href="#__codelineno-1-37">37</a></span>
|
|
<span class="normal"><a href="#__codelineno-1-38">38</a></span></pre></div></td><td class="code"><div><pre><span></span><code><a id="__codelineno-1-1" name="__codelineno-1-1"></a><span class="cm">/* --- Update operators --- */</span>
|
|
<a id="__codelineno-1-2" name="__codelineno-1-2"></a><span class="p">{</span><span class="w"> </span><span class="nt">"$inc"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="nt">"<key>"</span><span class="p">:</span><span class="w"> </span><span class="s2">"<increment>"</span><span class="p">,</span><span class="w"> </span><span class="err">...</span><span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="c1">// increment value</span>
|
|
<a id="__codelineno-1-3" name="__codelineno-1-3"></a><span class="p">{</span><span class="w"> </span><span class="nt">"$set"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="nt">"<key>"</span><span class="p">:</span><span class="w"> </span><span class="s2">"<value>"</span><span class="p">,</span><span class="w"> </span><span class="err">...</span><span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="c1">// set value</span>
|
|
<a id="__codelineno-1-4" name="__codelineno-1-4"></a><span class="p">{</span><span class="w"> </span><span class="nt">"$unsetset"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="nt">"<key>"</span><span class="p">:</span><span class="w"> </span><span class="s2">"true"</span><span class="p">,</span><span class="w"> </span><span class="err">...</span><span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="c1">// unset value</span>
|
|
<a id="__codelineno-1-5" name="__codelineno-1-5"></a><span class="p">{</span><span class="w"> </span><span class="nt">"$push"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="nt">"<key>"</span><span class="p">:</span><span class="w"> </span><span class="s2">"<value>"</span><span class="p">,</span><span class="w"> </span><span class="err">...</span><span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="c1">// add a value to an array field or turn field into array</span>
|
|
<a id="__codelineno-1-6" name="__codelineno-1-6"></a><span class="p">{</span><span class="w"> </span><span class="nt">"$pop"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="nt">"<key>"</span><span class="p">:</span><span class="w"> </span><span class="err"><</span><span class="mi">-1</span><span class="w"> </span><span class="err">|</span><span class="w"> </span><span class="mi">1</span><span class="err">></span><span class="p">,</span><span class="w"> </span><span class="err">...</span><span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="c1">// remove first or last array element</span>
|
|
<a id="__codelineno-1-7" name="__codelineno-1-7"></a><span class="p">{</span><span class="w"> </span><span class="nt">"$pull"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="nt">"<key>"</span><span class="p">:</span><span class="w"> </span><span class="s2">"<value | condition>"</span><span class="p">,</span><span class="w"> </span><span class="err">...</span><span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="c1">// remove a specific item in the array</span>
|
|
<a id="__codelineno-1-8" name="__codelineno-1-8"></a><span class="p">{</span><span class="w"> </span><span class="nt">"$pullAll"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="nt">"<key>"</span><span class="p">:</span><span class="w"> </span><span class="p">[</span><span class="w"> </span><span class="s2">"<value1>"</span><span class="p">,</span><span class="w"> </span><span class="s2">"<value2>"</span><span class="w"> </span><span class="err">...</span><span class="w"> </span><span class="p">],</span><span class="w"> </span><span class="err">...</span><span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="c1">// remove all specified values from array</span>
|
|
<a id="__codelineno-1-9" name="__codelineno-1-9"></a>
|
|
<a id="__codelineno-1-10" name="__codelineno-1-10"></a><span class="cm">/* --- Query Operators --- */</span>
|
|
<a id="__codelineno-1-11" name="__codelineno-1-11"></a><span class="p">{</span><span class="w"> </span><span class="nt">"<key>"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="nt">"$in"</span><span class="p">:</span><span class="w"> </span><span class="p">[</span><span class="w"> </span><span class="s2">"<value_1>"</span><span class="p">,</span><span class="w"> </span><span class="s2">"<value_2>"</span><span class="p">,</span><span class="w"> </span><span class="err">...</span><span class="p">]</span><span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="c1">// Membership</span>
|
|
<a id="__codelineno-1-12" name="__codelineno-1-12"></a><span class="p">{</span><span class="w"> </span><span class="nt">"<key>"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="nt">"$nin"</span><span class="p">:</span><span class="w"> </span><span class="p">[</span><span class="w"> </span><span class="s2">"<value_1>"</span><span class="p">,</span><span class="w"> </span><span class="s2">"<value_2>"</span><span class="p">,</span><span class="w"> </span><span class="err">...</span><span class="p">]</span><span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="c1">// Membership</span>
|
|
<a id="__codelineno-1-13" name="__codelineno-1-13"></a><span class="p">{</span><span class="w"> </span><span class="nt">"<key>"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="nt">"$exists"</span><span class="p">:</span><span class="w"> </span><span class="kc">true</span><span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="c1">// Field Exists</span>
|
|
<a id="__codelineno-1-14" name="__codelineno-1-14"></a>
|
|
<a id="__codelineno-1-15" name="__codelineno-1-15"></a><span class="cm">/* --- Comparison Operators (DEFAULT: $eq) --- */</span>
|
|
<a id="__codelineno-1-16" name="__codelineno-1-16"></a><span class="p">{</span><span class="w"> </span><span class="nt">"<key>"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="nt">"$gt"</span><span class="p">:</span><span class="w"> </span><span class="s2">"<value>"</span><span class="w"> </span><span class="p">}}</span><span class="w"> </span><span class="c1">// ></span>
|
|
<a id="__codelineno-1-17" name="__codelineno-1-17"></a><span class="p">{</span><span class="w"> </span><span class="nt">"<key>"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="nt">"$gte"</span><span class="p">:</span><span class="w"> </span><span class="s2">"<value>"</span><span class="w"> </span><span class="p">}}</span><span class="w"> </span><span class="c1">// >=</span>
|
|
<a id="__codelineno-1-18" name="__codelineno-1-18"></a><span class="p">{</span><span class="w"> </span><span class="nt">"<key>"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="nt">"$lt"</span><span class="p">:</span><span class="w"> </span><span class="s2">"<value>"</span><span class="w"> </span><span class="p">}}</span><span class="w"> </span><span class="c1">// <</span>
|
|
<a id="__codelineno-1-19" name="__codelineno-1-19"></a><span class="p">{</span><span class="w"> </span><span class="nt">"<key>"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="nt">"$lte"</span><span class="p">:</span><span class="w"> </span><span class="s2">"<value>"</span><span class="w"> </span><span class="p">}}</span><span class="w"> </span><span class="c1">// <=</span>
|
|
<a id="__codelineno-1-20" name="__codelineno-1-20"></a><span class="p">{</span><span class="w"> </span><span class="nt">"<key>"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="nt">"$eq"</span><span class="p">:</span><span class="w"> </span><span class="s2">"<value>"</span><span class="w"> </span><span class="p">}}</span><span class="w"> </span><span class="c1">// ==</span>
|
|
<a id="__codelineno-1-21" name="__codelineno-1-21"></a><span class="p">{</span><span class="w"> </span><span class="nt">"<key>"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="nt">"$ne"</span><span class="p">:</span><span class="w"> </span><span class="s2">"<value>"</span><span class="w"> </span><span class="p">}}</span><span class="w"> </span><span class="c1">// !=</span>
|
|
<a id="__codelineno-1-22" name="__codelineno-1-22"></a>
|
|
<a id="__codelineno-1-23" name="__codelineno-1-23"></a><span class="cm">/* --- Logic Operators (DEFAULT $and) --- */</span>
|
|
<a id="__codelineno-1-24" name="__codelineno-1-24"></a><span class="p">{</span><span class="w"> </span><span class="nt">"$and"</span><span class="p">:</span><span class="w"> </span><span class="p">[</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="s2">"<expression>"</span><span class="w"> </span><span class="p">},</span><span class="w"> </span><span class="err">...</span><span class="p">]</span><span class="w"> </span><span class="p">}</span>
|
|
<a id="__codelineno-1-25" name="__codelineno-1-25"></a><span class="p">{</span><span class="w"> </span><span class="nt">"$or"</span><span class="p">:</span><span class="w"> </span><span class="p">[</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="s2">"<expression>"</span><span class="w"> </span><span class="p">},</span><span class="w"> </span><span class="err">...</span><span class="p">]</span><span class="w"> </span><span class="p">}</span>
|
|
<a id="__codelineno-1-26" name="__codelineno-1-26"></a><span class="p">{</span><span class="w"> </span><span class="nt">"$nor"</span><span class="p">:</span><span class="w"> </span><span class="p">[</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="s2">"<expression>"</span><span class="w"> </span><span class="p">},</span><span class="w"> </span><span class="err">...</span><span class="p">]</span><span class="w"> </span><span class="p">}</span>
|
|
<a id="__codelineno-1-27" name="__codelineno-1-27"></a><span class="p">{</span><span class="w"> </span><span class="nt">"$not"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="s2">"<expression>"</span><span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="p">}</span>
|
|
<a id="__codelineno-1-28" name="__codelineno-1-28"></a>
|
|
<a id="__codelineno-1-29" name="__codelineno-1-29"></a><span class="cm">/* --- Array Operators --- */</span>
|
|
<a id="__codelineno-1-30" name="__codelineno-1-30"></a><span class="p">{</span><span class="w"> </span><span class="nt">"<key>"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="nt">"$all"</span><span class="p">:</span><span class="w"> </span><span class="p">[</span><span class="s2">"value>"</span><span class="p">,</span><span class="w"> </span><span class="s2">"<value>"</span><span class="p">,</span><span class="w"> </span><span class="err">...</span><span class="p">]</span><span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="c1">// field contains all values</span>
|
|
<a id="__codelineno-1-31" name="__codelineno-1-31"></a><span class="p">{</span><span class="w"> </span><span class="nt">"<key>"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="nt">"$size"</span><span class="p">:</span><span class="w"> </span><span class="s2">"<value>"</span><span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="p">}</span>
|
|
<a id="__codelineno-1-32" name="__codelineno-1-32"></a><span class="p">{</span><span class="w"> </span><span class="nt">"<array-key>"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="nt">"$elemMatch"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="nt">"<item-key>"</span><span class="p">:</span><span class="w"> </span><span class="s2">"<expression>"</span><span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="c1">// elements in array must match an expression</span>
|
|
<a id="__codelineno-1-33" name="__codelineno-1-33"></a>
|
|
<a id="__codelineno-1-34" name="__codelineno-1-34"></a><span class="cm">/* --- REGEX Operator --- */</span>
|
|
<a id="__codelineno-1-35" name="__codelineno-1-35"></a><span class="p">{</span><span class="w"> </span><span class="nt">"<key>"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="nt">"$regex"</span><span class="p">:</span><span class="w"> </span><span class="s2">"/pattern/"</span><span class="p">,</span><span class="w"> </span><span class="nt">"$options"</span><span class="p">:</span><span class="w"> </span><span class="s2">"<options>"</span><span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="p">}</span>
|
|
<a id="__codelineno-1-36" name="__codelineno-1-36"></a><span class="p">{</span><span class="w"> </span><span class="nt">"<key>"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="nt">"$regex"</span><span class="p">:</span><span class="w"> </span><span class="s2">"pattern"</span><span class="p">,</span><span class="w"> </span><span class="nt">"$options"</span><span class="p">:</span><span class="w"> </span><span class="s2">"<options>"</span><span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="p">}</span>
|
|
<a id="__codelineno-1-37" name="__codelineno-1-37"></a><span class="p">{</span><span class="w"> </span><span class="nt">"<key>"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="nt">"$regex"</span><span class="p">:</span><span class="w"> </span><span class="s2">"/pattern/<options>"</span><span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="p">}</span>
|
|
<a id="__codelineno-1-38" name="__codelineno-1-38"></a><span class="p">{</span><span class="w"> </span><span class="nt">"<key>"</span><span class="p">:</span><span class="w"> </span><span class="s2">"/pattern/<options>"</span><span class="w"> </span><span class="p">}</span>
|
|
</code></pre></div></td></tr></table></div>
|
|
<h3 id="expressive-query-operator">Expressive Query Operator</h3>
|
|
<blockquote>
|
|
<p><strong>Note</strong>: <code>$<key></code> is used to access the value of the field dynamically</p>
|
|
</blockquote>
|
|
<div class="highlight"><table class="highlighttable"><tr><th colspan="2" class="filename"><span class="filename">JSON</span></th></tr><tr><td class="linenos"><div class="linenodiv"><pre><span></span><span class="normal"><a href="#__codelineno-2-1">1</a></span>
|
|
<span class="normal"><a href="#__codelineno-2-2">2</a></span></pre></div></td><td class="code"><div><pre><span></span><code><a id="__codelineno-2-1" name="__codelineno-2-1"></a><span class="p">{</span><span class="w"> </span><span class="nt">"$expr"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="s2">"<expression>"</span><span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="c1">// aggregation expression, variables, conditional expressions</span>
|
|
<a id="__codelineno-2-2" name="__codelineno-2-2"></a><span class="p">{</span><span class="w"> </span><span class="nt">"$expr"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="nt">"$<comparison_operator>"</span><span class="p">:</span><span class="w"> </span><span class="p">[</span><span class="w"> </span><span class="s2">"$<key>"</span><span class="p">,</span><span class="w"> </span><span class="s2">"$<key>"</span><span class="w"> </span><span class="p">]</span><span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="c1">// compare field values (operators use aggregation syntax)</span>
|
|
</code></pre></div></td></tr></table></div>
|
|
<h2 id="mongo-query-language-mql">Mongo Query Language (MQL)</h2>
|
|
<h3 id="insertion">Insertion</h3>
|
|
<p>It's possible to insert a single document with the command <code>insertOne()</code> or multiple documents with <code>insertMany()</code>.</p>
|
|
<p>Insertion results:</p>
|
|
<ul>
|
|
<li>error -> rollback</li>
|
|
<li>success -> entire documents gets saved</li>
|
|
</ul>
|
|
<div class="highlight"><table class="highlighttable"><tr><th colspan="2" class="filename"><span class="filename">Bash</span></th></tr><tr><td class="linenos"><div class="linenodiv"><pre><span></span><span class="normal"><a href="#__codelineno-3-1"> 1</a></span>
|
|
<span class="normal"><a href="#__codelineno-3-2"> 2</a></span>
|
|
<span class="normal"><a href="#__codelineno-3-3"> 3</a></span>
|
|
<span class="normal"><a href="#__codelineno-3-4"> 4</a></span>
|
|
<span class="normal"><a href="#__codelineno-3-5"> 5</a></span>
|
|
<span class="normal"><a href="#__codelineno-3-6"> 6</a></span>
|
|
<span class="normal"><a href="#__codelineno-3-7"> 7</a></span>
|
|
<span class="normal"><a href="#__codelineno-3-8"> 8</a></span>
|
|
<span class="normal"><a href="#__codelineno-3-9"> 9</a></span>
|
|
<span class="normal"><a href="#__codelineno-3-10">10</a></span>
|
|
<span class="normal"><a href="#__codelineno-3-11">11</a></span>
|
|
<span class="normal"><a href="#__codelineno-3-12">12</a></span>
|
|
<span class="normal"><a href="#__codelineno-3-13">13</a></span>
|
|
<span class="normal"><a href="#__codelineno-3-14">14</a></span>
|
|
<span class="normal"><a href="#__codelineno-3-15">15</a></span>
|
|
<span class="normal"><a href="#__codelineno-3-16">16</a></span>
|
|
<span class="normal"><a href="#__codelineno-3-17">17</a></span>
|
|
<span class="normal"><a href="#__codelineno-3-18">18</a></span>
|
|
<span class="normal"><a href="#__codelineno-3-19">19</a></span>
|
|
<span class="normal"><a href="#__codelineno-3-20">20</a></span>
|
|
<span class="normal"><a href="#__codelineno-3-21">21</a></span>
|
|
<span class="normal"><a href="#__codelineno-3-22">22</a></span>
|
|
<span class="normal"><a href="#__codelineno-3-23">23</a></span>
|
|
<span class="normal"><a href="#__codelineno-3-24">24</a></span>
|
|
<span class="normal"><a href="#__codelineno-3-25">25</a></span>
|
|
<span class="normal"><a href="#__codelineno-3-26">26</a></span></pre></div></td><td class="code"><div><pre><span></span><code><a id="__codelineno-3-1" name="__codelineno-3-1"></a><span class="c1"># explicit collection creation, all options are optional</span>
|
|
<a id="__codelineno-3-2" name="__codelineno-3-2"></a>db.createCollection<span class="o">(</span><span class="w"> </span><name>,
|
|
<a id="__codelineno-3-3" name="__codelineno-3-3"></a><span class="w"> </span><span class="o">{</span>
|
|
<a id="__codelineno-3-4" name="__codelineno-3-4"></a><span class="w"> </span>capped:<span class="w"> </span><boolean>,
|
|
<a id="__codelineno-3-5" name="__codelineno-3-5"></a><span class="w"> </span>autoIndexId:<span class="w"> </span><boolean>,
|
|
<a id="__codelineno-3-6" name="__codelineno-3-6"></a><span class="w"> </span>size:<span class="w"> </span><number>,
|
|
<a id="__codelineno-3-7" name="__codelineno-3-7"></a><span class="w"> </span>max:<span class="w"> </span><number>,
|
|
<a id="__codelineno-3-8" name="__codelineno-3-8"></a><span class="w"> </span>storageEngine:<span class="w"> </span><document>,
|
|
<a id="__codelineno-3-9" name="__codelineno-3-9"></a><span class="w"> </span>validator:<span class="w"> </span><document>,
|
|
<a id="__codelineno-3-10" name="__codelineno-3-10"></a><span class="w"> </span>validationLevel:<span class="w"> </span><string>,
|
|
<a id="__codelineno-3-11" name="__codelineno-3-11"></a><span class="w"> </span>validationAction:<span class="w"> </span><string>,
|
|
<a id="__codelineno-3-12" name="__codelineno-3-12"></a><span class="w"> </span>indexOptionDefaults:<span class="w"> </span><document>,
|
|
<a id="__codelineno-3-13" name="__codelineno-3-13"></a><span class="w"> </span>viewOn:<span class="w"> </span><string>,
|
|
<a id="__codelineno-3-14" name="__codelineno-3-14"></a><span class="w"> </span>pipeline:<span class="w"> </span><pipeline>,
|
|
<a id="__codelineno-3-15" name="__codelineno-3-15"></a><span class="w"> </span>collation:<span class="w"> </span><document>,
|
|
<a id="__codelineno-3-16" name="__codelineno-3-16"></a><span class="w"> </span>writeConcern:<span class="w"> </span><document>
|
|
<a id="__codelineno-3-17" name="__codelineno-3-17"></a><span class="w"> </span><span class="o">}</span>
|
|
<a id="__codelineno-3-18" name="__codelineno-3-18"></a><span class="o">)</span>
|
|
<a id="__codelineno-3-19" name="__codelineno-3-19"></a>
|
|
<a id="__codelineno-3-20" name="__codelineno-3-20"></a>db.createCollection<span class="o">(</span><span class="s2">"name"</span>,<span class="w"> </span><span class="o">{</span><span class="w"> </span>capped:<span class="w"> </span>true,<span class="w"> </span>size:<span class="w"> </span>max_bytes,<span class="w"> </span>max:<span class="w"> </span>max_docs_num<span class="w"> </span><span class="o">}</span><span class="w"> </span><span class="o">)</span><span class="w"> </span><span class="c1"># creation of a capped collection</span>
|
|
<a id="__codelineno-3-21" name="__codelineno-3-21"></a><span class="c1"># SIZE: int - will be rounded to a multiple of 256</span>
|
|
<a id="__codelineno-3-22" name="__codelineno-3-22"></a>
|
|
<a id="__codelineno-3-23" name="__codelineno-3-23"></a><span class="c1"># implicit creation at doc insertion</span>
|
|
<a id="__codelineno-3-24" name="__codelineno-3-24"></a>db.<collection>.insertOne<span class="o">({</span><span class="w"> </span>document<span class="w"> </span><span class="o">}</span>,<span class="w"> </span>options<span class="o">)</span><span class="w"> </span><span class="c1"># insert a document in a collection</span>
|
|
<a id="__codelineno-3-25" name="__codelineno-3-25"></a>db.<collection>.insertMany<span class="o">([</span><span class="w"> </span><span class="o">{</span><span class="w"> </span>document<span class="w"> </span><span class="o">}</span>,<span class="w"> </span><span class="o">{</span><span class="w"> </span>document<span class="w"> </span><span class="o">}</span>,<span class="w"> </span>...<span class="w"> </span><span class="o">]</span>,<span class="w"> </span>options<span class="o">)</span><span class="w"> </span><span class="c1"># insert multiple docs</span>
|
|
<a id="__codelineno-3-26" name="__codelineno-3-26"></a>db.<collection>.insertMany<span class="o">([</span><span class="w"> </span><span class="o">{</span><span class="w"> </span>document<span class="w"> </span><span class="o">}</span>,<span class="w"> </span><span class="o">{</span><span class="w"> </span>document<span class="w"> </span><span class="o">}</span><span class="w"> </span><span class="o">]</span><span class="w"> </span>,<span class="w"> </span><span class="o">{</span><span class="w"> </span><span class="s2">"ordered"</span>:<span class="w"> </span><span class="nb">false</span><span class="w"> </span><span class="o">})</span><span class="w"> </span><span class="c1"># allow the unordered insertion, only documents that cause errors wont be inserted</span>
|
|
</code></pre></div></td></tr></table></div>
|
|
<blockquote>
|
|
<p><strong>Note</strong>: If <code>insertMany()</code> fails the already inserted documents are not rolled back but all the successive ones (even the correct ones) will not be inserted.</p>
|
|
</blockquote>
|
|
<h3 id="querying">Querying</h3>
|
|
<div class="highlight"><table class="highlighttable"><tr><th colspan="2" class="filename"><span class="filename">Bash</span></th></tr><tr><td class="linenos"><div class="linenodiv"><pre><span></span><span class="normal"><a href="#__codelineno-4-1"> 1</a></span>
|
|
<span class="normal"><a href="#__codelineno-4-2"> 2</a></span>
|
|
<span class="normal"><a href="#__codelineno-4-3"> 3</a></span>
|
|
<span class="normal"><a href="#__codelineno-4-4"> 4</a></span>
|
|
<span class="normal"><a href="#__codelineno-4-5"> 5</a></span>
|
|
<span class="normal"><a href="#__codelineno-4-6"> 6</a></span>
|
|
<span class="normal"><a href="#__codelineno-4-7"> 7</a></span>
|
|
<span class="normal"><a href="#__codelineno-4-8"> 8</a></span>
|
|
<span class="normal"><a href="#__codelineno-4-9"> 9</a></span>
|
|
<span class="normal"><a href="#__codelineno-4-10">10</a></span>
|
|
<span class="normal"><a href="#__codelineno-4-11">11</a></span>
|
|
<span class="normal"><a href="#__codelineno-4-12">12</a></span>
|
|
<span class="normal"><a href="#__codelineno-4-13">13</a></span>
|
|
<span class="normal"><a href="#__codelineno-4-14">14</a></span>
|
|
<span class="normal"><a href="#__codelineno-4-15">15</a></span>
|
|
<span class="normal"><a href="#__codelineno-4-16">16</a></span>
|
|
<span class="normal"><a href="#__codelineno-4-17">17</a></span>
|
|
<span class="normal"><a href="#__codelineno-4-18">18</a></span>
|
|
<span class="normal"><a href="#__codelineno-4-19">19</a></span>
|
|
<span class="normal"><a href="#__codelineno-4-20">20</a></span>
|
|
<span class="normal"><a href="#__codelineno-4-21">21</a></span>
|
|
<span class="normal"><a href="#__codelineno-4-22">22</a></span>
|
|
<span class="normal"><a href="#__codelineno-4-23">23</a></span>
|
|
<span class="normal"><a href="#__codelineno-4-24">24</a></span>
|
|
<span class="normal"><a href="#__codelineno-4-25">25</a></span>
|
|
<span class="normal"><a href="#__codelineno-4-26">26</a></span>
|
|
<span class="normal"><a href="#__codelineno-4-27">27</a></span>
|
|
<span class="normal"><a href="#__codelineno-4-28">28</a></span>
|
|
<span class="normal"><a href="#__codelineno-4-29">29</a></span>
|
|
<span class="normal"><a href="#__codelineno-4-30">30</a></span>
|
|
<span class="normal"><a href="#__codelineno-4-31">31</a></span>
|
|
<span class="normal"><a href="#__codelineno-4-32">32</a></span>
|
|
<span class="normal"><a href="#__codelineno-4-33">33</a></span>
|
|
<span class="normal"><a href="#__codelineno-4-34">34</a></span>
|
|
<span class="normal"><a href="#__codelineno-4-35">35</a></span></pre></div></td><td class="code"><div><pre><span></span><code><a id="__codelineno-4-1" name="__codelineno-4-1"></a>db.<collection>.findOne<span class="o">()</span><span class="w"> </span><span class="c1"># find only one document</span>
|
|
<a id="__codelineno-4-2" name="__codelineno-4-2"></a>db.<collection>.find<span class="o">(</span>filter<span class="o">)</span><span class="w"> </span><span class="c1"># show selected documents</span>
|
|
<a id="__codelineno-4-3" name="__codelineno-4-3"></a>db.<collection>.find<span class="o">()</span>.pretty<span class="o">()</span><span class="w"> </span><span class="c1"># show documents formatted</span>
|
|
<a id="__codelineno-4-4" name="__codelineno-4-4"></a>db.<collection>.find<span class="o">()</span>.limit<span class="o">(</span>n<span class="o">)</span><span class="w"> </span><span class="c1"># show n documents</span>
|
|
<a id="__codelineno-4-5" name="__codelineno-4-5"></a>db.<collection>.find<span class="o">()</span>.limit<span class="o">(</span>n<span class="o">)</span>.skip<span class="o">(</span>k<span class="o">)</span><span class="w"> </span><span class="c1"># show n documents skipping k docs</span>
|
|
<a id="__codelineno-4-6" name="__codelineno-4-6"></a>db.<collection>.find<span class="o">()</span>.count<span class="o">()</span><span class="w"> </span><span class="c1"># number of found docs</span>
|
|
<a id="__codelineno-4-7" name="__codelineno-4-7"></a>db.<collection>.find<span class="o">()</span>.sort<span class="o">({</span><span class="w"> </span><span class="s2">"<key-1>"</span>:<span class="w"> </span><span class="m">1</span>,<span class="w"> </span>...<span class="w"> </span>,<span class="w"> </span><span class="s2">"<key-n>"</span>:<span class="w"> </span>-1<span class="w"> </span><span class="o">})</span><span class="w"> </span><span class="c1"># show documents sorted by specified keys in ascending (1) or descending (-1) order</span>
|
|
<a id="__codelineno-4-8" name="__codelineno-4-8"></a>
|
|
<a id="__codelineno-4-9" name="__codelineno-4-9"></a><span class="c1"># projection</span>
|
|
<a id="__codelineno-4-10" name="__codelineno-4-10"></a>db.<collection>.find<span class="o">(</span>filter,<span class="w"> </span><span class="o">{</span><span class="w"> </span><span class="s2">"<key>"</span>:<span class="w"> </span><span class="m">1</span><span class="w"> </span><span class="o">})</span><span class="w"> </span><span class="c1"># show selected values form documents (1 or true => show, 0 or false => don't show, cant mix 0 and 1)</span>
|
|
<a id="__codelineno-4-11" name="__codelineno-4-11"></a>db.<collection>.find<span class="o">(</span>filter,<span class="w"> </span><span class="o">{</span><span class="w"> </span>_id:<span class="w"> </span><span class="m">0</span>,<span class="w"> </span><span class="s2">"<key>"</span>:<span class="w"> </span><span class="m">1</span><span class="w"> </span><span class="o">})</span><span class="w"> </span><span class="c1"># only _id can be set to 0 with other keys at 1</span>
|
|
<a id="__codelineno-4-12" name="__codelineno-4-12"></a>db.<collection>.find<span class="o">(</span>filter,<span class="w"> </span><span class="o">{</span><span class="w"> </span><span class="s2">"<array-key>"</span>:<span class="w"> </span><span class="o">{</span><span class="w"> </span><span class="s2">"</span><span class="nv">$elemMatch</span><span class="s2">"</span>:<span class="w"> </span><span class="o">{</span><span class="w"> </span><span class="s2">"<item-key>"</span>:<span class="w"> </span><span class="s2">"<expression>"</span><span class="w"> </span><span class="o">}</span><span class="w"> </span><span class="o">}</span><span class="w"> </span><span class="o">})</span><span class="w"> </span><span class="c1"># project only elements matching the expression</span>
|
|
<a id="__codelineno-4-13" name="__codelineno-4-13"></a>
|
|
<a id="__codelineno-4-14" name="__codelineno-4-14"></a><span class="c1"># sub documents & arrays</span>
|
|
<a id="__codelineno-4-15" name="__codelineno-4-15"></a>db.<collection>.find<span class="o">({</span><span class="w"> </span><span class="s2">"<key>.<sub-key>.<sub-key>"</span>:<span class="w"> </span><span class="s2">"<expression>"</span><span class="w"> </span><span class="o">})</span>
|
|
<a id="__codelineno-4-16" name="__codelineno-4-16"></a>db.<collection>.find<span class="o">({</span><span class="w"> </span><span class="s2">"<array-key>.<index>.<sub-key>"</span>:<span class="w"> </span><span class="s2">"<expression>"</span><span class="w"> </span><span class="o">})</span>
|
|
<a id="__codelineno-4-17" name="__codelineno-4-17"></a>
|
|
<a id="__codelineno-4-18" name="__codelineno-4-18"></a><span class="c1"># GeoJSON - https://docs.mongodb.com/manual/reference/operator/query/near/index.html</span>
|
|
<a id="__codelineno-4-19" name="__codelineno-4-19"></a>db.<collection>.find<span class="o">(</span>
|
|
<a id="__codelineno-4-20" name="__codelineno-4-20"></a><span class="w"> </span><span class="o">{</span>
|
|
<a id="__codelineno-4-21" name="__codelineno-4-21"></a><span class="w"> </span><location<span class="w"> </span>field>:<span class="w"> </span><span class="o">{</span>
|
|
<a id="__codelineno-4-22" name="__codelineno-4-22"></a><span class="w"> </span><span class="nv">$near</span>:<span class="w"> </span><span class="o">{</span>
|
|
<a id="__codelineno-4-23" name="__codelineno-4-23"></a><span class="w"> </span><span class="nv">$geometry</span>:<span class="w"> </span><span class="o">{</span><span class="w"> </span>type:<span class="w"> </span><span class="s2">"Point"</span>,<span class="w"> </span>coordinates:<span class="w"> </span><span class="o">[</span><span class="w"> </span><longitude><span class="w"> </span>,<span class="w"> </span><latitude><span class="w"> </span><span class="o">]</span><span class="w"> </span><span class="o">}</span>,
|
|
<a id="__codelineno-4-24" name="__codelineno-4-24"></a><span class="w"> </span><span class="nv">$maxDistance</span>:<span class="w"> </span><distance<span class="w"> </span><span class="k">in</span><span class="w"> </span>meters>,
|
|
<a id="__codelineno-4-25" name="__codelineno-4-25"></a><span class="w"> </span><span class="nv">$minDistance</span>:<span class="w"> </span><distance<span class="w"> </span><span class="k">in</span><span class="w"> </span>meters>
|
|
<a id="__codelineno-4-26" name="__codelineno-4-26"></a><span class="w"> </span><span class="o">}</span>
|
|
<a id="__codelineno-4-27" name="__codelineno-4-27"></a><span class="w"> </span><span class="o">}</span>
|
|
<a id="__codelineno-4-28" name="__codelineno-4-28"></a><span class="w"> </span><span class="o">}</span>
|
|
<a id="__codelineno-4-29" name="__codelineno-4-29"></a><span class="o">)</span>
|
|
<a id="__codelineno-4-30" name="__codelineno-4-30"></a>
|
|
<a id="__codelineno-4-31" name="__codelineno-4-31"></a>db.<collection>.find<span class="o">()</span>.hint<span class="o">(</span><span class="w"> </span><span class="o">{</span><span class="w"> </span><span class="s2">"<key>"</span>:<span class="w"> </span><span class="m">1</span><span class="w"> </span><span class="o">}</span><span class="w"> </span><span class="o">)</span><span class="w"> </span><span class="c1"># specify the index</span>
|
|
<a id="__codelineno-4-32" name="__codelineno-4-32"></a>db.<collection>.find<span class="o">()</span>.hint<span class="o">(</span><span class="w"> </span><span class="s2">"index-name"</span><span class="w"> </span><span class="o">)</span><span class="w"> </span><span class="c1"># specify the index using the index name</span>
|
|
<a id="__codelineno-4-33" name="__codelineno-4-33"></a>
|
|
<a id="__codelineno-4-34" name="__codelineno-4-34"></a>db.<collection>.find<span class="o">()</span>.hint<span class="o">(</span><span class="w"> </span><span class="o">{</span><span class="w"> </span><span class="nv">$natural</span><span class="w"> </span>:<span class="w"> </span><span class="m">1</span><span class="w"> </span><span class="o">}</span><span class="w"> </span><span class="o">)</span><span class="w"> </span><span class="c1"># force the query to perform a forwards collection scan</span>
|
|
<a id="__codelineno-4-35" name="__codelineno-4-35"></a>db.<collection>.find<span class="o">()</span>.hint<span class="o">(</span><span class="w"> </span><span class="o">{</span><span class="w"> </span><span class="nv">$natural</span><span class="w"> </span>:<span class="w"> </span>-1<span class="w"> </span><span class="o">}</span><span class="w"> </span><span class="o">)</span><span class="w"> </span><span class="c1"># force the query to perform a reverse collection scan</span>
|
|
</code></pre></div></td></tr></table></div>
|
|
<blockquote>
|
|
<p><strong>Note</strong>: <code>{ <key>: <value> }</code> in case of a field array will match if the array <em>contains</em> the value</p>
|
|
</blockquote>
|
|
<h3 id="updating">Updating</h3>
|
|
<p><a href="https://docs.mongodb.com/manual/reference/operator/update/" title="Update Operators Documentation">Update Operators</a></p>
|
|
<div class="highlight"><table class="highlighttable"><tr><th colspan="2" class="filename"><span class="filename">Bash</span></th></tr><tr><td class="linenos"><div class="linenodiv"><pre><span></span><span class="normal"><a href="#__codelineno-5-1">1</a></span>
|
|
<span class="normal"><a href="#__codelineno-5-2">2</a></span>
|
|
<span class="normal"><a href="#__codelineno-5-3">3</a></span>
|
|
<span class="normal"><a href="#__codelineno-5-4">4</a></span></pre></div></td><td class="code"><div><pre><span></span><code><a id="__codelineno-5-1" name="__codelineno-5-1"></a>db.<collection>.replaceOne<span class="o">(</span>filter,<span class="w"> </span>update,<span class="w"> </span>options<span class="o">)</span>
|
|
<a id="__codelineno-5-2" name="__codelineno-5-2"></a>db.<collection>.updateOne<span class="o">(</span>filter,<span class="w"> </span>update,<span class="w"> </span><span class="o">{</span>upsert:<span class="w"> </span>true<span class="o">})</span><span class="w"> </span><span class="c1"># modify document if existing, insert otherwise</span>
|
|
<a id="__codelineno-5-3" name="__codelineno-5-3"></a>
|
|
<a id="__codelineno-5-4" name="__codelineno-5-4"></a>db.<collection>.updateOne<span class="o">(</span>filter,<span class="w"> </span><span class="o">{</span><span class="w"> </span><span class="s2">"</span><span class="nv">$push</span><span class="s2">"</span>:<span class="w"> </span><span class="o">{</span><span class="w"> </span>...<span class="w"> </span><span class="o">}</span>,<span class="w"> </span><span class="s2">"</span><span class="nv">$set</span><span class="s2">"</span>:<span class="w"> </span><span class="o">{</span><span class="w"> </span>...<span class="w"> </span><span class="o">}</span>,<span class="w"> </span><span class="o">{</span><span class="w"> </span><span class="s2">"</span><span class="nv">$inc</span><span class="s2">"</span>:<span class="w"> </span><span class="o">{</span><span class="w"> </span>...<span class="w"> </span><span class="o">}</span>,<span class="w"> </span>...<span class="w"> </span><span class="o">}</span><span class="w"> </span><span class="o">})</span>
|
|
</code></pre></div></td></tr></table></div>
|
|
<h3 id="deletion">Deletion</h3>
|
|
<div class="highlight"><table class="highlighttable"><tr><th colspan="2" class="filename"><span class="filename">Bash</span></th></tr><tr><td class="linenos"><div class="linenodiv"><pre><span></span><span class="normal"><a href="#__codelineno-6-1">1</a></span>
|
|
<span class="normal"><a href="#__codelineno-6-2">2</a></span>
|
|
<span class="normal"><a href="#__codelineno-6-3">3</a></span>
|
|
<span class="normal"><a href="#__codelineno-6-4">4</a></span>
|
|
<span class="normal"><a href="#__codelineno-6-5">5</a></span></pre></div></td><td class="code"><div><pre><span></span><code><a id="__codelineno-6-1" name="__codelineno-6-1"></a>db.<collection>.deleteOne<span class="o">(</span>filter,<span class="w"> </span>options<span class="o">)</span>
|
|
<a id="__codelineno-6-2" name="__codelineno-6-2"></a>db.<collection>.deleteMany<span class="o">(</span>filter,<span class="w"> </span>options<span class="o">)</span>
|
|
<a id="__codelineno-6-3" name="__codelineno-6-3"></a>
|
|
<a id="__codelineno-6-4" name="__codelineno-6-4"></a>db.<collection>.drop<span class="o">()</span><span class="w"> </span><span class="c1"># delete whole collection</span>
|
|
<a id="__codelineno-6-5" name="__codelineno-6-5"></a>db.dropDatabase<span class="o">()</span><span class="w"> </span><span class="c1"># delete entire database</span>
|
|
</code></pre></div></td></tr></table></div>
|
|
<hr />
|
|
<h2 id="mongodb-database-tools">MongoDB Database Tools</h2>
|
|
<h3 id="mongoimport"><a href="https://docs.mongodb.com/database-tools/mongoimport/">Mongoimport</a></h3>
|
|
<p>Utility to import all docs into a specified collection.<br />
|
|
If the collection already exists <code>--drop</code> deletes it before reuploading it.
|
|
<strong>WARNING</strong>: CSV separators must be commas (<code>,</code>)</p>
|
|
<div class="highlight"><table class="highlighttable"><tr><th colspan="2" class="filename"><span class="filename">Bash</span></th></tr><tr><td class="linenos"><div class="linenodiv"><pre><span></span><span class="normal"><a href="#__codelineno-7-1"> 1</a></span>
|
|
<span class="normal"><a href="#__codelineno-7-2"> 2</a></span>
|
|
<span class="normal"><a href="#__codelineno-7-3"> 3</a></span>
|
|
<span class="normal"><a href="#__codelineno-7-4"> 4</a></span>
|
|
<span class="normal"><a href="#__codelineno-7-5"> 5</a></span>
|
|
<span class="normal"><a href="#__codelineno-7-6"> 6</a></span>
|
|
<span class="normal"><a href="#__codelineno-7-7"> 7</a></span>
|
|
<span class="normal"><a href="#__codelineno-7-8"> 8</a></span>
|
|
<span class="normal"><a href="#__codelineno-7-9"> 9</a></span>
|
|
<span class="normal"><a href="#__codelineno-7-10">10</a></span>
|
|
<span class="normal"><a href="#__codelineno-7-11">11</a></span>
|
|
<span class="normal"><a href="#__codelineno-7-12">12</a></span></pre></div></td><td class="code"><div><pre><span></span><code><a id="__codelineno-7-1" name="__codelineno-7-1"></a>mongoimport<span class="w"> </span><options><span class="w"> </span><connection-string><span class="w"> </span><file>
|
|
<a id="__codelineno-7-2" name="__codelineno-7-2"></a>
|
|
<a id="__codelineno-7-3" name="__codelineno-7-3"></a>--uri<span class="o">=</span><connectionString>
|
|
<a id="__codelineno-7-4" name="__codelineno-7-4"></a>--host<span class="o">=</span><hostname><:port>,<span class="w"> </span>-h<span class="o">=</span><hostname><:port>
|
|
<a id="__codelineno-7-5" name="__codelineno-7-5"></a>--username<span class="o">=</span><username>,<span class="w"> </span>-u<span class="o">=</span><username>
|
|
<a id="__codelineno-7-6" name="__codelineno-7-6"></a>--password<span class="o">=</span><password>,<span class="w"> </span>-p<span class="o">=</span><password>
|
|
<a id="__codelineno-7-7" name="__codelineno-7-7"></a>--collection<span class="o">=</span><collection>,<span class="w"> </span>-c<span class="o">=</span><collection><span class="w"> </span><span class="c1"># Specifies the collection to import.</span>
|
|
<a id="__codelineno-7-8" name="__codelineno-7-8"></a>--ssl<span class="w"> </span><span class="c1"># Enables connection to a mongod or mongos that has TLS/SSL support enabled.</span>
|
|
<a id="__codelineno-7-9" name="__codelineno-7-9"></a>--type<span class="w"> </span><json<span class="p">|</span>csv<span class="p">|</span>tsv><span class="w"> </span><span class="c1"># Specifies the file type to import. DEFAULT: json</span>
|
|
<a id="__codelineno-7-10" name="__codelineno-7-10"></a>--drop<span class="w"> </span><span class="c1"># drops the collection before importing the data from the input.</span>
|
|
<a id="__codelineno-7-11" name="__codelineno-7-11"></a>--headerline<span class="w"> </span><span class="c1"># if file is CSV and first line is header</span>
|
|
<a id="__codelineno-7-12" name="__codelineno-7-12"></a>--jsonarray<span class="w"> </span><span class="c1"># Accepts the import of data expressed with multiple MongoDB documents within a single json array. MAX 16 MB</span>
|
|
</code></pre></div></td></tr></table></div>
|
|
<h3 id="mongoexport"><a href="https://docs.mongodb.com/database-tools/mongoexport/">Mongoexport</a></h3>
|
|
<p>Utility to export documents into a specified file.</p>
|
|
<div class="highlight"><table class="highlighttable"><tr><th colspan="2" class="filename"><span class="filename">Bash</span></th></tr><tr><td class="linenos"><div class="linenodiv"><pre><span></span><span class="normal"><a href="#__codelineno-8-1"> 1</a></span>
|
|
<span class="normal"><a href="#__codelineno-8-2"> 2</a></span>
|
|
<span class="normal"><a href="#__codelineno-8-3"> 3</a></span>
|
|
<span class="normal"><a href="#__codelineno-8-4"> 4</a></span>
|
|
<span class="normal"><a href="#__codelineno-8-5"> 5</a></span>
|
|
<span class="normal"><a href="#__codelineno-8-6"> 6</a></span>
|
|
<span class="normal"><a href="#__codelineno-8-7"> 7</a></span>
|
|
<span class="normal"><a href="#__codelineno-8-8"> 8</a></span>
|
|
<span class="normal"><a href="#__codelineno-8-9"> 9</a></span>
|
|
<span class="normal"><a href="#__codelineno-8-10">10</a></span>
|
|
<span class="normal"><a href="#__codelineno-8-11">11</a></span>
|
|
<span class="normal"><a href="#__codelineno-8-12">12</a></span>
|
|
<span class="normal"><a href="#__codelineno-8-13">13</a></span>
|
|
<span class="normal"><a href="#__codelineno-8-14">14</a></span>
|
|
<span class="normal"><a href="#__codelineno-8-15">15</a></span></pre></div></td><td class="code"><div><pre><span></span><code><a id="__codelineno-8-1" name="__codelineno-8-1"></a>mongoexport<span class="w"> </span>--collection<span class="o">=</span><collection><span class="w"> </span><options><span class="w"> </span><connection-string>
|
|
<a id="__codelineno-8-2" name="__codelineno-8-2"></a>
|
|
<a id="__codelineno-8-3" name="__codelineno-8-3"></a>--uri<span class="o">=</span><connectionString>
|
|
<a id="__codelineno-8-4" name="__codelineno-8-4"></a>--host<span class="o">=</span><hostname><:port>,<span class="w"> </span>-h<span class="o">=</span><hostname><:port>
|
|
<a id="__codelineno-8-5" name="__codelineno-8-5"></a>--username<span class="o">=</span><username>,<span class="w"> </span>-u<span class="o">=</span><username>
|
|
<a id="__codelineno-8-6" name="__codelineno-8-6"></a>--password<span class="o">=</span><password>,<span class="w"> </span>-p<span class="o">=</span><password>
|
|
<a id="__codelineno-8-7" name="__codelineno-8-7"></a>--db<span class="o">=</span><database>,<span class="w"> </span>-d<span class="o">=</span><database>
|
|
<a id="__codelineno-8-8" name="__codelineno-8-8"></a>--collection<span class="o">=</span><collection>,<span class="w"> </span>-c<span class="o">=</span><collection>
|
|
<a id="__codelineno-8-9" name="__codelineno-8-9"></a>--type<span class="o">=</span><json<span class="p">|</span>csv>
|
|
<a id="__codelineno-8-10" name="__codelineno-8-10"></a>--out<span class="o">=</span><file>,<span class="w"> </span>-o<span class="o">=</span><file><span class="w"> </span><span class="c1">#Specifies a file to write the export to. DEFAULT: stdout</span>
|
|
<a id="__codelineno-8-11" name="__codelineno-8-11"></a>--jsonArray<span class="w"> </span><span class="c1"># Write the entire contents of the export as a single json array.</span>
|
|
<a id="__codelineno-8-12" name="__codelineno-8-12"></a>--pretty<span class="w"> </span><span class="c1"># Outputs documents in a pretty-printed format JSON.</span>
|
|
<a id="__codelineno-8-13" name="__codelineno-8-13"></a>--skip<span class="o">=</span><number>
|
|
<a id="__codelineno-8-14" name="__codelineno-8-14"></a>--limit<span class="o">=</span><number><span class="w"> </span><span class="c1"># Specifies a maximum number of documents to include in the export</span>
|
|
<a id="__codelineno-8-15" name="__codelineno-8-15"></a>--sort<span class="o">=</span><JSON><span class="w"> </span><span class="c1"># Specifies an ordering for exported results</span>
|
|
</code></pre></div></td></tr></table></div>
|
|
<h3 id="mongodump-mongorestore"><a href="https://docs.mongodb.com/database-tools/mongodump/">Mongodump</a> & <a href="https://docs.mongodb.com/database-tools/mongorestore/">Mongorestore</a></h3>
|
|
<p><code>mongodump</code> exports the content of a running server into <code>.bson</code> files.</p>
|
|
<p><code>mongorestore</code> Restore backups generated with <code>mongodump</code> to a running server.</p>
|
|
<hr />
|
|
<h2 id="indexes"><a href="https://docs.mongodb.com/manual/indexes/" title="Index Documentation">Indexes</a></h2>
|
|
<p>Indexes support the efficient execution of queries in MongoDB.</p>
|
|
<p>Without indexes, MongoDB must perform a <em>collection scan</em> (<em>COLLSCAN</em>): scan every document in a collection, to select those documents that match the query statement.<br />
|
|
If an appropriate index exists for a query, MongoDB can use the index to limit the number of documents it must inspect (<em>IXSCAN</em>).</p>
|
|
<p>Indexes are special data structures that store a small portion of the collection's data set in an easy to traverse form. The index stores the value of a specific field or set of fields, ordered by the value of the field. The ordering of the index entries supports efficient equality matches and range-based query operations. In addition, MongoDB can return sorted results by using the ordering in the index.</p>
|
|
<p>Indexes <em>slow down writing operations</em> since the index must be updated at every writing.</p>
|
|
<p><img alt="IXSCAN" src="../img/mongodb_ixscan.avif" title=".find() using an index" /></p>
|
|
<h3 id="index-types"><a href="https://docs.mongodb.com/manual/indexes/#index-types">Index Types</a></h3>
|
|
<ul>
|
|
<li><strong>Normal</strong>: Fields sorted by name</li>
|
|
<li><strong>Compound</strong>: Multiple Fields sorted by name</li>
|
|
<li><strong>Multikey</strong>: values of sorted arrays</li>
|
|
<li><strong>Text</strong>: Ordered text fragments</li>
|
|
<li><strong>Geospatial</strong>: ordered geodata</li>
|
|
</ul>
|
|
<p><strong>Sparse</strong> indexes only contain entries for documents that have the indexed field, even if the index field contains a null value. The index skips over any document that is missing the indexed field.</p>
|
|
<h3 id="diagnosis-and-query-planning">Diagnosis and query planning</h3>
|
|
<div class="highlight"><table class="highlighttable"><tr><th colspan="2" class="filename"><span class="filename">Bash</span></th></tr><tr><td class="linenos"><div class="linenodiv"><pre><span></span><span class="normal"><a href="#__codelineno-9-1">1</a></span>
|
|
<span class="normal"><a href="#__codelineno-9-2">2</a></span>
|
|
<span class="normal"><a href="#__codelineno-9-3">3</a></span></pre></div></td><td class="code"><div><pre><span></span><code><a id="__codelineno-9-1" name="__codelineno-9-1"></a>db.<collection>.find<span class="o">({</span>...<span class="o">})</span>.explain<span class="o">()</span><span class="w"> </span><span class="c1"># explain won't accept other functions</span>
|
|
<a id="__codelineno-9-2" name="__codelineno-9-2"></a>db.explain<span class="o">()</span>.<collection>.find<span class="o">({</span>...<span class="o">})</span><span class="w"> </span><span class="c1"># can accept other functions</span>
|
|
<a id="__codelineno-9-3" name="__codelineno-9-3"></a>db.explain<span class="o">(</span><span class="s2">"executionStats"</span><span class="o">)</span>.<collection>.find<span class="o">({</span>...<span class="o">})</span><span class="w"> </span><span class="c1"># more info</span>
|
|
</code></pre></div></td></tr></table></div>
|
|
<h3 id="index-creation">Index Creation</h3>
|
|
<div class="highlight"><table class="highlighttable"><tr><th colspan="2" class="filename"><span class="filename">Bash</span></th></tr><tr><td class="linenos"><div class="linenodiv"><pre><span></span><span class="normal"><a href="#__codelineno-10-1"> 1</a></span>
|
|
<span class="normal"><a href="#__codelineno-10-2"> 2</a></span>
|
|
<span class="normal"><a href="#__codelineno-10-3"> 3</a></span>
|
|
<span class="normal"><a href="#__codelineno-10-4"> 4</a></span>
|
|
<span class="normal"><a href="#__codelineno-10-5"> 5</a></span>
|
|
<span class="normal"><a href="#__codelineno-10-6"> 6</a></span>
|
|
<span class="normal"><a href="#__codelineno-10-7"> 7</a></span>
|
|
<span class="normal"><a href="#__codelineno-10-8"> 8</a></span>
|
|
<span class="normal"><a href="#__codelineno-10-9"> 9</a></span>
|
|
<span class="normal"><a href="#__codelineno-10-10">10</a></span>
|
|
<span class="normal"><a href="#__codelineno-10-11">11</a></span>
|
|
<span class="normal"><a href="#__codelineno-10-12">12</a></span>
|
|
<span class="normal"><a href="#__codelineno-10-13">13</a></span>
|
|
<span class="normal"><a href="#__codelineno-10-14">14</a></span>
|
|
<span class="normal"><a href="#__codelineno-10-15">15</a></span>
|
|
<span class="normal"><a href="#__codelineno-10-16">16</a></span>
|
|
<span class="normal"><a href="#__codelineno-10-17">17</a></span></pre></div></td><td class="code"><div><pre><span></span><code><a id="__codelineno-10-1" name="__codelineno-10-1"></a>db.<collection>.createIndex<span class="o">(</span><span class="w"> </span><key<span class="w"> </span>and<span class="w"> </span>index<span class="w"> </span><span class="nb">type</span><span class="w"> </span>specification>,<span class="w"> </span><options><span class="w"> </span><span class="o">)</span>
|
|
<a id="__codelineno-10-2" name="__codelineno-10-2"></a>
|
|
<a id="__codelineno-10-3" name="__codelineno-10-3"></a>db.<collection>.createIndex<span class="o">(</span><span class="w"> </span><span class="o">{</span><span class="w"> </span><span class="s2">"<key>"</span>:<span class="w"> </span><type>,<span class="w"> </span><span class="s2">"<key>"</span>:<span class="w"> </span><type>,<span class="w"> </span>...<span class="w"> </span><span class="o">}</span><span class="w"> </span><span class="o">)</span><span class="w"> </span><span class="c1"># normal, compound or multikey (field is array) index</span>
|
|
<a id="__codelineno-10-4" name="__codelineno-10-4"></a>db.<collection>.createIndex<span class="o">(</span><span class="w"> </span><span class="o">{</span><span class="w"> </span><span class="s2">"<key>"</span>:<span class="w"> </span><span class="s2">"text"</span><span class="w"> </span><span class="o">}</span><span class="w"> </span><span class="o">)</span><span class="w"> </span><span class="c1"># text index</span>
|
|
<a id="__codelineno-10-5" name="__codelineno-10-5"></a>db.<collection>.createIndex<span class="o">(</span><span class="w"> </span><span class="o">{</span><span class="w"> </span><span class="s2">"<key>"</span>:<span class="w"> </span>2dsphere<span class="w"> </span><span class="o">}</span><span class="w"> </span><span class="o">)</span><span class="w"> </span><span class="c1"># geospatial 2dsphere index</span>
|
|
<a id="__codelineno-10-6" name="__codelineno-10-6"></a>
|
|
<a id="__codelineno-10-7" name="__codelineno-10-7"></a><span class="c1"># sparse index</span>
|
|
<a id="__codelineno-10-8" name="__codelineno-10-8"></a>db.<collection>.createIndex<span class="o">(</span>
|
|
<a id="__codelineno-10-9" name="__codelineno-10-9"></a><span class="w"> </span><span class="o">{</span><span class="w"> </span><span class="s2">"<key>"</span>:<span class="w"> </span><type>,<span class="w"> </span><span class="s2">"<key>"</span>:<span class="w"> </span><type>,<span class="w"> </span>...<span class="w"> </span><span class="o">}</span>,
|
|
<a id="__codelineno-10-10" name="__codelineno-10-10"></a><span class="w"> </span><span class="o">{</span><span class="w"> </span>sparse:<span class="w"> </span><span class="nb">true</span><span class="w"> </span><span class="o">}</span><span class="w"> </span><span class="c1"># sparse option</span>
|
|
<a id="__codelineno-10-11" name="__codelineno-10-11"></a><span class="o">)</span>
|
|
<a id="__codelineno-10-12" name="__codelineno-10-12"></a>
|
|
<a id="__codelineno-10-13" name="__codelineno-10-13"></a><span class="c1"># custom name</span>
|
|
<a id="__codelineno-10-14" name="__codelineno-10-14"></a>db.<collection>.createIndex<span class="o">(</span>
|
|
<a id="__codelineno-10-15" name="__codelineno-10-15"></a><span class="w"> </span><span class="o">{</span><span class="w"> </span><key<span class="w"> </span>and<span class="w"> </span>index<span class="w"> </span><span class="nb">type</span><span class="w"> </span>specification>,<span class="w"> </span><span class="o">}</span>,
|
|
<a id="__codelineno-10-16" name="__codelineno-10-16"></a><span class="w"> </span><span class="o">{</span><span class="w"> </span>name:<span class="w"> </span><span class="s2">"index-name"</span><span class="w"> </span><span class="o">}</span><span class="w"> </span><span class="c1"># name option</span>
|
|
<a id="__codelineno-10-17" name="__codelineno-10-17"></a><span class="o">)</span>
|
|
</code></pre></div></td></tr></table></div>
|
|
<h3 id="index-management"><a href="https://docs.mongodb.com/manual/tutorial/manage-indexes/">Index Management</a></h3>
|
|
<div class="highlight"><table class="highlighttable"><tr><th colspan="2" class="filename"><span class="filename">Bash</span></th></tr><tr><td class="linenos"><div class="linenodiv"><pre><span></span><span class="normal"><a href="#__codelineno-11-1"> 1</a></span>
|
|
<span class="normal"><a href="#__codelineno-11-2"> 2</a></span>
|
|
<span class="normal"><a href="#__codelineno-11-3"> 3</a></span>
|
|
<span class="normal"><a href="#__codelineno-11-4"> 4</a></span>
|
|
<span class="normal"><a href="#__codelineno-11-5"> 5</a></span>
|
|
<span class="normal"><a href="#__codelineno-11-6"> 6</a></span>
|
|
<span class="normal"><a href="#__codelineno-11-7"> 7</a></span>
|
|
<span class="normal"><a href="#__codelineno-11-8"> 8</a></span>
|
|
<span class="normal"><a href="#__codelineno-11-9"> 9</a></span>
|
|
<span class="normal"><a href="#__codelineno-11-10">10</a></span></pre></div></td><td class="code"><div><pre><span></span><code><a id="__codelineno-11-1" name="__codelineno-11-1"></a><span class="c1"># view all db indexes</span>
|
|
<a id="__codelineno-11-2" name="__codelineno-11-2"></a>db.getCollectionNames<span class="o">()</span>.forEach<span class="o">(</span><span class="k">function</span><span class="o">(</span>collection<span class="o">)</span><span class="w"> </span><span class="o">{</span>
|
|
<a id="__codelineno-11-3" name="__codelineno-11-3"></a><span class="w"> </span><span class="nv">indexes</span><span class="w"> </span><span class="o">=</span><span class="w"> </span>db<span class="o">[</span>collection<span class="o">]</span>.getIndexes<span class="o">()</span><span class="p">;</span>
|
|
<a id="__codelineno-11-4" name="__codelineno-11-4"></a><span class="w"> </span>print<span class="o">(</span><span class="s2">"Indexes for "</span><span class="w"> </span>+<span class="w"> </span>collection<span class="w"> </span>+<span class="w"> </span><span class="s2">":"</span><span class="o">)</span><span class="p">;</span>
|
|
<a id="__codelineno-11-5" name="__codelineno-11-5"></a><span class="w"> </span>printjson<span class="o">(</span>indexes<span class="o">)</span><span class="p">;</span>
|
|
<a id="__codelineno-11-6" name="__codelineno-11-6"></a><span class="o">})</span><span class="p">;</span>
|
|
<a id="__codelineno-11-7" name="__codelineno-11-7"></a>db.<collection>.getIndexes<span class="o">()</span><span class="w"> </span><span class="c1"># view collection's index</span>
|
|
<a id="__codelineno-11-8" name="__codelineno-11-8"></a>
|
|
<a id="__codelineno-11-9" name="__codelineno-11-9"></a>db.<collection>.dropIndexes<span class="o">()</span><span class="w"> </span><span class="c1"># drop all indexes</span>
|
|
<a id="__codelineno-11-10" name="__codelineno-11-10"></a>db.<collection>.dropIndex<span class="o">(</span><span class="w"> </span><span class="o">{</span><span class="w"> </span><span class="s2">"index-name"</span>:<span class="w"> </span><span class="m">1</span><span class="w"> </span><span class="o">}</span><span class="w"> </span><span class="o">)</span><span class="w"> </span><span class="c1"># drop a specific index</span>
|
|
</code></pre></div></td></tr></table></div>
|
|
<hr />
|
|
<h2 id="cluster-administration">Cluster Administration</h2>
|
|
<h3 id="mongod"><code>mongod</code></h3>
|
|
<p><code>mongod</code> is the main deamon process for MongoDB. It's the core process of the database,
|
|
handling connections, requests and persisting the data.</p>
|
|
<p><code>mongod</code> default configuration:</p>
|
|
<ul>
|
|
<li>port: <code>27017</code></li>
|
|
<li>dbpath: <code>/data/db</code></li>
|
|
<li>bind_ip: <code>localhost</code></li>
|
|
<li>auth: disabled</li>
|
|
</ul>
|
|
<p><a href="https://www.mongodb.com/docs/manual/reference/configuration-options" title="`mongod` config file docs"><code>mongod</code> config file</a><br />
|
|
<a href="https://www.mongodb.com/docs/manual/reference/program/mongod/#options" title="`mongod` command line options docs"><code>mongod</code> command line options</a></p>
|
|
<h3 id="basic-shell-helpers">Basic Shell Helpers</h3>
|
|
<div class="highlight"><table class="highlighttable"><tr><th colspan="2" class="filename"><span class="filename">Bash</span></th></tr><tr><td class="linenos"><div class="linenodiv"><pre><span></span><span class="normal"><a href="#__codelineno-12-1"> 1</a></span>
|
|
<span class="normal"><a href="#__codelineno-12-2"> 2</a></span>
|
|
<span class="normal"><a href="#__codelineno-12-3"> 3</a></span>
|
|
<span class="normal"><a href="#__codelineno-12-4"> 4</a></span>
|
|
<span class="normal"><a href="#__codelineno-12-5"> 5</a></span>
|
|
<span class="normal"><a href="#__codelineno-12-6"> 6</a></span>
|
|
<span class="normal"><a href="#__codelineno-12-7"> 7</a></span>
|
|
<span class="normal"><a href="#__codelineno-12-8"> 8</a></span>
|
|
<span class="normal"><a href="#__codelineno-12-9"> 9</a></span>
|
|
<span class="normal"><a href="#__codelineno-12-10">10</a></span>
|
|
<span class="normal"><a href="#__codelineno-12-11">11</a></span>
|
|
<span class="normal"><a href="#__codelineno-12-12">12</a></span>
|
|
<span class="normal"><a href="#__codelineno-12-13">13</a></span>
|
|
<span class="normal"><a href="#__codelineno-12-14">14</a></span>
|
|
<span class="normal"><a href="#__codelineno-12-15">15</a></span>
|
|
<span class="normal"><a href="#__codelineno-12-16">16</a></span>
|
|
<span class="normal"><a href="#__codelineno-12-17">17</a></span>
|
|
<span class="normal"><a href="#__codelineno-12-18">18</a></span>
|
|
<span class="normal"><a href="#__codelineno-12-19">19</a></span>
|
|
<span class="normal"><a href="#__codelineno-12-20">20</a></span>
|
|
<span class="normal"><a href="#__codelineno-12-21">21</a></span>
|
|
<span class="normal"><a href="#__codelineno-12-22">22</a></span>
|
|
<span class="normal"><a href="#__codelineno-12-23">23</a></span>
|
|
<span class="normal"><a href="#__codelineno-12-24">24</a></span>
|
|
<span class="normal"><a href="#__codelineno-12-25">25</a></span>
|
|
<span class="normal"><a href="#__codelineno-12-26">26</a></span></pre></div></td><td class="code"><div><pre><span></span><code><a id="__codelineno-12-1" name="__codelineno-12-1"></a>db.<method><span class="o">()</span><span class="w"> </span><span class="c1"># database interaction</span>
|
|
<a id="__codelineno-12-2" name="__codelineno-12-2"></a>db.<collection>.<method><span class="o">()</span><span class="w"> </span><span class="c1"># collection interaction</span>
|
|
<a id="__codelineno-12-3" name="__codelineno-12-3"></a>rs.<method><span class="o">()</span><span class="p">;</span><span class="w"> </span><span class="c1"># replica set deployment and management</span>
|
|
<a id="__codelineno-12-4" name="__codelineno-12-4"></a>sh.<method><span class="o">()</span><span class="p">;</span><span class="w"> </span><span class="c1"># sharded cluster deployment and management</span>
|
|
<a id="__codelineno-12-5" name="__codelineno-12-5"></a>
|
|
<a id="__codelineno-12-6" name="__codelineno-12-6"></a><span class="c1"># user management</span>
|
|
<a id="__codelineno-12-7" name="__codelineno-12-7"></a>db.createUser<span class="o">()</span>
|
|
<a id="__codelineno-12-8" name="__codelineno-12-8"></a>db.dropUser<span class="o">()</span>
|
|
<a id="__codelineno-12-9" name="__codelineno-12-9"></a>
|
|
<a id="__codelineno-12-10" name="__codelineno-12-10"></a><span class="c1"># collection management</span>
|
|
<a id="__codelineno-12-11" name="__codelineno-12-11"></a>db.renameCollection<span class="o">()</span>
|
|
<a id="__codelineno-12-12" name="__codelineno-12-12"></a>db.<collection>.createIndex<span class="o">()</span>
|
|
<a id="__codelineno-12-13" name="__codelineno-12-13"></a>db.<collection>.drop<span class="o">()</span>
|
|
<a id="__codelineno-12-14" name="__codelineno-12-14"></a>
|
|
<a id="__codelineno-12-15" name="__codelineno-12-15"></a><span class="c1"># database management</span>
|
|
<a id="__codelineno-12-16" name="__codelineno-12-16"></a>db.dropDatabase<span class="o">()</span>
|
|
<a id="__codelineno-12-17" name="__codelineno-12-17"></a>db.createCollection<span class="o">()</span>
|
|
<a id="__codelineno-12-18" name="__codelineno-12-18"></a>
|
|
<a id="__codelineno-12-19" name="__codelineno-12-19"></a><span class="c1"># database status</span>
|
|
<a id="__codelineno-12-20" name="__codelineno-12-20"></a>db.serverStatus<span class="o">()</span>
|
|
<a id="__codelineno-12-21" name="__codelineno-12-21"></a>
|
|
<a id="__codelineno-12-22" name="__codelineno-12-22"></a><span class="c1"># database command (underlying to shell helpers and drivers)</span>
|
|
<a id="__codelineno-12-23" name="__codelineno-12-23"></a>db.runCommand<span class="o">({</span><span class="w"> </span><span class="s2">"<COMMAND>"</span><span class="w"> </span><span class="o">})</span>
|
|
<a id="__codelineno-12-24" name="__codelineno-12-24"></a>
|
|
<a id="__codelineno-12-25" name="__codelineno-12-25"></a><span class="c1"># help</span>
|
|
<a id="__codelineno-12-26" name="__codelineno-12-26"></a>db.commandHelp<span class="o">(</span><span class="s2">"<command>)</span>
|
|
</code></pre></div></td></tr></table></div>
|
|
<h3 id="logging">Logging</h3>
|
|
<p>The <strong>process log</strong> displays activity on the MongoDB instance and collects activities of various components:</p>
|
|
<p>Log Verbosity Level:</p>
|
|
<ul>
|
|
<li><code>-1</code>: Inherit from parent</li>
|
|
<li><code>0</code>: Default Verbosity (Information)</li>
|
|
<li><code>1 - 5</code>: Increases the verbosity up to Debug messages</li>
|
|
</ul>
|
|
<div class="highlight"><table class="highlighttable"><tr><th colspan="2" class="filename"><span class="filename">Bash</span></th></tr><tr><td class="linenos"><div class="linenodiv"><pre><span></span><span class="normal"><a href="#__codelineno-13-1">1</a></span>
|
|
<span class="normal"><a href="#__codelineno-13-2">2</a></span>
|
|
<span class="normal"><a href="#__codelineno-13-3">3</a></span>
|
|
<span class="normal"><a href="#__codelineno-13-4">4</a></span>
|
|
<span class="normal"><a href="#__codelineno-13-5">5</a></span></pre></div></td><td class="code"><div><pre><span></span><code><a id="__codelineno-13-1" name="__codelineno-13-1"></a>db.getLogComponents<span class="o">()</span><span class="w"> </span><span class="c1"># get components and their verbosity</span>
|
|
<a id="__codelineno-13-2" name="__codelineno-13-2"></a>db.adminCommand<span class="o">({</span><span class="s2">"getLog"</span>:<span class="w"> </span><span class="s2">"<scope>"</span><span class="o">})</span><span class="w"> </span><span class="c1"># retrieve logs (getLog must be run on admin db -> adminCommand)</span>
|
|
<a id="__codelineno-13-3" name="__codelineno-13-3"></a>db.setLogLevel<span class="o">(</span><level>,<span class="w"> </span><span class="s2">"<component>"</span><span class="o">)</span><span class="p">;</span><span class="w"> </span><span class="c1"># set log level (output is OLD verbosity levels)</span>
|
|
<a id="__codelineno-13-4" name="__codelineno-13-4"></a>
|
|
<a id="__codelineno-13-5" name="__codelineno-13-5"></a>tail<span class="w"> </span>-f<span class="w"> </span>/path/to/mongod.log<span class="w"> </span><span class="c1"># read end og log file</span>
|
|
</code></pre></div></td></tr></table></div>
|
|
<blockquote>
|
|
<p><strong>Note</strong>: Log Message Structure: <code><timestamp> <severity-level> <component> <connection> <event> ...</code></p>
|
|
</blockquote>
|
|
<h3 id="database-profiling">Database Profiling</h3>
|
|
<p>Profiling Levels:</p>
|
|
<ul>
|
|
<li><code>0</code>: no profiling</li>
|
|
<li><code>1</code>: data on operations slower than <code>slowms</code> (default 100ms)</li>
|
|
<li><code>2</code>: data on all operations</li>
|
|
</ul>
|
|
<p>Events captured by the profiler:</p>
|
|
<ul>
|
|
<li>CRUD operations</li>
|
|
<li>Administrative operations</li>
|
|
<li>Configuration operations</li>
|
|
</ul>
|
|
<blockquote>
|
|
<p><strong>Note</strong>: Logs are saved in the <code>system.profile</code> <em>capped</em> collection.</p>
|
|
</blockquote>
|
|
<div class="highlight"><table class="highlighttable"><tr><th colspan="2" class="filename"><span class="filename">Bash</span></th></tr><tr><td class="linenos"><div class="linenodiv"><pre><span></span><span class="normal"><a href="#__codelineno-14-1">1</a></span>
|
|
<span class="normal"><a href="#__codelineno-14-2">2</a></span>
|
|
<span class="normal"><a href="#__codelineno-14-3">3</a></span>
|
|
<span class="normal"><a href="#__codelineno-14-4">4</a></span>
|
|
<span class="normal"><a href="#__codelineno-14-5">5</a></span>
|
|
<span class="normal"><a href="#__codelineno-14-6">6</a></span></pre></div></td><td class="code"><div><pre><span></span><code><a id="__codelineno-14-1" name="__codelineno-14-1"></a>db.setProfilingLevel<span class="o">(</span>n<span class="o">)</span><span class="w"> </span><span class="c1"># set profiler level</span>
|
|
<a id="__codelineno-14-2" name="__codelineno-14-2"></a>db.setProfilingLevel<span class="o">(</span><span class="m">1</span>,<span class="w"> </span><span class="o">{</span><span class="w"> </span>slowms:<span class="w"> </span><ms><span class="w"> </span><span class="o">})</span>
|
|
<a id="__codelineno-14-3" name="__codelineno-14-3"></a>db.getProfilingStatus<span class="o">()</span><span class="w"> </span><span class="c1"># check profiler status</span>
|
|
<a id="__codelineno-14-4" name="__codelineno-14-4"></a>
|
|
<a id="__codelineno-14-5" name="__codelineno-14-5"></a>db.system.profile.find<span class="o">()</span>.limit<span class="o">(</span>n<span class="o">)</span>.sort<span class="o">(</span><span class="w"> </span><span class="o">{}</span><span class="w"> </span><span class="o">)</span>.pretty<span class="o">()</span><span class="w"> </span><span class="c1"># see logs</span>
|
|
<a id="__codelineno-14-6" name="__codelineno-14-6"></a>db.system.profile.find<span class="o">()</span>.limit<span class="o">(</span>n<span class="o">)</span>.sort<span class="o">(</span><span class="w"> </span><span class="o">{</span><span class="w"> </span>ts<span class="w"> </span>:<span class="w"> </span>-1<span class="w"> </span><span class="o">}</span><span class="w"> </span><span class="o">)</span>.pretty<span class="o">()</span><span class="w"> </span><span class="c1"># sort by decreasing timestamp</span>
|
|
</code></pre></div></td></tr></table></div>
|
|
<h3 id="authentication">Authentication</h3>
|
|
<p>Client Authentication Mechanisms:</p>
|
|
<ul>
|
|
<li><strong>SCRAM</strong> (Default): Salted Challenge Response Authentication Mechanism</li>
|
|
<li><strong>X.509</strong>: <code>X.509</code> Certificate</li>
|
|
<li><strong>LADP</strong>: Lightweight Directory Access Protocol (Enterprise Only)</li>
|
|
<li><strong>KERBEROS</strong> (Enterprise Only)</li>
|
|
</ul>
|
|
<h3 id="authorization-role-based-access-control-rbac">Authorization: Role Based Access Control (RBAC)</h3>
|
|
<p>Each user has one or more <strong>Roles</strong>. Each role has one or more <strong>Privileges</strong>.<br />
|
|
A privilege represents a group of <em>actions</em> and the <em>resources</em> those actions apply to.</p>
|
|
<p>By default no user exists so the ONLY way to act is to connect locally to the server.<br />
|
|
This is the "localhost exception" and it closes after the <em>first</em> user is created.</p>
|
|
<blockquote>
|
|
<p><strong>Warn</strong>: Always create an admin user first (ideally with the <code>userAdmin</code> role)</p>
|
|
</blockquote>
|
|
<p>Role's <strong>Resources</strong>:</p>
|
|
<ul>
|
|
<li>specific database and collection: <code>{ "db": "<database>", "collection": "<collection>" }</code></li>
|
|
<li>all databases and collections: <code>{ "db": "", "collection": "" }</code></li>
|
|
<li>any databases and specific collection: <code>{ "db": "", "collection": "<collections>" }</code></li>
|
|
<li>specific database and any collection: <code>{ "db": "<database>", "collection": "" }</code></li>
|
|
<li>cluster resource: <code>{ "cluster": true }</code></li>
|
|
</ul>
|
|
<p>Role's <strong>Privileges</strong>: <code>{ resource: { <resource> }, actions: [ "<action>" ] }</code></p>
|
|
<p>A role can <em>inherit</em> from multiple others and can define <strong>network restrictions</strong> such as <em>Server Address</em> and <em>Client Source</em>.</p>
|
|
<p>Built-in Roles Groups and Names:</p>
|
|
<ul>
|
|
<li>Database User: <code>read</code>, <code>readWrite</code>, <code>readAnyDatabase</code>, <code>readWriteAnyDatabase</code></li>
|
|
<li>Database Administration: <code>dbAdmin</code>, <code>userAdmin</code>, <code>dbOwner</code>, <code>dbAdminAnyDatabase</code>, <code>userAdminAnyDatabase</code></li>
|
|
<li>Cluster Administration: <code>clusterAdmin</code>, <code>clusterManager</code>, <code>clusterMonitor</code>, <code>hostManager</code></li>
|
|
<li>Backup/Restore: <code>backup</code>, <code>restore</code></li>
|
|
<li>Super User: <code>root</code></li>
|
|
</ul>
|
|
<div class="highlight"><table class="highlighttable"><tr><th colspan="2" class="filename"><span class="filename">Bash</span></th></tr><tr><td class="linenos"><div class="linenodiv"><pre><span></span><span class="normal"><a href="#__codelineno-15-1"> 1</a></span>
|
|
<span class="normal"><a href="#__codelineno-15-2"> 2</a></span>
|
|
<span class="normal"><a href="#__codelineno-15-3"> 3</a></span>
|
|
<span class="normal"><a href="#__codelineno-15-4"> 4</a></span>
|
|
<span class="normal"><a href="#__codelineno-15-5"> 5</a></span>
|
|
<span class="normal"><a href="#__codelineno-15-6"> 6</a></span>
|
|
<span class="normal"><a href="#__codelineno-15-7"> 7</a></span>
|
|
<span class="normal"><a href="#__codelineno-15-8"> 8</a></span>
|
|
<span class="normal"><a href="#__codelineno-15-9"> 9</a></span>
|
|
<span class="normal"><a href="#__codelineno-15-10">10</a></span>
|
|
<span class="normal"><a href="#__codelineno-15-11">11</a></span>
|
|
<span class="normal"><a href="#__codelineno-15-12">12</a></span>
|
|
<span class="normal"><a href="#__codelineno-15-13">13</a></span>
|
|
<span class="normal"><a href="#__codelineno-15-14">14</a></span>
|
|
<span class="normal"><a href="#__codelineno-15-15">15</a></span>
|
|
<span class="normal"><a href="#__codelineno-15-16">16</a></span>
|
|
<span class="normal"><a href="#__codelineno-15-17">17</a></span>
|
|
<span class="normal"><a href="#__codelineno-15-18">18</a></span>
|
|
<span class="normal"><a href="#__codelineno-15-19">19</a></span>
|
|
<span class="normal"><a href="#__codelineno-15-20">20</a></span>
|
|
<span class="normal"><a href="#__codelineno-15-21">21</a></span>
|
|
<span class="normal"><a href="#__codelineno-15-22">22</a></span>
|
|
<span class="normal"><a href="#__codelineno-15-23">23</a></span>
|
|
<span class="normal"><a href="#__codelineno-15-24">24</a></span>
|
|
<span class="normal"><a href="#__codelineno-15-25">25</a></span>
|
|
<span class="normal"><a href="#__codelineno-15-26">26</a></span>
|
|
<span class="normal"><a href="#__codelineno-15-27">27</a></span>
|
|
<span class="normal"><a href="#__codelineno-15-28">28</a></span>
|
|
<span class="normal"><a href="#__codelineno-15-29">29</a></span>
|
|
<span class="normal"><a href="#__codelineno-15-30">30</a></span>
|
|
<span class="normal"><a href="#__codelineno-15-31">31</a></span>
|
|
<span class="normal"><a href="#__codelineno-15-32">32</a></span>
|
|
<span class="normal"><a href="#__codelineno-15-33">33</a></span>
|
|
<span class="normal"><a href="#__codelineno-15-34">34</a></span>
|
|
<span class="normal"><a href="#__codelineno-15-35">35</a></span>
|
|
<span class="normal"><a href="#__codelineno-15-36">36</a></span>
|
|
<span class="normal"><a href="#__codelineno-15-37">37</a></span>
|
|
<span class="normal"><a href="#__codelineno-15-38">38</a></span>
|
|
<span class="normal"><a href="#__codelineno-15-39">39</a></span>
|
|
<span class="normal"><a href="#__codelineno-15-40">40</a></span></pre></div></td><td class="code"><div><pre><span></span><code><a id="__codelineno-15-1" name="__codelineno-15-1"></a>db.createUser<span class="o">({</span>
|
|
<a id="__codelineno-15-2" name="__codelineno-15-2"></a><span class="w"> </span>user:<span class="w"> </span><span class="s2">"<username>"</span>,
|
|
<a id="__codelineno-15-3" name="__codelineno-15-3"></a><span class="w"> </span>pwd:<span class="w"> </span><span class="s2">"<password>"</span>,
|
|
<a id="__codelineno-15-4" name="__codelineno-15-4"></a><span class="w"> </span>roles:<span class="w"> </span><span class="o">[</span><span class="w"> </span><span class="o">{</span><span class="w"> </span>role:<span class="w"> </span><span class="s2">"<role>"</span>,<span class="w"> </span>db:<span class="w"> </span><span class="s2">"<database>"</span><span class="w"> </span><span class="o">}</span><span class="w"> </span><span class="o">]</span>
|
|
<a id="__codelineno-15-5" name="__codelineno-15-5"></a><span class="o">})</span>
|
|
<a id="__codelineno-15-6" name="__codelineno-15-6"></a>
|
|
<a id="__codelineno-15-7" name="__codelineno-15-7"></a>db.createRole<span class="o">({</span>
|
|
<a id="__codelineno-15-8" name="__codelineno-15-8"></a><span class="w"> </span>role:<span class="w"> </span><span class="s2">"<role>"</span>,
|
|
<a id="__codelineno-15-9" name="__codelineno-15-9"></a><span class="w"> </span>privileges:<span class="w"> </span><span class="o">[</span>
|
|
<a id="__codelineno-15-10" name="__codelineno-15-10"></a><span class="w"> </span><span class="o">{</span><span class="w"> </span>resource:<span class="w"> </span><span class="o">{</span><span class="w"> </span>cluster:<span class="w"> </span><span class="nb">true</span><span class="w"> </span><span class="o">}</span>,<span class="w"> </span>actions:<span class="w"> </span><span class="o">[</span><span class="w"> </span><span class="s2">"<action>"</span>,<span class="w"> </span>...<span class="w"> </span><span class="o">]</span><span class="w"> </span><span class="o">}</span>,
|
|
<a id="__codelineno-15-11" name="__codelineno-15-11"></a><span class="w"> </span><span class="o">{</span>
|
|
<a id="__codelineno-15-12" name="__codelineno-15-12"></a><span class="w"> </span>resource:<span class="w"> </span><span class="o">{</span><span class="w"> </span>
|
|
<a id="__codelineno-15-13" name="__codelineno-15-13"></a><span class="w"> </span>db:<span class="w"> </span><span class="s2">"<database>"</span>,
|
|
<a id="__codelineno-15-14" name="__codelineno-15-14"></a><span class="w"> </span>collection:<span class="w"> </span><span class="s2">"<collection>"</span>
|
|
<a id="__codelineno-15-15" name="__codelineno-15-15"></a><span class="w"> </span><span class="o">}</span>,
|
|
<a id="__codelineno-15-16" name="__codelineno-15-16"></a><span class="w"> </span>actions:<span class="w"> </span><span class="o">[</span><span class="w"> </span><span class="s2">"<action>"</span>,<span class="w"> </span>...<span class="w"> </span><span class="o">]</span>
|
|
<a id="__codelineno-15-17" name="__codelineno-15-17"></a><span class="w"> </span><span class="o">}</span>,
|
|
<a id="__codelineno-15-18" name="__codelineno-15-18"></a><span class="w"> </span><span class="o">]</span>,
|
|
<a id="__codelineno-15-19" name="__codelineno-15-19"></a><span class="w"> </span>roles:<span class="w"> </span><span class="o">[</span>
|
|
<a id="__codelineno-15-20" name="__codelineno-15-20"></a><span class="w"> </span><span class="o">{</span><span class="w"> </span>role:<span class="w"> </span><span class="s2">"<role>"</span>,<span class="w"> </span>db:<span class="w"> </span><span class="s2">"<database>"</span><span class="w"> </span><span class="o">}</span><span class="w"> </span><span class="c1"># inherited permissions</span>
|
|
<a id="__codelineno-15-21" name="__codelineno-15-21"></a><span class="w"> </span><span class="o">]</span>
|
|
<a id="__codelineno-15-22" name="__codelineno-15-22"></a><span class="o">})</span>
|
|
<a id="__codelineno-15-23" name="__codelineno-15-23"></a>
|
|
<a id="__codelineno-15-24" name="__codelineno-15-24"></a><span class="c1"># add role to existing user</span>
|
|
<a id="__codelineno-15-25" name="__codelineno-15-25"></a>db.grantRolesToUser<span class="o">(</span>
|
|
<a id="__codelineno-15-26" name="__codelineno-15-26"></a><span class="w"> </span><span class="s2">"<user>"</span>,
|
|
<a id="__codelineno-15-27" name="__codelineno-15-27"></a><span class="w"> </span><span class="o">[</span>
|
|
<a id="__codelineno-15-28" name="__codelineno-15-28"></a><span class="w"> </span><span class="o">{</span><span class="w"> </span>
|
|
<a id="__codelineno-15-29" name="__codelineno-15-29"></a><span class="w"> </span>role:<span class="w"> </span><span class="s2">"<role>"</span>
|
|
<a id="__codelineno-15-30" name="__codelineno-15-30"></a><span class="w"> </span>db:<span class="w"> </span><span class="s2">"<database>"</span>,
|
|
<a id="__codelineno-15-31" name="__codelineno-15-31"></a><span class="w"> </span>collection:<span class="w"> </span><span class="s2">"<collection>"</span>,
|
|
<a id="__codelineno-15-32" name="__codelineno-15-32"></a><span class="w"> </span><span class="o">}</span>
|
|
<a id="__codelineno-15-33" name="__codelineno-15-33"></a><span class="w"> </span><span class="o">]</span>
|
|
<a id="__codelineno-15-34" name="__codelineno-15-34"></a><span class="o">)</span>
|
|
<a id="__codelineno-15-35" name="__codelineno-15-35"></a>
|
|
<a id="__codelineno-15-36" name="__codelineno-15-36"></a><span class="c1"># show role privileges</span>
|
|
<a id="__codelineno-15-37" name="__codelineno-15-37"></a>db.runCommand<span class="o">({</span>
|
|
<a id="__codelineno-15-38" name="__codelineno-15-38"></a><span class="w"> </span>rolesInfo:<span class="w"> </span><span class="o">{</span><span class="w"> </span>db:<span class="w"> </span><span class="s2">"<database>"</span>,<span class="w"> </span>role:<span class="w"> </span><span class="s2">"<role>"</span><span class="w"> </span><span class="o">}</span>,
|
|
<a id="__codelineno-15-39" name="__codelineno-15-39"></a><span class="w"> </span>showPrivileges:<span class="w"> </span><span class="nb">true</span><span class="w"> </span>
|
|
<a id="__codelineno-15-40" name="__codelineno-15-40"></a><span class="o">})</span>
|
|
</code></pre></div></td></tr></table></div>
|
|
<h3 id="replica-set"><a href="https://docs.mongodb.com/manual/replication/">Replica set</a></h3>
|
|
<p>A <strong>replica set</strong> in MongoDB is a group of <code>mongod</code> processes that maintain the <code>same dataset</code>. Replica sets provide redundancy and high availability, and are the basis for all production deployments.</p>
|
|
<h3 id="sharding">Sharding</h3>
|
|
<p><strong>Sharding</strong> is a MongoDB concept through which big datasets are subdivided in smaller sets and distributed towards multiple instances of MongoDB.<br />
|
|
It's a technique used to improve the performances of large queries towards large quantities of data that require al lot of resources from the server.</p>
|
|
<p>A collection containing several documents is splitted in more smaller collections (<em>shards</em>)
|
|
Shards are implemented via cluster that are none other a group of MongoDB instances.</p>
|
|
<p>Shard components are:</p>
|
|
<ul>
|
|
<li>Shards (min 2), instances of MongoDB that contain a subset of the data</li>
|
|
<li>A config server, instance of MongoDB which contains metadata on the cluster, that is the set of instances that have the shard data.</li>
|
|
<li>A router (or <code>mongos</code>), instance of MongoDB used to redirect the user instructions from the client to the correct server.</li>
|
|
</ul>
|
|
<p><img alt="Shared Cluster" src="../img/mongodb_shared-cluster.avif" title="Components of a shared cluster" /></p>
|
|
<hr />
|
|
<h2 id="aggregation-framework"><a href="https://docs.mongodb.com/manual/reference/operator/aggregation-pipeline/">Aggregation Framework</a></h2>
|
|
<p>Sequence of operations applied to a collection as a <em>pipeline</em> to get a result: <code>db.collection.aggregate(pipeline, options)</code>.<br />
|
|
Each step of the pipeline acts on its inputs and not on the original data in the collection.</p>
|
|
<h3 id="variables">Variables</h3>
|
|
<p>Variable syntax in aggregations:</p>
|
|
<ul>
|
|
<li><code>$key</code>: field path</li>
|
|
<li><code>$$UPPERCASE</code>: system variable (e.g.: <code>$$CURRENT</code>)</li>
|
|
<li><code>$$foo</code>: user defined variable</li>
|
|
</ul>
|
|
<h3 id="match-aggregation-stage"><a href="https://www.mongodb.com/docs/manual/reference/operator/aggregation/match/" title="$match operator docs"><code>$match</code> Aggregation Stage</a></h3>
|
|
<p>Filters the documents to pass only the documents that match the specified condition(s) to the next pipeline stage.</p>
|
|
<div class="highlight"><table class="highlighttable"><tr><th colspan="2" class="filename"><span class="filename">Bash</span></th></tr><tr><td class="linenos"><div class="linenodiv"><pre><span></span><span class="normal"><a href="#__codelineno-16-1">1</a></span>
|
|
<span class="normal"><a href="#__codelineno-16-2">2</a></span>
|
|
<span class="normal"><a href="#__codelineno-16-3">3</a></span>
|
|
<span class="normal"><a href="#__codelineno-16-4">4</a></span>
|
|
<span class="normal"><a href="#__codelineno-16-5">5</a></span>
|
|
<span class="normal"><a href="#__codelineno-16-6">6</a></span></pre></div></td><td class="code"><div><pre><span></span><code><a id="__codelineno-16-1" name="__codelineno-16-1"></a>db.<collection>.aggregate<span class="o">([</span><span class="w"> </span>
|
|
<a id="__codelineno-16-2" name="__codelineno-16-2"></a><span class="w"> </span><span class="o">{</span><span class="w"> </span><span class="s2">"</span><span class="nv">$match</span><span class="s2">"</span>:<span class="w"> </span><span class="o">{</span><span class="w"> </span><span class="s2">"<query>"</span><span class="w"> </span><span class="o">}</span><span class="w"> </span><span class="o">}</span>,
|
|
<a id="__codelineno-16-3" name="__codelineno-16-3"></a>
|
|
<a id="__codelineno-16-4" name="__codelineno-16-4"></a><span class="w"> </span><span class="c1"># key exists and is an array</span>
|
|
<a id="__codelineno-16-5" name="__codelineno-16-5"></a><span class="w"> </span><span class="o">{</span><span class="w"> </span><span class="nv">$match</span>:<span class="w"> </span><span class="o">{</span><span class="w"> </span><span class="s2">"<array-key>"</span>:<span class="w"> </span><span class="o">{</span><span class="w"> </span><span class="nv">$elemMatch</span>:<span class="w"> </span><span class="o">{</span><span class="w"> </span><span class="nv">$exists</span>:<span class="w"> </span><span class="nb">true</span><span class="w"> </span><span class="o">}</span><span class="w"> </span><span class="o">}</span><span class="w"> </span><span class="o">}</span><span class="w"> </span><span class="o">}</span>
|
|
<a id="__codelineno-16-6" name="__codelineno-16-6"></a><span class="o">})</span>
|
|
</code></pre></div></td></tr></table></div>
|
|
<blockquote>
|
|
<p><strong>Note</strong>: <code>$match</code> can contain the <code>$text</code> query operation but it <strong>must</strong> ber the <em>first</em> in a pipeline<br />
|
|
<strong>Note</strong>: <code>$match</code> cannot contain use <code>$where</code><br />
|
|
<strong>Note</strong>: <code>$match</code> uses the same syntax as <code>find()</code></p>
|
|
</blockquote>
|
|
<h3 id="project-aggregation-stage"><a href="https://www.mongodb.com/docs/manual/reference/operator/aggregation/project/" title="$project operator docs"><code>$project</code> Aggregation Stage</a></h3>
|
|
<p>Passes along the documents with the requested fields to the next stage in the pipeline. The specified fields can be existing fields from the input documents or newly computed fields.</p>
|
|
<p><code>$project</code> Array Expression Operators:</p>
|
|
<ul>
|
|
<li><a href="https://www.mongodb.com/docs/v4.4/reference/operator/aggregation/filter/" title="$filter operator docs"><code>$filter</code></a></li>
|
|
<li><a href="https://www.mongodb.com/docs/v4.4/reference/operator/aggregation/map/" title="$map operator docs"><code>$map</code></a></li>
|
|
<li><a href="https://www.mongodb.com/docs/v5.0/reference/operator/aggregation/reduce/" title="$reduce operator docs"><code>$reduce</code></a></li>
|
|
</ul>
|
|
<p><code>$project</code> Arithmetic Expression Operators:</p>
|
|
<ul>
|
|
<li><a href="https://www.mongodb.com/docs/v5.0/reference/operator/aggregation/max/" title="$max operator docs"><code>$max</code></a></li>
|
|
<li><a href="https://www.mongodb.com/docs/v5.0/reference/operator/aggregation/min/" title="$min operator docs"><code>$min</code></a></li>
|
|
<li><a href="https://www.mongodb.com/docs/v5.0/reference/operator/aggregation/sum/" title="$sum operator docs"><code>$sum</code></a></li>
|
|
<li><a href="https://www.mongodb.com/docs/v5.0/reference/operator/aggregation/avg/" title="$avg operator docs"><code>$avg</code></a></li>
|
|
</ul>
|
|
<div class="highlight"><table class="highlighttable"><tr><th colspan="2" class="filename"><span class="filename">Bash</span></th></tr><tr><td class="linenos"><div class="linenodiv"><pre><span></span><span class="normal"><a href="#__codelineno-17-1"> 1</a></span>
|
|
<span class="normal"><a href="#__codelineno-17-2"> 2</a></span>
|
|
<span class="normal"><a href="#__codelineno-17-3"> 3</a></span>
|
|
<span class="normal"><a href="#__codelineno-17-4"> 4</a></span>
|
|
<span class="normal"><a href="#__codelineno-17-5"> 5</a></span>
|
|
<span class="normal"><a href="#__codelineno-17-6"> 6</a></span>
|
|
<span class="normal"><a href="#__codelineno-17-7"> 7</a></span>
|
|
<span class="normal"><a href="#__codelineno-17-8"> 8</a></span>
|
|
<span class="normal"><a href="#__codelineno-17-9"> 9</a></span>
|
|
<span class="normal"><a href="#__codelineno-17-10">10</a></span>
|
|
<span class="normal"><a href="#__codelineno-17-11">11</a></span>
|
|
<span class="normal"><a href="#__codelineno-17-12">12</a></span>
|
|
<span class="normal"><a href="#__codelineno-17-13">13</a></span>
|
|
<span class="normal"><a href="#__codelineno-17-14">14</a></span>
|
|
<span class="normal"><a href="#__codelineno-17-15">15</a></span>
|
|
<span class="normal"><a href="#__codelineno-17-16">16</a></span>
|
|
<span class="normal"><a href="#__codelineno-17-17">17</a></span>
|
|
<span class="normal"><a href="#__codelineno-17-18">18</a></span>
|
|
<span class="normal"><a href="#__codelineno-17-19">19</a></span>
|
|
<span class="normal"><a href="#__codelineno-17-20">20</a></span>
|
|
<span class="normal"><a href="#__codelineno-17-21">21</a></span>
|
|
<span class="normal"><a href="#__codelineno-17-22">22</a></span>
|
|
<span class="normal"><a href="#__codelineno-17-23">23</a></span>
|
|
<span class="normal"><a href="#__codelineno-17-24">24</a></span>
|
|
<span class="normal"><a href="#__codelineno-17-25">25</a></span>
|
|
<span class="normal"><a href="#__codelineno-17-26">26</a></span>
|
|
<span class="normal"><a href="#__codelineno-17-27">27</a></span>
|
|
<span class="normal"><a href="#__codelineno-17-28">28</a></span>
|
|
<span class="normal"><a href="#__codelineno-17-29">29</a></span>
|
|
<span class="normal"><a href="#__codelineno-17-30">30</a></span>
|
|
<span class="normal"><a href="#__codelineno-17-31">31</a></span>
|
|
<span class="normal"><a href="#__codelineno-17-32">32</a></span>
|
|
<span class="normal"><a href="#__codelineno-17-33">33</a></span>
|
|
<span class="normal"><a href="#__codelineno-17-34">34</a></span>
|
|
<span class="normal"><a href="#__codelineno-17-35">35</a></span>
|
|
<span class="normal"><a href="#__codelineno-17-36">36</a></span>
|
|
<span class="normal"><a href="#__codelineno-17-37">37</a></span>
|
|
<span class="normal"><a href="#__codelineno-17-38">38</a></span>
|
|
<span class="normal"><a href="#__codelineno-17-39">39</a></span></pre></div></td><td class="code"><div><pre><span></span><code><a id="__codelineno-17-1" name="__codelineno-17-1"></a>db.<collection>.aggregate<span class="o">([</span><span class="w"> </span>
|
|
<a id="__codelineno-17-2" name="__codelineno-17-2"></a><span class="w"> </span><span class="o">{</span><span class="w"> </span>
|
|
<a id="__codelineno-17-3" name="__codelineno-17-3"></a><span class="w"> </span><span class="s2">"</span><span class="nv">$project</span><span class="s2">"</span>:<span class="w"> </span><span class="o">{</span><span class="w"> </span>
|
|
<a id="__codelineno-17-4" name="__codelineno-17-4"></a><span class="w"> </span><span class="s2">"_id"</span>:<span class="w"> </span><span class="m">0</span>,<span class="w"> </span><span class="c1"># discard value</span>
|
|
<a id="__codelineno-17-5" name="__codelineno-17-5"></a><span class="w"> </span><span class="s2">"<key>"</span>:<span class="w"> </span><span class="m">1</span>,<span class="w"> </span><span class="c1"># keep value</span>
|
|
<a id="__codelineno-17-6" name="__codelineno-17-6"></a><span class="w"> </span><span class="s2">"<key>"</span>:<span class="w"> </span><span class="s2">"</span>$<span class="s2"><other-key>"</span><span class="w"> </span><span class="c1"># reassign or create field,</span>
|
|
<a id="__codelineno-17-7" name="__codelineno-17-7"></a><span class="w"> </span><span class="s2">"<key>"</span>:<span class="w"> </span><span class="o">{</span><span class="w"> </span><span class="s2">"<expression>"</span><span class="w"> </span><span class="o">}</span><span class="w"> </span><span class="c1"># calculate field value.</span>
|
|
<a id="__codelineno-17-8" name="__codelineno-17-8"></a>
|
|
<a id="__codelineno-17-9" name="__codelineno-17-9"></a><span class="w"> </span><span class="c1"># filter elements in an array</span>
|
|
<a id="__codelineno-17-10" name="__codelineno-17-10"></a><span class="w"> </span><span class="s2">"<key>"</span>:<span class="w"> </span><span class="o">{</span>
|
|
<a id="__codelineno-17-11" name="__codelineno-17-11"></a><span class="w"> </span><span class="s2">"</span><span class="nv">$filter</span><span class="s2">"</span>:<span class="w"> </span><span class="o">{</span>
|
|
<a id="__codelineno-17-12" name="__codelineno-17-12"></a><span class="w"> </span><span class="s2">"input"</span>:<span class="w"> </span><span class="s2">"</span>$<span class="s2"><array-key>"</span>,
|
|
<a id="__codelineno-17-13" name="__codelineno-17-13"></a><span class="w"> </span><span class="s2">"as"</span>:<span class="w"> </span><span class="s2">"<name-of-item>"</span>,
|
|
<a id="__codelineno-17-14" name="__codelineno-17-14"></a><span class="w"> </span><span class="s2">"cond"</span>:<span class="w"> </span><span class="o">{</span><span class="w"> </span><span class="s2">"<bool-expression>"</span><span class="w"> </span><span class="o">}</span>
|
|
<a id="__codelineno-17-15" name="__codelineno-17-15"></a><span class="w"> </span><span class="o">}</span>
|
|
<a id="__codelineno-17-16" name="__codelineno-17-16"></a><span class="w"> </span><span class="o">}</span>,
|
|
<a id="__codelineno-17-17" name="__codelineno-17-17"></a>
|
|
<a id="__codelineno-17-18" name="__codelineno-17-18"></a><span class="w"> </span><span class="c1"># transform array items</span>
|
|
<a id="__codelineno-17-19" name="__codelineno-17-19"></a><span class="w"> </span><span class="s2">"<key>"</span>:<span class="w"> </span><span class="o">{</span>
|
|
<a id="__codelineno-17-20" name="__codelineno-17-20"></a><span class="w"> </span><span class="s2">"</span><span class="nv">$map</span><span class="s2">"</span>:<span class="w"> </span><span class="o">{</span>
|
|
<a id="__codelineno-17-21" name="__codelineno-17-21"></a><span class="w"> </span><span class="s2">"input"</span>:<span class="w"> </span><span class="s2">"</span>$<span class="s2"><array-key>"</span>,
|
|
<a id="__codelineno-17-22" name="__codelineno-17-22"></a><span class="w"> </span><span class="s2">"as"</span>:<span class="w"> </span><span class="s2">"<item>"</span>,
|
|
<a id="__codelineno-17-23" name="__codelineno-17-23"></a><span class="w"> </span><span class="s2">"in"</span>:<span class="w"> </span><span class="o">{</span><span class="w"> </span><span class="s2">"<expression>"</span><span class="w"> </span><span class="o">}</span>
|
|
<a id="__codelineno-17-24" name="__codelineno-17-24"></a><span class="w"> </span><span class="c1"># $$<item> is the current item's value</span>
|
|
<a id="__codelineno-17-25" name="__codelineno-17-25"></a><span class="w"> </span><span class="o">}</span>
|
|
<a id="__codelineno-17-26" name="__codelineno-17-26"></a><span class="w"> </span><span class="o">}</span>
|
|
<a id="__codelineno-17-27" name="__codelineno-17-27"></a>
|
|
<a id="__codelineno-17-28" name="__codelineno-17-28"></a><span class="w"> </span><span class="c1"># apply expression to each element in an array and combine them</span>
|
|
<a id="__codelineno-17-29" name="__codelineno-17-29"></a><span class="w"> </span><span class="s2">"<key>"</span>:<span class="w"> </span><span class="o">{</span>
|
|
<a id="__codelineno-17-30" name="__codelineno-17-30"></a><span class="w"> </span><span class="s2">"</span><span class="nv">$reduce</span><span class="s2">"</span>:<span class="w"> </span><span class="o">{</span>
|
|
<a id="__codelineno-17-31" name="__codelineno-17-31"></a><span class="w"> </span><span class="s2">"input"</span>:<span class="w"> </span><span class="s2">"<array-key>"</span>,
|
|
<a id="__codelineno-17-32" name="__codelineno-17-32"></a><span class="w"> </span><span class="s2">"initialValue"</span>:<span class="w"> </span><span class="s2">"<value>"</span>,
|
|
<a id="__codelineno-17-33" name="__codelineno-17-33"></a><span class="w"> </span><span class="s2">"in"</span>:<span class="w"> </span><span class="o">{</span><span class="w"> </span><span class="s2">"<expression>"</span><span class="w"> </span><span class="o">}</span>
|
|
<a id="__codelineno-17-34" name="__codelineno-17-34"></a><span class="w"> </span><span class="c1"># $$this is current document, $$value is current accumulated value</span>
|
|
<a id="__codelineno-17-35" name="__codelineno-17-35"></a><span class="w"> </span><span class="o">}</span>
|
|
<a id="__codelineno-17-36" name="__codelineno-17-36"></a><span class="w"> </span><span class="o">}</span>
|
|
<a id="__codelineno-17-37" name="__codelineno-17-37"></a><span class="w"> </span><span class="o">}</span>
|
|
<a id="__codelineno-17-38" name="__codelineno-17-38"></a><span class="w"> </span><span class="o">}</span><span class="w"> </span>
|
|
<a id="__codelineno-17-39" name="__codelineno-17-39"></a><span class="o">])</span>
|
|
</code></pre></div></td></tr></table></div>
|
|
<h3 id="addfields-aggregation-stage"><a href="https://www.mongodb.com/docs/manual/reference/operator/aggregation/addFields/" title="$addFields operator docs"><code>$addFields</code> Aggregation Stage</a></h3>
|
|
<p>Adds new fields to documents (can be result of computation).<br />
|
|
<code>$addFields</code> outputs documents that contain <em>all existing fields</em> from the input documents and newly added fields.</p>
|
|
<div class="highlight"><table class="highlighttable"><tr><th colspan="2" class="filename"><span class="filename">Bash</span></th></tr><tr><td class="linenos"><div class="linenodiv"><pre><span></span><span class="normal"><a href="#__codelineno-18-1">1</a></span>
|
|
<span class="normal"><a href="#__codelineno-18-2">2</a></span>
|
|
<span class="normal"><a href="#__codelineno-18-3">3</a></span></pre></div></td><td class="code"><div><pre><span></span><code><a id="__codelineno-18-1" name="__codelineno-18-1"></a>db.<collection>.aggregate<span class="o">({</span>
|
|
<a id="__codelineno-18-2" name="__codelineno-18-2"></a><span class="w"> </span><span class="o">{</span><span class="w"> </span><span class="nv">$addFields</span>:<span class="w"> </span><span class="o">{</span><span class="w"> </span><newField>:<span class="w"> </span><expression>,<span class="w"> </span>...<span class="w"> </span><span class="o">}</span><span class="w"> </span><span class="o">}</span>
|
|
<a id="__codelineno-18-3" name="__codelineno-18-3"></a><span class="o">})</span>
|
|
</code></pre></div></td></tr></table></div>
|
|
<h3 id="group-aggregation-stage"><a href="https://www.mongodb.com/docs/manual/reference/operator/aggregation/group/" title="$group operator docs"><code>$group</code> Aggregation Stage</a></h3>
|
|
<p>The $<code>group</code> stage separates documents into groups according to a "group key". The output is one document for each unique group key.</p>
|
|
<div class="highlight"><table class="highlighttable"><tr><th colspan="2" class="filename"><span class="filename">Bash</span></th></tr><tr><td class="linenos"><div class="linenodiv"><pre><span></span><span class="normal"><a href="#__codelineno-19-1">1</a></span>
|
|
<span class="normal"><a href="#__codelineno-19-2">2</a></span>
|
|
<span class="normal"><a href="#__codelineno-19-3">3</a></span>
|
|
<span class="normal"><a href="#__codelineno-19-4">4</a></span>
|
|
<span class="normal"><a href="#__codelineno-19-5">5</a></span>
|
|
<span class="normal"><a href="#__codelineno-19-6">6</a></span>
|
|
<span class="normal"><a href="#__codelineno-19-7">7</a></span>
|
|
<span class="normal"><a href="#__codelineno-19-8">8</a></span>
|
|
<span class="normal"><a href="#__codelineno-19-9">9</a></span></pre></div></td><td class="code"><div><pre><span></span><code><a id="__codelineno-19-1" name="__codelineno-19-1"></a>db.<collection>.aggregate<span class="o">([</span><span class="w"> </span>
|
|
<a id="__codelineno-19-2" name="__codelineno-19-2"></a><span class="w"> </span><span class="o">{</span><span class="w"> </span>
|
|
<a id="__codelineno-19-3" name="__codelineno-19-3"></a><span class="w"> </span><span class="s2">"</span><span class="nv">$group</span><span class="s2">"</span>:<span class="w"> </span><span class="o">{</span>
|
|
<a id="__codelineno-19-4" name="__codelineno-19-4"></a><span class="w"> </span><span class="s2">"_id"</span>:<span class="w"> </span><span class="s2">"<expression>"</span>,<span class="w"> </span><span class="c1"># Group By Expression (Required)</span>
|
|
<a id="__codelineno-19-5" name="__codelineno-19-5"></a><span class="w"> </span><span class="s2">"<key-1>"</span>:<span class="w"> </span><span class="o">{</span><span class="w"> </span><span class="s2">"<accumulator-1>"</span>:<span class="w"> </span><span class="s2">"<expression-1>"</span><span class="w"> </span><span class="o">}</span>,
|
|
<a id="__codelineno-19-6" name="__codelineno-19-6"></a><span class="w"> </span>...
|
|
<a id="__codelineno-19-7" name="__codelineno-19-7"></a><span class="w"> </span><span class="o">}</span><span class="w"> </span>
|
|
<a id="__codelineno-19-8" name="__codelineno-19-8"></a><span class="w"> </span><span class="o">}</span>
|
|
<a id="__codelineno-19-9" name="__codelineno-19-9"></a><span class="o">])</span>
|
|
</code></pre></div></td></tr></table></div>
|
|
<h3 id="unwind-aggregation-stage"><a href="https://www.mongodb.com/docs/manual/reference/operator/aggregation/unwind/" title="$unwind operator docs"><code>$unwind</code> Aggregation Stage</a></h3>
|
|
<p>Deconstructs an array field from the input documents to output a document for each element.<br />
|
|
Each output document is the input document with the value of the array field replaced by the element</p>
|
|
<div class="highlight"><table class="highlighttable"><tr><th colspan="2" class="filename"><span class="filename">Bash</span></th></tr><tr><td class="linenos"><div class="linenodiv"><pre><span></span><span class="normal"><a href="#__codelineno-20-1"> 1</a></span>
|
|
<span class="normal"><a href="#__codelineno-20-2"> 2</a></span>
|
|
<span class="normal"><a href="#__codelineno-20-3"> 3</a></span>
|
|
<span class="normal"><a href="#__codelineno-20-4"> 4</a></span>
|
|
<span class="normal"><a href="#__codelineno-20-5"> 5</a></span>
|
|
<span class="normal"><a href="#__codelineno-20-6"> 6</a></span>
|
|
<span class="normal"><a href="#__codelineno-20-7"> 7</a></span>
|
|
<span class="normal"><a href="#__codelineno-20-8"> 8</a></span>
|
|
<span class="normal"><a href="#__codelineno-20-9"> 9</a></span>
|
|
<span class="normal"><a href="#__codelineno-20-10">10</a></span>
|
|
<span class="normal"><a href="#__codelineno-20-11">11</a></span></pre></div></td><td class="code"><div><pre><span></span><code><a id="__codelineno-20-1" name="__codelineno-20-1"></a>db.<collection>.aggregate<span class="o">([</span><span class="w"> </span>
|
|
<a id="__codelineno-20-2" name="__codelineno-20-2"></a><span class="w"> </span><span class="o">{</span><span class="w"> </span><span class="s2">"</span><span class="nv">$unwind</span><span class="s2">"</span>:<span class="w"> </span><span class="s2">"<array-key>"</span><span class="w"> </span><span class="o">}</span>
|
|
<a id="__codelineno-20-3" name="__codelineno-20-3"></a>
|
|
<a id="__codelineno-20-4" name="__codelineno-20-4"></a><span class="w"> </span><span class="o">{</span><span class="w"> </span>
|
|
<a id="__codelineno-20-5" name="__codelineno-20-5"></a><span class="w"> </span><span class="s2">"</span><span class="nv">$unwind</span><span class="s2">"</span>:<span class="w"> </span><span class="o">{</span>
|
|
<a id="__codelineno-20-6" name="__codelineno-20-6"></a><span class="w"> </span><span class="s2">"path"</span>:<span class="w"> </span><span class="s2">"<array-key>"</span>,<span class="w"> </span><span class="c1"># array to unwind</span>
|
|
<a id="__codelineno-20-7" name="__codelineno-20-7"></a><span class="w"> </span><span class="s2">"includeArrayIndex"</span>:<span class="w"> </span><span class="s2">"<string>"</span>,<span class="w"> </span><span class="c1"># name of index field</span>
|
|
<a id="__codelineno-20-8" name="__codelineno-20-8"></a><span class="w"> </span><span class="s2">"preserveNullAndEmptyArrays"</span>:<span class="w"> </span><bool>
|
|
<a id="__codelineno-20-9" name="__codelineno-20-9"></a><span class="w"> </span><span class="o">}</span><span class="w"> </span>
|
|
<a id="__codelineno-20-10" name="__codelineno-20-10"></a><span class="w"> </span><span class="o">}</span>
|
|
<a id="__codelineno-20-11" name="__codelineno-20-11"></a><span class="o">]</span>,<span class="w"> </span><span class="o">{</span><span class="w"> </span><span class="s2">"allowDiskUse"</span>:<span class="w"> </span><bool><span class="w"> </span><span class="o">})</span>
|
|
</code></pre></div></td></tr></table></div>
|
|
<h3 id="count-aggregation-stage"><a href="https://www.mongodb.com/docs/manual/reference/operator/aggregation/count/" title="$count operator docs"><code>$count</code> Aggregation Stage</a></h3>
|
|
<div class="highlight"><table class="highlighttable"><tr><th colspan="2" class="filename"><span class="filename">Bash</span></th></tr><tr><td class="linenos"><div class="linenodiv"><pre><span></span><span class="normal"><a href="#__codelineno-21-1">1</a></span>
|
|
<span class="normal"><a href="#__codelineno-21-2">2</a></span>
|
|
<span class="normal"><a href="#__codelineno-21-3">3</a></span></pre></div></td><td class="code"><div><pre><span></span><code><a id="__codelineno-21-1" name="__codelineno-21-1"></a>db.<collection>.aggregate<span class="o">([</span><span class="w"> </span>
|
|
<a id="__codelineno-21-2" name="__codelineno-21-2"></a><span class="w"> </span><span class="o">{</span><span class="w"> </span><span class="s2">"</span><span class="nv">$count</span><span class="s2">"</span>:<span class="w"> </span><span class="s2">"<count-key>"</span><span class="w"> </span><span class="o">}</span>
|
|
<a id="__codelineno-21-3" name="__codelineno-21-3"></a><span class="o">])</span>
|
|
</code></pre></div></td></tr></table></div>
|
|
<h3 id="sort-aggregation-stage"><a href="https://www.mongodb.com/docs/manual/reference/operator/aggregation/sort/" title="$sort operator docs"><code>$sort</code> Aggregation Stage</a></h3>
|
|
<div class="highlight"><table class="highlighttable"><tr><th colspan="2" class="filename"><span class="filename">Bash</span></th></tr><tr><td class="linenos"><div class="linenodiv"><pre><span></span><span class="normal"><a href="#__codelineno-22-1">1</a></span>
|
|
<span class="normal"><a href="#__codelineno-22-2">2</a></span>
|
|
<span class="normal"><a href="#__codelineno-22-3">3</a></span>
|
|
<span class="normal"><a href="#__codelineno-22-4">4</a></span>
|
|
<span class="normal"><a href="#__codelineno-22-5">5</a></span>
|
|
<span class="normal"><a href="#__codelineno-22-6">6</a></span>
|
|
<span class="normal"><a href="#__codelineno-22-7">7</a></span>
|
|
<span class="normal"><a href="#__codelineno-22-8">8</a></span>
|
|
<span class="normal"><a href="#__codelineno-22-9">9</a></span></pre></div></td><td class="code"><div><pre><span></span><code><a id="__codelineno-22-1" name="__codelineno-22-1"></a>db.<collection>.aggregate<span class="o">([</span><span class="w"> </span>
|
|
<a id="__codelineno-22-2" name="__codelineno-22-2"></a><span class="w"> </span><span class="o">{</span><span class="w"> </span>
|
|
<a id="__codelineno-22-3" name="__codelineno-22-3"></a><span class="w"> </span><span class="s2">"</span><span class="nv">$sort</span><span class="s2">"</span>:<span class="w"> </span><span class="o">{</span><span class="w"> </span>
|
|
<a id="__codelineno-22-4" name="__codelineno-22-4"></a><span class="w"> </span><span class="s2">"<key-1>"</span>:<span class="w"> </span><span class="s2">"<sort order>"</span>,<span class="w"> </span>
|
|
<a id="__codelineno-22-5" name="__codelineno-22-5"></a><span class="w"> </span><span class="s2">"<key-2>"</span>:<span class="w"> </span><span class="s2">"<sort order>"</span>,<span class="w"> </span>
|
|
<a id="__codelineno-22-6" name="__codelineno-22-6"></a><span class="w"> </span>...<span class="w"> </span>
|
|
<a id="__codelineno-22-7" name="__codelineno-22-7"></a><span class="w"> </span><span class="o">}</span><span class="w"> </span>
|
|
<a id="__codelineno-22-8" name="__codelineno-22-8"></a><span class="w"> </span><span class="o">}</span>
|
|
<a id="__codelineno-22-9" name="__codelineno-22-9"></a><span class="o">]</span>,<span class="w"> </span><span class="o">{</span><span class="w"> </span><span class="s2">"allowDiskUse"</span>:<span class="w"> </span><bool><span class="w"> </span><span class="o">})</span>
|
|
</code></pre></div></td></tr></table></div>
|
|
<blockquote>
|
|
<p><strong>Note</strong>: can take advantage of indexes if early int the pipeline and before any <code>%project</code>, <code>$group</code> and <code>$unwind</code><br />
|
|
<strong>Note</strong>: By default <code>$sort</code> will use up to 10 MB of RAM. Setting <code>allowDiskUse: true</code> will allow for larger sorts</p>
|
|
</blockquote>
|
|
<h3 id="skip-aggregation-stage"><a href="https://www.mongodb.com/docs/manual/reference/operator/aggregation/skip/" title="$skip operator docs"><code>$skip</code> Aggregation Stage</a></h3>
|
|
<div class="highlight"><table class="highlighttable"><tr><th colspan="2" class="filename"><span class="filename">Bash</span></th></tr><tr><td class="linenos"><div class="linenodiv"><pre><span></span><span class="normal"><a href="#__codelineno-23-1">1</a></span>
|
|
<span class="normal"><a href="#__codelineno-23-2">2</a></span>
|
|
<span class="normal"><a href="#__codelineno-23-3">3</a></span></pre></div></td><td class="code"><div><pre><span></span><code><a id="__codelineno-23-1" name="__codelineno-23-1"></a>db.<collection>.aggregate<span class="o">([</span><span class="w"> </span>
|
|
<a id="__codelineno-23-2" name="__codelineno-23-2"></a><span class="w"> </span><span class="o">{</span><span class="w"> </span><span class="s2">"</span><span class="nv">$skip</span><span class="s2">"</span>:<span class="w"> </span><span class="s2">"<positive 64-bit integer>"</span><span class="w"> </span><span class="o">}</span>
|
|
<a id="__codelineno-23-3" name="__codelineno-23-3"></a><span class="o">])</span>
|
|
</code></pre></div></td></tr></table></div>
|
|
<h3 id="limit-aggregation-stage"><a href="https://www.mongodb.com/docs/manual/reference/operator/aggregation/limit/" title="$limit operator docs"><code>$limit</code> Aggregation Stage</a></h3>
|
|
<div class="highlight"><table class="highlighttable"><tr><th colspan="2" class="filename"><span class="filename">Bash</span></th></tr><tr><td class="linenos"><div class="linenodiv"><pre><span></span><span class="normal"><a href="#__codelineno-24-1">1</a></span>
|
|
<span class="normal"><a href="#__codelineno-24-2">2</a></span>
|
|
<span class="normal"><a href="#__codelineno-24-3">3</a></span></pre></div></td><td class="code"><div><pre><span></span><code><a id="__codelineno-24-1" name="__codelineno-24-1"></a>db.<collection>.aggregate<span class="o">([</span><span class="w"> </span>
|
|
<a id="__codelineno-24-2" name="__codelineno-24-2"></a><span class="w"> </span><span class="o">{</span><span class="w"> </span><span class="s2">"</span><span class="nv">$limit</span><span class="s2">"</span>:<span class="w"> </span><span class="s2">"<positive 64-bit integer>"</span><span class="w"> </span><span class="o">}</span>
|
|
<a id="__codelineno-24-3" name="__codelineno-24-3"></a><span class="o">])</span>
|
|
</code></pre></div></td></tr></table></div>
|
|
<h3 id="lookup-aggregation-stage"><a href="https://www.mongodb.com/docs/manual/reference/operator/aggregation/lookup/" title="$look operator docs"><code>$lookup</code> Aggregation Stage</a></h3>
|
|
<p>Performs a left outer join to a collection <em>in the same database</em> to filter in documents from the "joined" collection for processing.<br />
|
|
The <code>$lookup</code> stage adds a new array field to each input document. The new array field contains the matching documents from the "joined" collection.</p>
|
|
<blockquote>
|
|
<p><strong>Note</strong>: To combine elements from two different collections, use the <a href="https://www.mongodb.com/docs/manual/reference/operator/aggregation/unionWith/" title="$unionWith operator docs"><code>$unionWith</code></a> pipeline stage.</p>
|
|
</blockquote>
|
|
<div class="highlight"><table class="highlighttable"><tr><th colspan="2" class="filename"><span class="filename">Bash</span></th></tr><tr><td class="linenos"><div class="linenodiv"><pre><span></span><span class="normal"><a href="#__codelineno-25-1"> 1</a></span>
|
|
<span class="normal"><a href="#__codelineno-25-2"> 2</a></span>
|
|
<span class="normal"><a href="#__codelineno-25-3"> 3</a></span>
|
|
<span class="normal"><a href="#__codelineno-25-4"> 4</a></span>
|
|
<span class="normal"><a href="#__codelineno-25-5"> 5</a></span>
|
|
<span class="normal"><a href="#__codelineno-25-6"> 6</a></span>
|
|
<span class="normal"><a href="#__codelineno-25-7"> 7</a></span>
|
|
<span class="normal"><a href="#__codelineno-25-8"> 8</a></span>
|
|
<span class="normal"><a href="#__codelineno-25-9"> 9</a></span>
|
|
<span class="normal"><a href="#__codelineno-25-10">10</a></span></pre></div></td><td class="code"><div><pre><span></span><code><a id="__codelineno-25-1" name="__codelineno-25-1"></a>db.<collection>.aggregate<span class="o">([</span><span class="w"> </span>
|
|
<a id="__codelineno-25-2" name="__codelineno-25-2"></a><span class="w"> </span><span class="o">{</span>
|
|
<a id="__codelineno-25-3" name="__codelineno-25-3"></a><span class="w"> </span><span class="s2">"</span><span class="nv">$lookup</span><span class="s2">"</span>:<span class="w"> </span><span class="o">{</span>
|
|
<a id="__codelineno-25-4" name="__codelineno-25-4"></a><span class="w"> </span><span class="s2">"from"</span>:<span class="w"> </span><span class="s2">"<foreign-collection>"</span>,
|
|
<a id="__codelineno-25-5" name="__codelineno-25-5"></a><span class="w"> </span><span class="s2">"localField"</span>:<span class="w"> </span><span class="s2">"<key>"</span>,
|
|
<a id="__codelineno-25-6" name="__codelineno-25-6"></a><span class="w"> </span><span class="s2">"foreignField"</span>:<span class="w"> </span><span class="s2">"<foreign-collection>.<key>"</span>,
|
|
<a id="__codelineno-25-7" name="__codelineno-25-7"></a><span class="w"> </span><span class="s2">"as"</span>:<span class="w"> </span><span class="s2">"<output array field>"</span>
|
|
<a id="__codelineno-25-8" name="__codelineno-25-8"></a><span class="w"> </span><span class="o">}</span>
|
|
<a id="__codelineno-25-9" name="__codelineno-25-9"></a><span class="w"> </span><span class="o">}</span>
|
|
<a id="__codelineno-25-10" name="__codelineno-25-10"></a><span class="o">])</span>
|
|
</code></pre></div></td></tr></table></div>
|
|
<h3 id="graphlookup-aggregation-stage"><a href="https://www.mongodb.com/docs/upcoming/reference/operator/aggregation/graphLookup/" title="$graphLookup operator docs"><code>$graphLookup</code> Aggregation Stage</a></h3>
|
|
<p>Performs a recursive search on a collection, with options for restricting the search by recursion depth and query filter.</p>
|
|
<p>The collection on which the aggregation is performed and the <code>from</code> collection can be the same (in-collection search) or different (cross-collection search)</p>
|
|
<div class="highlight"><table class="highlighttable"><tr><th colspan="2" class="filename"><span class="filename">Bash</span></th></tr><tr><td class="linenos"><div class="linenodiv"><pre><span></span><span class="normal"><a href="#__codelineno-26-1"> 1</a></span>
|
|
<span class="normal"><a href="#__codelineno-26-2"> 2</a></span>
|
|
<span class="normal"><a href="#__codelineno-26-3"> 3</a></span>
|
|
<span class="normal"><a href="#__codelineno-26-4"> 4</a></span>
|
|
<span class="normal"><a href="#__codelineno-26-5"> 5</a></span>
|
|
<span class="normal"><a href="#__codelineno-26-6"> 6</a></span>
|
|
<span class="normal"><a href="#__codelineno-26-7"> 7</a></span>
|
|
<span class="normal"><a href="#__codelineno-26-8"> 8</a></span>
|
|
<span class="normal"><a href="#__codelineno-26-9"> 9</a></span>
|
|
<span class="normal"><a href="#__codelineno-26-10">10</a></span>
|
|
<span class="normal"><a href="#__codelineno-26-11">11</a></span>
|
|
<span class="normal"><a href="#__codelineno-26-12">12</a></span>
|
|
<span class="normal"><a href="#__codelineno-26-13">13</a></span>
|
|
<span class="normal"><a href="#__codelineno-26-14">14</a></span></pre></div></td><td class="code"><div><pre><span></span><code><a id="__codelineno-26-1" name="__codelineno-26-1"></a>db.<collection>.aggregate<span class="o">([</span>
|
|
<a id="__codelineno-26-2" name="__codelineno-26-2"></a><span class="w"> </span><span class="o">{</span>
|
|
<a id="__codelineno-26-3" name="__codelineno-26-3"></a><span class="w"> </span><span class="nv">$graphLookup</span>:<span class="w"> </span><span class="o">{</span>
|
|
<a id="__codelineno-26-4" name="__codelineno-26-4"></a><span class="w"> </span>from:<span class="w"> </span><collection>,<span class="w"> </span><span class="c1"># starting collection of the search</span>
|
|
<a id="__codelineno-26-5" name="__codelineno-26-5"></a><span class="w"> </span>startWith:<span class="w"> </span><expression>,<span class="w"> </span><span class="c1"># initial value(s) of search</span>
|
|
<a id="__codelineno-26-6" name="__codelineno-26-6"></a><span class="w"> </span>connectFromField:<span class="w"> </span><string>,<span class="w"> </span><span class="c1"># source of the connection</span>
|
|
<a id="__codelineno-26-7" name="__codelineno-26-7"></a><span class="w"> </span>connectToField:<span class="w"> </span><string>,<span class="w"> </span><span class="c1"># destination of the connection</span>
|
|
<a id="__codelineno-26-8" name="__codelineno-26-8"></a><span class="w"> </span>as:<span class="w"> </span><string>,<span class="w"> </span><span class="c1"># array of found documents</span>
|
|
<a id="__codelineno-26-9" name="__codelineno-26-9"></a><span class="w"> </span>maxDepth:<span class="w"> </span><number>,<span class="w"> </span><span class="c1"># recursive search depth limit (steps inside from collection)</span>
|
|
<a id="__codelineno-26-10" name="__codelineno-26-10"></a><span class="w"> </span>depthField:<span class="w"> </span><string>,<span class="w"> </span><span class="c1"># field containing distance from start</span>
|
|
<a id="__codelineno-26-11" name="__codelineno-26-11"></a><span class="w"> </span>restrictSearchWithMatch:<span class="w"> </span><document><span class="w"> </span><span class="c1"># filter on found documents</span>
|
|
<a id="__codelineno-26-12" name="__codelineno-26-12"></a><span class="w"> </span><span class="o">}</span>
|
|
<a id="__codelineno-26-13" name="__codelineno-26-13"></a><span class="w"> </span><span class="o">}</span>
|
|
<a id="__codelineno-26-14" name="__codelineno-26-14"></a><span class="o">]</span>,<span class="w"> </span><span class="o">{</span><span class="w"> </span>allowDiskUse:<span class="w"> </span><span class="nb">true</span><span class="w"> </span><span class="o">})</span>
|
|
</code></pre></div></td></tr></table></div>
|
|
<blockquote>
|
|
<p><strong>Note</strong>: Having the <code>connectToField</code> indexed will improve search performance<br />
|
|
<strong>Warn</strong>: Can exceed the <code>100 Mb</code> memory limit even with <code>{ allowDiskUse: true }</code></p>
|
|
</blockquote>
|
|
<h3 id="sortbycount-aggregation-stage"><a href="https://www.mongodb.com/docs/upcoming/reference/operator/aggregation/sortByCount/" title="$sortByCount operator docs"><code>$sortByCount</code> Aggregation Stage</a></h3>
|
|
<p>Groups incoming documents based on the value of a specified expression, then computes the count of documents in each distinct group.</p>
|
|
<p>Each output document contains two fields: an <code>_id</code> field containing the distinct grouping value, and a <code>count</code> field containing the number of documents belonging to that grouping or category.</p>
|
|
<p>The documents are sorted by count in descending order.</p>
|
|
<div class="highlight"><table class="highlighttable"><tr><th colspan="2" class="filename"><span class="filename">Bash</span></th></tr><tr><td class="linenos"><div class="linenodiv"><pre><span></span><span class="normal"><a href="#__codelineno-27-1">1</a></span>
|
|
<span class="normal"><a href="#__codelineno-27-2">2</a></span>
|
|
<span class="normal"><a href="#__codelineno-27-3">3</a></span></pre></div></td><td class="code"><div><pre><span></span><code><a id="__codelineno-27-1" name="__codelineno-27-1"></a>db.<collection>.aggregate<span class="o">([</span>
|
|
<a id="__codelineno-27-2" name="__codelineno-27-2"></a><span class="w"> </span><span class="o">{</span><span class="w"> </span><span class="nv">$sortByCount</span>:<span class="w"> </span><expression><span class="w"> </span><span class="o">}</span>
|
|
<a id="__codelineno-27-3" name="__codelineno-27-3"></a><span class="o">])</span>
|
|
</code></pre></div></td></tr></table></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</article>
|
|
</div>
|
|
|
|
|
|
<script>var target=document.getElementById(location.hash.slice(1));target&&target.name&&(target.checked=target.name.startsWith("__tabbed_"))</script>
|
|
</div>
|
|
|
|
<button type="button" class="md-top md-icon" data-md-component="top" hidden>
|
|
|
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M13 20h-2V8l-5.5 5.5-1.42-1.42L12 4.16l7.92 7.92-1.42 1.42L13 8z"/></svg>
|
|
Back to top
|
|
</button>
|
|
|
|
</main>
|
|
|
|
<footer class="md-footer">
|
|
|
|
|
|
|
|
<nav class="md-footer__inner md-grid" aria-label="Footer" >
|
|
|
|
|
|
<a href="sql.html" class="md-footer__link md-footer__link--prev" aria-label="Previous: SQL">
|
|
<div class="md-footer__button md-icon">
|
|
|
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M20 11v2H8l5.5 5.5-1.42 1.42L4.16 12l7.92-7.92L13.5 5.5 8 11z"/></svg>
|
|
</div>
|
|
<div class="md-footer__title">
|
|
<span class="md-footer__direction">
|
|
Previous
|
|
</span>
|
|
<div class="md-ellipsis">
|
|
SQL
|
|
</div>
|
|
</div>
|
|
</a>
|
|
|
|
|
|
|
|
<a href="../languages/html/html.html" class="md-footer__link md-footer__link--next" aria-label="Next: HTML">
|
|
<div class="md-footer__title">
|
|
<span class="md-footer__direction">
|
|
Next
|
|
</span>
|
|
<div class="md-ellipsis">
|
|
HTML
|
|
</div>
|
|
</div>
|
|
<div class="md-footer__button md-icon">
|
|
|
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M4 11v2h12l-5.5 5.5 1.42 1.42L19.84 12l-7.92-7.92L10.5 5.5 16 11z"/></svg>
|
|
</div>
|
|
</a>
|
|
|
|
</nav>
|
|
|
|
|
|
<div class="md-footer-meta md-typeset">
|
|
<div class="md-footer-meta__inner md-grid">
|
|
<div class="md-copyright">
|
|
|
|
<div class="md-copyright__highlight">
|
|
MIT
|
|
</div>
|
|
|
|
|
|
Made with
|
|
<a href="https://squidfunk.github.io/mkdocs-material/" target="_blank" rel="noopener">
|
|
Material for MkDocs
|
|
</a>
|
|
|
|
</div>
|
|
|
|
<div class="md-social">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<a href="https://hachyderm.io/@m_lamonaca" target="_blank" rel="noopener me" title="hachyderm.io" class="md-social__link">
|
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><!--! Font Awesome Free 6.6.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2024 Fonticons, Inc.--><path d="M433 179.11c0-97.2-63.71-125.7-63.71-125.7-62.52-28.7-228.56-28.4-290.48 0 0 0-63.72 28.5-63.72 125.7 0 115.7-6.6 259.4 105.63 289.1 40.51 10.7 75.32 13 103.33 11.4 50.81-2.8 79.32-18.1 79.32-18.1l-1.7-36.9s-36.31 11.4-77.12 10.1c-40.41-1.4-83-4.4-89.63-54a102.5 102.5 0 0 1-.9-13.9c85.63 20.9 158.65 9.1 178.75 6.7 56.12-6.7 105-41.3 111.23-72.9 9.8-49.8 9-121.5 9-121.5m-75.12 125.2h-46.63v-114.2c0-49.7-64-51.6-64 6.9v62.5h-46.33V197c0-58.5-64-56.6-64-6.9v114.2H90.19c0-122.1-5.2-147.9 18.41-175 25.9-28.9 79.82-30.8 103.83 6.1l11.6 19.5 11.6-19.5c24.11-37.1 78.12-34.8 103.83-6.1 23.71 27.3 18.4 53 18.4 175z"/></svg>
|
|
</a>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<a href="https://github.com/m-lamonaca" target="_blank" rel="noopener" title="github.com" class="md-social__link">
|
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 496 512"><!--! Font Awesome Free 6.6.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2024 Fonticons, Inc.--><path d="M165.9 397.4c0 2-2.3 3.6-5.2 3.6-3.3.3-5.6-1.3-5.6-3.6 0-2 2.3-3.6 5.2-3.6 3-.3 5.6 1.3 5.6 3.6m-31.1-4.5c-.7 2 1.3 4.3 4.3 4.9 2.6 1 5.6 0 6.2-2s-1.3-4.3-4.3-5.2c-2.6-.7-5.5.3-6.2 2.3m44.2-1.7c-2.9.7-4.9 2.6-4.6 4.9.3 2 2.9 3.3 5.9 2.6 2.9-.7 4.9-2.6 4.6-4.6-.3-1.9-3-3.2-5.9-2.9M244.8 8C106.1 8 0 113.3 0 252c0 110.9 69.8 205.8 169.5 239.2 12.8 2.3 17.3-5.6 17.3-12.1 0-6.2-.3-40.4-.3-61.4 0 0-70 15-84.7-29.8 0 0-11.4-29.1-27.8-36.6 0 0-22.9-15.7 1.6-15.4 0 0 24.9 2 38.6 25.8 21.9 38.6 58.6 27.5 72.9 20.9 2.3-16 8.8-27.1 16-33.7-55.9-6.2-112.3-14.3-112.3-110.5 0-27.5 7.6-41.3 23.6-58.9-2.6-6.5-11.1-33.3 2.6-67.9 20.9-6.5 69 27 69 27 20-5.6 41.5-8.5 62.8-8.5s42.8 2.9 62.8 8.5c0 0 48.1-33.6 69-27 13.7 34.7 5.2 61.4 2.6 67.9 16 17.7 25.8 31.5 25.8 58.9 0 96.5-58.9 104.2-114.8 110.5 9.2 7.9 17 22.9 17 46.4 0 33.7-.3 75.4-.3 83.6 0 6.5 4.6 14.4 17.3 12.1C428.2 457.8 496 362.9 496 252 496 113.3 383.5 8 244.8 8M97.2 352.9c-1.3 1-1 3.3.7 5.2 1.6 1.6 3.9 2.3 5.2 1 1.3-1 1-3.3-.7-5.2-1.6-1.6-3.9-2.3-5.2-1m-10.8-8.1c-.7 1.3.3 2.9 2.3 3.9 1.6 1 3.6.7 4.3-.7.7-1.3-.3-2.9-2.3-3.9-2-.6-3.6-.3-4.3.7m32.4 35.6c-1.6 1.3-1 4.3 1.3 6.2 2.3 2.3 5.2 2.6 6.5 1 1.3-1.3.7-4.3-1.3-6.2-2.2-2.3-5.2-2.6-6.5-1m-11.4-14.7c-1.6 1-1.6 3.6 0 5.9s4.3 3.3 5.6 2.3c1.6-1.3 1.6-3.9 0-6.2-1.4-2.3-4-3.3-5.6-2"/></svg>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
</div>
|
|
</footer>
|
|
|
|
</div>
|
|
<div class="md-dialog" data-md-component="dialog">
|
|
<div class="md-dialog__inner md-typeset"></div>
|
|
</div>
|
|
|
|
|
|
<script id="__config" type="application/json">{"base": "..", "features": ["navigation.instant", "navigation.indexes", "navigation.tracking", "navigation.pruning", "navigation.sections", "navigation.top", "navigation.tabs", "navigation.tabs.sticky", "navigation.footer", "toc.follow", "content.code.copy"], "search": "../assets/javascripts/workers/search.07f07601.min.js", "translations": {"clipboard.copied": "Copied to clipboard", "clipboard.copy": "Copy to clipboard", "search.result.more.one": "1 more on this page", "search.result.more.other": "# more on this page", "search.result.none": "No matching documents", "search.result.one": "1 matching document", "search.result.other": "# matching documents", "search.result.placeholder": "Type to start searching", "search.result.term.missing": "Missing", "select.version": "Select version"}}</script>
|
|
|
|
|
|
<script src="../assets/javascripts/bundle.56dfad97.min.js"></script>
|
|
|
|
|
|
</body>
|
|
</html> |