\documentclass[10pt,a4paper]{article} % Packages \usepackage{fancyhdr} % For header and footer \usepackage{multicol} % Allows multicols in tables \usepackage{tabularx} % Intelligent column widths \usepackage{tabulary} % Used in header and footer \usepackage{hhline} % Border under tables \usepackage{graphicx} % For images \usepackage{xcolor} % For hex colours %\usepackage[utf8x]{inputenc} % For unicode character support \usepackage[T1]{fontenc} % Without this we get weird character replacements \usepackage{colortbl} % For coloured tables \usepackage{setspace} % For line height \usepackage{lastpage} % Needed for total page number \usepackage{seqsplit} % Splits long words. %\usepackage{opensans} % Can't make this work so far. Shame. Would be lovely. \usepackage[normalem]{ulem} % For underlining links % Most of the following are not required for the majority % of cheat sheets but are needed for some symbol support. \usepackage{amsmath} % Symbols \usepackage{MnSymbol} % Symbols \usepackage{wasysym} % Symbols %\usepackage[english,german,french,spanish,italian]{babel} % Languages % Document Info \author{Zeineb Zt and Kawther br (zeineb and kawther)} \pdfinfo{ /Title (mongodb.pdf) /Creator (Cheatography) /Author (Zeineb Zt and Kawther br (zeineb and kawther)) /Subject (MongoDB Cheat Sheet) } % Lengths and widths \addtolength{\textwidth}{6cm} \addtolength{\textheight}{-1cm} \addtolength{\hoffset}{-3cm} \addtolength{\voffset}{-2cm} \setlength{\tabcolsep}{0.2cm} % Space between columns \setlength{\headsep}{-12pt} % Reduce space between header and content \setlength{\headheight}{85pt} % If less, LaTeX automatically increases it \renewcommand{\footrulewidth}{0pt} % Remove footer line \renewcommand{\headrulewidth}{0pt} % Remove header line \renewcommand{\seqinsert}{\ifmmode\allowbreak\else\-\fi} % Hyphens in seqsplit % This two commands together give roughly % the right line height in the tables \renewcommand{\arraystretch}{1.3} \onehalfspacing % Commands \newcommand{\SetRowColor}[1]{\noalign{\gdef\RowColorName{#1}}\rowcolor{\RowColorName}} % Shortcut for row colour \newcommand{\mymulticolumn}[3]{\multicolumn{#1}{>{\columncolor{\RowColorName}}#2}{#3}} % For coloured multi-cols \newcolumntype{x}[1]{>{\raggedright}p{#1}} % New column types for ragged-right paragraph columns \newcommand{\tn}{\tabularnewline} % Required as custom column type in use % Font and Colours \definecolor{HeadBackground}{HTML}{333333} \definecolor{FootBackground}{HTML}{666666} \definecolor{TextColor}{HTML}{333333} \definecolor{DarkBackground}{HTML}{1FA310} \definecolor{LightBackground}{HTML}{F1F9F0} \renewcommand{\familydefault}{\sfdefault} \color{TextColor} % Header and Footer \pagestyle{fancy} \fancyhead{} % Set header to blank \fancyfoot{} % Set footer to blank \fancyhead[L]{ \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{C} \SetRowColor{DarkBackground} \vspace{-7pt} {\parbox{\dimexpr\textwidth-2\fboxsep\relax}{\noindent \hspace*{-6pt}\includegraphics[width=5.8cm]{/web/www.cheatography.com/public/images/cheatography_logo.pdf}} } \end{tabulary} \columnbreak \begin{tabulary}{11cm}{L} \vspace{-2pt}\large{\bf{\textcolor{DarkBackground}{\textrm{MongoDB Cheat Sheet}}}} \\ \normalsize{by \textcolor{DarkBackground}{Zeineb Zt and Kawther br (zeineb and kawther)} via \textcolor{DarkBackground}{\uline{cheatography.com/129500/cs/25636/}}} \end{tabulary} \end{multicols}} \fancyfoot[L]{ \footnotesize \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{LL} \SetRowColor{FootBackground} \mymulticolumn{2}{p{5.377cm}}{\bf\textcolor{white}{Cheatographer}} \\ \vspace{-2pt}Zeineb Zt and Kawther br (zeineb and kawther) \\ \uline{cheatography.com/zeineb-and-kawther} \\ \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Cheat Sheet}} \\ \vspace{-2pt}Published 9th December, 2020.\\ Updated 30th December, 2020.\\ Page {\thepage} of \pageref{LastPage}. \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Sponsor}} \\ \SetRowColor{white} \vspace{-5pt} %\includegraphics[width=48px,height=48px]{dave.jpeg} Measure your website readability!\\ www.readability-score.com \end{tabulary} \end{multicols}} \begin{document} \raggedright \raggedcolumns % Set font size to small. Switch to any value % from this page to resize cheat sheet text: % www.emerson.emory.edu/services/latex/latex_169.html \footnotesize % Small font. \begin{multicols*}{4} \begin{tabularx}{3.833cm}{x{0.99557 cm} x{2.43743 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{3.833cm}}{\bf\textcolor{white}{Commandes Shell Basique}} \tn % Row 0 \SetRowColor{LightBackground} mongo & Connecter au client Mongo \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} mongod & Connecter au serveur Mongo \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} \seqsplit{db.getMongo()} & Renvoie le Mongo() objet de connexion pour la connexion actuelle. \tn % Row Count 5 (+ 3) % Row 3 \SetRowColor{white} \seqsplit{db.version()} & Renvoie la version de serveur Mongo \tn % Row Count 7 (+ 2) % Row 4 \SetRowColor{LightBackground} help & Obtenir de l'aide pour le contexte dans lequel vous vous trouvez \tn % Row Count 10 (+ 3) % Row 5 \SetRowColor{white} exit & Quitter le Shell \tn % Row Count 11 (+ 1) % Row 6 \SetRowColor{LightBackground} show users & Afficher les utilisateurs de la base de données actuelle \tn % Row Count 14 (+ 3) % Row 7 \SetRowColor{white} show databases & Lister les bases de données sur le serveur \tn % Row Count 16 (+ 2) % Row 8 \SetRowColor{LightBackground} use \textless{}database\textgreater{} & Sélectionner et utiliser une base de données \tn % Row Count 18 (+ 2) % Row 9 \SetRowColor{white} show \seqsplit{collections} & Lister les collections de la base de données actuelle \tn % Row Count 20 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{3.833cm}{x{1.68217 cm} x{1.75083 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{3.833cm}}{\bf\textcolor{white}{Commandes DB}} \tn % Row 0 \SetRowColor{LightBackground} copyDatabases() & Copie une base de données dans une autre base de données \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} db.getName() & Renvoie le nom de la base de données actuelle. \tn % Row Count 6 (+ 3) % Row 2 \SetRowColor{LightBackground} db.dropDatabases() & Supprime la base de données actuelle. \tn % Row Count 8 (+ 2) % Row 3 \SetRowColor{white} db.getLastError() & Renvoie le dernière erreur. \tn % Row Count 10 (+ 2) % Row 4 \SetRowColor{LightBackground} \seqsplit{db.getCollectionNames()} & Répertorie toutes les collections de la base de données actuelle. \tn % Row Count 14 (+ 4) % Row 5 \SetRowColor{white} \seqsplit{db.getCollectionInfo()} & Renvoie les informations pour toutes les collections et vues de la base de données actuelle \tn % Row Count 19 (+ 5) % Row 6 \SetRowColor{LightBackground} db.createView() & Crée une vue. \tn % Row Count 20 (+ 1) % Row 7 \SetRowColor{white} db.stats() & Renvoie un document qui rend compte de l'état de la base de données actuelle. \tn % Row Count 24 (+ 4) % Row 8 \SetRowColor{LightBackground} db.serverStatus() & Renvoie un document qui fournit une vue d'ensemble de l'état du processus de base de données. \tn % Row Count 29 (+ 5) % Row 9 \SetRowColor{white} use nameDB et db.collection.insert(\{\}) & Création de DB \tn % Row Count 31 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{3.833cm}{x{1.7165 cm} x{1.7165 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{3.833cm}}{\bf\textcolor{white}{Commandes Collection}} \tn % Row 0 \SetRowColor{LightBackground} \seqsplit{db.nameCollection.renameCollection()} & Modifie le nom d'une collection. \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} db.createCollection(\{name,options\}) / db.nameCollection.insert(\{options\}) & Crée une nouvelle collection \tn % Row Count 6 (+ 4) % Row 2 \SetRowColor{LightBackground} \seqsplit{db.collection.count()} & Renvoyer le nombre de documents dans une collection \tn % Row Count 9 (+ 3) % Row 3 \SetRowColor{white} \seqsplit{db.collection.dataSize()} & Renvoie la taille de la collection \tn % Row Count 11 (+ 2) % Row 4 \SetRowColor{LightBackground} \seqsplit{db.collection.explain()} & Renvoie des informations sur l'exécution de la requête de diverses méthodes. \tn % Row Count 15 (+ 4) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{3.833cm}{x{1.7165 cm} x{1.7165 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{3.833cm}}{\bf\textcolor{white}{Commandes Index}} \tn % Row 0 \SetRowColor{LightBackground} \seqsplit{db.collection.createIndex()} / \seqsplit{db.Etudiants.ensureIndex()} & Construit un index sur une collection. \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} \seqsplit{db.collection.dropIndex()} & Supprime un index spécifié sur une collection. \tn % Row Count 6 (+ 3) % Row 2 \SetRowColor{LightBackground} \seqsplit{db.collection.getIndexes()} & Renvoie un tableau de documents décrivant les index existants sur une collection. \tn % Row Count 11 (+ 5) % Row 3 \SetRowColor{white} \seqsplit{db.collection.reIndex()} & Reconstruit tous les index existants sur une collection. \tn % Row Count 14 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{3.833cm}{x{1.7165 cm} x{1.7165 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{3.833cm}}{\bf\textcolor{white}{Commandes CRUD}} \tn % Row 0 \SetRowColor{LightBackground} \seqsplit{db.collection.insert()} & Crée un nouveau document dans une collection. \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} \seqsplit{db.collection.insertOne} (documents) & Insère un nouveau document(qui contient des champs de type single ou array ou record) dans une collection. \tn % Row Count 9 (+ 6) % Row 2 \SetRowColor{LightBackground} db.collection.insertMany({[}documents{]}) & Insère plusieurs nouveaux documents dans une collection. \tn % Row Count 12 (+ 3) % Row 3 \SetRowColor{white} db.collection.update(\{filter\},\{\$set:document\},\{multi:true\}) & Modifie plusieurs document dans une collection. \tn % Row Count 15 (+ 3) % Row 4 \SetRowColor{LightBackground} db.collection.updateMany(\{filter\},\{\$set:document\}) & Modifie plusieurs document dans une collection. \tn % Row Count 18 (+ 3) % Row 5 \SetRowColor{white} db.collection.updateOne(\{filter\},\{\$set:document\}) & Modifie un document dans une collection. \tn % Row Count 21 (+ 3) % Row 6 \SetRowColor{LightBackground} db.collection.deleteOne(\{filter\},\{document\}) & Supprime un seul document dans une collection. \tn % Row Count 24 (+ 3) % Row 7 \SetRowColor{white} \seqsplit{db.collection.deleteMany(filter},document) & Supprime plusieurs documents dans une collection. \tn % Row Count 27 (+ 3) % Row 8 \SetRowColor{LightBackground} db.collection.remove(\textless{}query\textgreater{},\textless{}justOne\textgreater{}) & Supprime les documents d'une collection. \tn % Row Count 29 (+ 2) % Row 9 \SetRowColor{white} db.collection.update(\{filter\},\{\$unset:document\}) & Supprime un champ dans un document dans une collection. \tn % Row Count 32 (+ 3) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{3.833cm}{x{1.7165 cm} x{1.7165 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{3.833cm}}{\bf\textcolor{white}{Commandes CRUD (cont)}} \tn % Row 10 \SetRowColor{LightBackground} db.collection.update(\{\}, \{ \$unset: document \}, \{ multi: true \} ) & supprimer un champ de tous les documents. \tn % Row Count 4 (+ 4) % Row 11 \SetRowColor{white} \seqsplit{db.collection.find().pretty()} & Afficher tous les documents de la collection. . \tn % Row Count 7 (+ 3) % Row 12 \SetRowColor{LightBackground} db.Collection.find(\{filter\}).pretty() & Afficher un les documents qui spécifient le filter. \tn % Row Count 10 (+ 3) % Row 13 \SetRowColor{white} \seqsplit{db.collection.findOne()} & Renvoie un seul document. \tn % Row Count 12 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{3.833cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{3.833cm}}{\bf\textcolor{white}{Opérateurs}} \tn \SetRowColor{white} \mymulticolumn{1}{x{3.833cm}}{~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ {\bf{{\emph{Comparaison }}}} \newline % Row Count 2 (+ 2) {\bf{\$gt}} {\bf{:}} correspond à des valeurs supérieures à la valeur \newline % Row Count 4 (+ 2) {\bf{\$gte }}{\bf{:}} correspond à des valeurs supérieures ou égale à la valeur \newline % Row Count 6 (+ 2) {\bf{\$lt}} {\bf{:}} correspond à des valeurs inferieurs à la valeur \newline % Row Count 8 (+ 2) {\bf{\$lte}} {\bf{:}} correspond à des valeurs inferieurs ou égale à la valeur \newline % Row Count 10 (+ 2) {\bf{\$in}} {\bf{:}} correspond aux valeurs fournies dans un tableau \newline % Row Count 12 (+ 2) {\bf{\$ne}} {\bf{:}} correspond à toutes les valeurs qui ne sont pas ~ ~ ~ ~ ~ ~ ~ égales à données \newline % Row Count 15 (+ 3) {\bf{\$nin }}{\bf{:}} correspond à des valeurs qui n'existent pas dans ~ ~ ~ ~ ~ un tableau \newline % Row Count 18 (+ 3) ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~~ {\bf{{\emph{Logique}}}} \newline % Row Count 21 (+ 3) {\bf{\$or}} {\bf{:}} joint les clauses de requête avec un ou \newline % Row Count 23 (+ 2) {\bf{\$and}} {\bf{:}} joint les clauses de requête avec un et \newline % Row Count 25 (+ 2) {\bf{\$not}} {\bf{:}} renvoyer des documents qui ne correspondent pas \newline % Row Count 27 (+ 2) {\bf{\$nor}} {\bf{:}} joindre des clauses de requête avec un ni logique \newline % Row Count 29 (+ 2) ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ {\bf{{\emph{Array}}}} \newline % Row Count 32 (+ 3) } \tn \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{3.833cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{3.833cm}}{\bf\textcolor{white}{Opérateurs (cont)}} \tn \SetRowColor{white} \mymulticolumn{1}{x{3.833cm}}{{\bf{\$all}} {\bf{:}} correspond aux tableaux qui contiennent tous les éléments donnés \newline % Row Count 2 (+ 2) {\bf{\$size }}{\bf{:}} les correspondances du tableau ont la taille spécifiée \newline % Row Count 4 (+ 2) {\bf{\$push}} {\bf{:}} ajoute un élément à un tableau \newline % Row Count 5 (+ 1) {\bf{\$pop }}{\bf{:}} mettre à jour le premier élément d'un tableau qui correspond \newline % Row Count 7 (+ 2) {\bf{\$pull }}{\bf{:}} supprimer les éléments qui correspondent à une instruction de requête \newline % Row Count 9 (+ 2) {\bf{\$pullAll}} {\bf{:}} supprimer plusieurs valeurs d'un tableau \newline % Row Count 11 (+ 2) ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ {\bf{{\emph{Autres}}}} \newline % Row Count 14 (+ 3) {\bf{\$slice}} {\bf{:}} modifier \$push pour limiter la taille du tableau mis à jour \newline % Row Count 16 (+ 2) {\bf{\$sort}} {\bf{:}} modifier \$push les documents du record dans le tableau% Row Count 18 (+ 2) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} % That's all folks \end{multicols*} \end{document}