<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-GB">
	<id>https://training-course-material.com/index.php?action=history&amp;feed=atom&amp;title=Basics_of_MongoDB</id>
	<title>Basics of MongoDB - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://training-course-material.com/index.php?action=history&amp;feed=atom&amp;title=Basics_of_MongoDB"/>
	<link rel="alternate" type="text/html" href="https://training-course-material.com/index.php?title=Basics_of_MongoDB&amp;action=history"/>
	<updated>2026-06-02T19:27:47Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.45.1</generator>
	<entry>
		<id>https://training-course-material.com/index.php?title=Basics_of_MongoDB&amp;diff=87718&amp;oldid=prev</id>
		<title>Lsokolowski1: /* CRUD */</title>
		<link rel="alternate" type="text/html" href="https://training-course-material.com/index.php?title=Basics_of_MongoDB&amp;diff=87718&amp;oldid=prev"/>
		<updated>2023-09-13T20:29:02Z</updated>

		<summary type="html">&lt;p&gt;&lt;span class=&quot;autocomment&quot;&gt;CRUD&lt;/span&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en-GB&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 20:29, 13 September 2023&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l124&quot;&gt;Line 124:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 124:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#039;&amp;#039;&amp;#039; Delete &amp;#039;&amp;#039;&amp;#039;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#039;&amp;#039;&amp;#039; Delete &amp;#039;&amp;#039;&amp;#039;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;syntaxhighlight lang=&amp;quot;JavaScript&amp;quot;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;syntaxhighlight lang=&amp;quot;JavaScript&amp;quot;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;db.people.remove({&quot;Name&quot; : &quot;Sean Connery&quot;})&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;db.people.remove({&quot;Name&quot; : &quot;Sean Connery&quot;}) &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;// .remove() is depricated now, use .deleteOne() instead&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;db.people.remove({})&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;db.people.remove({})&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;db.people.findOne()&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;db.people.findOne()&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Lsokolowski1</name></author>
	</entry>
	<entry>
		<id>https://training-course-material.com/index.php?title=Basics_of_MongoDB&amp;diff=87717&amp;oldid=prev</id>
		<title>Lsokolowski1: /* CRUD */</title>
		<link rel="alternate" type="text/html" href="https://training-course-material.com/index.php?title=Basics_of_MongoDB&amp;diff=87717&amp;oldid=prev"/>
		<updated>2023-09-13T20:22:56Z</updated>

		<summary type="html">&lt;p&gt;&lt;span class=&quot;autocomment&quot;&gt;CRUD&lt;/span&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en-GB&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 20:22, 13 September 2023&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l105&quot;&gt;Line 105:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 105:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;use NobleProg&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;use NobleProg&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;person = {&amp;quot;Name&amp;quot; : &amp;quot;Sean Connery&amp;quot;, &amp;quot;Nationality&amp;quot; : &amp;quot;Great Britain&amp;quot;}&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;person = {&amp;quot;Name&amp;quot; : &amp;quot;Sean Connery&amp;quot;, &amp;quot;Nationality&amp;quot; : &amp;quot;Great Britain&amp;quot;}&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;db.people.insert(person)&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;db.people.insert(person) &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;// .insert() is depricated now, use .insertOne() instead&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l118&quot;&gt;Line 118:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 118:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;syntaxhighlight lang=&amp;quot;JavaScript&amp;quot;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;syntaxhighlight lang=&amp;quot;JavaScript&amp;quot;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;personUp = {&amp;quot;Occupation&amp;quot; : &amp;quot;Actor&amp;quot;}&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;personUp = {&amp;quot;Occupation&amp;quot; : &amp;quot;Actor&amp;quot;}&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;db.people.update({&quot;Name&quot; : &quot;Sean Connery&quot;}, {$set: personUp})&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;db.people.update({&quot;Name&quot; : &quot;Sean Connery&quot;}, {$set: personUp}) &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;// .update() is depricated now, use .updateOne() instead&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;db.people.findOne()&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;db.people.findOne()&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Lsokolowski1</name></author>
	</entry>
	<entry>
		<id>https://training-course-material.com/index.php?title=Basics_of_MongoDB&amp;diff=87716&amp;oldid=prev</id>
		<title>Lsokolowski1: /* CRUD */</title>
		<link rel="alternate" type="text/html" href="https://training-course-material.com/index.php?title=Basics_of_MongoDB&amp;diff=87716&amp;oldid=prev"/>
		<updated>2023-09-13T20:20:54Z</updated>

		<summary type="html">&lt;p&gt;&lt;span class=&quot;autocomment&quot;&gt;CRUD&lt;/span&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en-GB&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 20:20, 13 September 2023&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l112&quot;&gt;Line 112:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 112:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;db.people.find()&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;db.people.find()&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;db.people.findOne()&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;db.people.findOne()&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;db.people.find().pretty()&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;db.people.find().pretty() &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;// .pretty() is the default now, so can be omitted&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Lsokolowski1</name></author>
	</entry>
	<entry>
		<id>https://training-course-material.com/index.php?title=Basics_of_MongoDB&amp;diff=87715&amp;oldid=prev</id>
		<title>Lsokolowski1: /* CRUD */</title>
		<link rel="alternate" type="text/html" href="https://training-course-material.com/index.php?title=Basics_of_MongoDB&amp;diff=87715&amp;oldid=prev"/>
		<updated>2023-09-13T20:19:06Z</updated>

		<summary type="html">&lt;p&gt;&lt;span class=&quot;autocomment&quot;&gt;CRUD&lt;/span&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en-GB&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 20:19, 13 September 2023&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l117&quot;&gt;Line 117:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 117:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#039;&amp;#039;&amp;#039; Update &amp;#039;&amp;#039;&amp;#039;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#039;&amp;#039;&amp;#039; Update &amp;#039;&amp;#039;&amp;#039;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;syntaxhighlight lang=&amp;quot;JavaScript&amp;quot;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;syntaxhighlight lang=&amp;quot;JavaScript&amp;quot;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;person.&lt;/del&gt;Occupation &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;= &lt;/del&gt;&quot;Actor&quot;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;personUp = {&quot;&lt;/ins&gt;Occupation&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&quot; : &lt;/ins&gt;&quot;Actor&quot;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;}&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;db.people.update({&quot;Name&quot; : &quot;Sean Connery&quot;}, &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;person&lt;/del&gt;)&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;db.people.update({&quot;Name&quot; : &quot;Sean Connery&quot;}, &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;{$set: personUp}&lt;/ins&gt;)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;db.people.findOne()&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;db.people.findOne()&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Lsokolowski1</name></author>
	</entry>
	<entry>
		<id>https://training-course-material.com/index.php?title=Basics_of_MongoDB&amp;diff=71096&amp;oldid=prev</id>
		<title>Kbaran: /* MongoDB Shell */</title>
		<link rel="alternate" type="text/html" href="https://training-course-material.com/index.php?title=Basics_of_MongoDB&amp;diff=71096&amp;oldid=prev"/>
		<updated>2019-03-12T07:24:35Z</updated>

		<summary type="html">&lt;p&gt;&lt;span class=&quot;autocomment&quot;&gt;MongoDB Shell&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;[[Category:MongoDB]]&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
* MongoDB is a fast document-oriented database&lt;br /&gt;
* replaces the concept of a &amp;quot;row&amp;quot; with a more flexible model - the &amp;quot;document&amp;quot;&lt;br /&gt;
* convenient data storage for modern object-oriented languages&lt;br /&gt;
* no predefined schemas&lt;br /&gt;
* no transactions&lt;br /&gt;
* no SQL&lt;br /&gt;
* supports indexes&lt;br /&gt;
* easy to scale out horizontally &lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Getting Started ===&lt;br /&gt;
* document is a basic unit of data (like row in RDBMS)&lt;br /&gt;
* collection = table&lt;br /&gt;
* multiple databases in single instance&lt;br /&gt;
* _id in every document, unique within collection&lt;br /&gt;
* JavaScript shell for administration and data manipulation&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Documents ===&lt;br /&gt;
* document is an ordered set of keys with associated values&lt;br /&gt;
* representation of a document varies by programming language (map; hash - Perl, Ruby; dictionary - Python)&lt;br /&gt;
* objects in JavaScript {key:value}&lt;br /&gt;
* example {&amp;quot;company&amp;quot; : &amp;quot;NobleProg&amp;quot;, &amp;quot;training&amp;quot; : &amp;quot;MongoDB for Developers&amp;quot;}&lt;br /&gt;
* key is a string, any UTF-8 is allowed (except \0 . $)&lt;br /&gt;
* type-sensitive {&amp;quot;age&amp;quot; : 3}, {&amp;quot;age&amp;quot; : &amp;quot;3&amp;quot;}&lt;br /&gt;
* case-sensitive {&amp;quot;age&amp;quot; : 3}, {&amp;quot;Age&amp;quot; : 3}&lt;br /&gt;
* documents cannot contain duplicated keys&lt;br /&gt;
* key/value pairs are ordered {&amp;quot;x&amp;quot; : 1, &amp;quot;y&amp;quot; : 1} != {&amp;quot;y&amp;quot; : 1, &amp;quot;x&amp;quot; : 1}&lt;br /&gt;
** order does not usually matter, MongoDB can reorder keys&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;JavaScript&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;_id&amp;quot; : ObjectId(&amp;quot;545a414c7907b2a255b156c5&amp;quot;),&lt;br /&gt;
  &amp;quot;Name&amp;quot; : &amp;quot;Sean Connery&amp;quot;,&lt;br /&gt;
  &amp;quot;Nationality&amp;quot; : &amp;quot;Great Britain&amp;quot;,&lt;br /&gt;
  &amp;quot;BirthDate&amp;quot; : ISODate(&amp;quot;1930-08-25T00:00:00Z&amp;quot;),&lt;br /&gt;
  &amp;quot;BirthYear&amp;quot; : 1930,&lt;br /&gt;
  &amp;quot;Occupation&amp;quot; : [&lt;br /&gt;
    &amp;quot;Actor&amp;quot;,&lt;br /&gt;
    &amp;quot;Director&amp;quot;,&lt;br /&gt;
    &amp;quot;Producer&amp;quot;&lt;br /&gt;
  ],&lt;br /&gt;
  &amp;quot;Movie&amp;quot; : [&lt;br /&gt;
    {&lt;br /&gt;
      &amp;quot;_id&amp;quot; : ObjectId(&amp;quot;545a5f167907b2a255b156c7&amp;quot;),&lt;br /&gt;
      &amp;quot;Title&amp;quot; : &amp;quot;Dr. No&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    {&lt;br /&gt;
      &amp;quot;_id&amp;quot; : ObjectId(&amp;quot;545a5f317907b2a255b156c8&amp;quot;),&lt;br /&gt;
      &amp;quot;Title&amp;quot; : &amp;quot;From Russia with Love&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    {&lt;br /&gt;
      &amp;quot;_id&amp;quot; : ObjectId(&amp;quot;545a5ed67907b2a255b156c6&amp;quot;),&lt;br /&gt;
      &amp;quot;Title&amp;quot; : &amp;quot;Never Say Never Again&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
  ],&lt;br /&gt;
  &amp;quot;BirthPlace&amp;quot; : {&lt;br /&gt;
    &amp;quot;Country&amp;quot; : &amp;quot;United Kingdom, Scotland&amp;quot;,&lt;br /&gt;
    &amp;quot;City&amp;quot; : &amp;quot;Edinburgh&amp;quot;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Collections ===&lt;br /&gt;
* a group of documents&lt;br /&gt;
* dynamic schemas&lt;br /&gt;
** {&amp;quot;company&amp;quot; : &amp;quot;NobleProg&amp;quot;}&lt;br /&gt;
** {&amp;quot;age&amp;quot; : 5}&lt;br /&gt;
* why should we use more than one collection?&lt;br /&gt;
** nightmare for developers&lt;br /&gt;
** much faster to get a list of collections than extracting document types from collections&lt;br /&gt;
** grouping documents of the same kind&lt;br /&gt;
** indexes&lt;br /&gt;
* collection name is a string, any UTF-8 is allowed except:&lt;br /&gt;
** empty string, start with &amp;quot;system.&amp;quot; prefix, contain \0 character, $ character&lt;br /&gt;
* subcollections separated by the . character&lt;br /&gt;
** example GridFS (fs.files, fs.chunks)&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Databases ===&lt;br /&gt;
* database is a group of collections&lt;br /&gt;
* one database = one application&lt;br /&gt;
* separated databases for different applications, users&lt;br /&gt;
* database name is a alphanumeric string, case sensitive, max 64 bytes, empty string is not allowed&lt;br /&gt;
* database name will end up as file on filesystem (this explains restrictions)&lt;br /&gt;
* special databases: admin (root database), local (never replicated), config (when sharding)&lt;br /&gt;
* namespace is a concatenation of database and collection name (fully qualified collection name)&lt;br /&gt;
** max 121 bytes, shold be less than 100&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Getting and Starting MongoDB ===&lt;br /&gt;
# Installation on Windows&lt;br /&gt;
#* http://docs.mongodb.org/manual/tutorial/install-mongodb-on-windows/&lt;br /&gt;
# Installation on Ubuntu&lt;br /&gt;
#* http://docs.mongodb.org/manual/tutorial/install-mongodb-on-ubuntu/&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== CRUD ===&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039; Create &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;JavaScript&amp;quot;&amp;gt;&lt;br /&gt;
use NobleProg&lt;br /&gt;
person = {&amp;quot;Name&amp;quot; : &amp;quot;Sean Connery&amp;quot;, &amp;quot;Nationality&amp;quot; : &amp;quot;Great Britain&amp;quot;}&lt;br /&gt;
db.people.insert(person)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039; Read &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;JavaScript&amp;quot;&amp;gt;&lt;br /&gt;
db.people.find()&lt;br /&gt;
db.people.findOne()&lt;br /&gt;
db.people.find().pretty()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039; Update &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;JavaScript&amp;quot;&amp;gt;&lt;br /&gt;
person.Occupation = &amp;quot;Actor&amp;quot;&lt;br /&gt;
db.people.update({&amp;quot;Name&amp;quot; : &amp;quot;Sean Connery&amp;quot;}, person)&lt;br /&gt;
db.people.findOne()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039; Delete &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;JavaScript&amp;quot;&amp;gt;&lt;br /&gt;
db.people.remove({&amp;quot;Name&amp;quot; : &amp;quot;Sean Connery&amp;quot;})&lt;br /&gt;
db.people.remove({})&lt;br /&gt;
db.people.findOne()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Data Types ===&lt;br /&gt;
* JSON-like documents&lt;br /&gt;
** 6 data types: null, boolean, numeric, string, array, object&lt;br /&gt;
* MongoDB adds support for other datatypes&lt;br /&gt;
** null {&amp;quot;x&amp;quot; : null}&lt;br /&gt;
** boolean {&amp;quot;x&amp;quot; : true}&lt;br /&gt;
** number (by default 64-bit floating point numbers) {&amp;quot;x&amp;quot; : 1.4142}&lt;br /&gt;
*** 4-byte integers {&amp;quot;x&amp;quot; : NumberInt(141)}&lt;br /&gt;
*** 8-byte integers {&amp;quot;x&amp;quot; : LongInt(141)}&lt;br /&gt;
** string (any UTF-8 character) {&amp;quot;x&amp;quot; : &amp;quot;NobleProg&amp;quot;}&lt;br /&gt;
** date (stored as milliseconds from Linux epoch) {&amp;quot;x&amp;quot; : new Date()}&lt;br /&gt;
** regular expressions (in queries) {&amp;quot;x&amp;quot; : /bob/i}&lt;br /&gt;
** array {&amp;quot;x&amp;quot; : [1.4142, true, &amp;quot;training&amp;quot;]}&lt;br /&gt;
** embedded documents {&amp;quot;x&amp;quot; : {&amp;quot;y&amp;quot; : 100}}&lt;br /&gt;
** ObjectId {&amp;quot;x&amp;quot; : ObjectId(&amp;quot;54597591bb107f6ef5989771&amp;quot;)}&lt;br /&gt;
** binary data (for non-UTF-8 strings)&lt;br /&gt;
** code {&amp;quot;x&amp;quot; : function() {/*...*/}}&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== _id and ObjectId ===&lt;br /&gt;
* every document in MongoDB must have _id&lt;br /&gt;
* can be any type but it defaults to ObjectId&lt;br /&gt;
* unique values in a single collection&lt;br /&gt;
* ObjectId is designed to lightweight and easy to generate&lt;br /&gt;
** 12-bytes of storage (24 hexidecimal digits)&lt;br /&gt;
*** timestamp - byte 0-3&lt;br /&gt;
*** machine - byte 4-6&lt;br /&gt;
*** PID - byte 7-8&lt;br /&gt;
*** increment - byte 9-11&lt;br /&gt;
** _id is generated automatically if not present in document&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== MongoDB Shell ==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;JavaScript&amp;quot;&amp;gt;&lt;br /&gt;
$ mongo&lt;br /&gt;
MongoDB shell version: 4.0.6&lt;br /&gt;
connecting to: test&lt;br /&gt;
&amp;gt;&lt;br /&gt;
&lt;br /&gt;
$ mongo HostName:PortNumber/DatabaseName&lt;br /&gt;
$ mongo localhost:27017/test&lt;br /&gt;
&lt;br /&gt;
$ mongo --nodb&lt;br /&gt;
&amp;gt; conn = new Mongo(&amp;quot;localhost:27017&amp;quot;)&lt;br /&gt;
connection to localhost27017&lt;br /&gt;
&amp;gt; db = conn.getDB(&amp;quot;NobleProg&amp;quot;)&lt;br /&gt;
NobleProg&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Using help ===&lt;br /&gt;
* mongo is a JavaScript shell, help is available in JavaScript on-line documentation&lt;br /&gt;
* use built-in help for MongoDB-specific functionality&lt;br /&gt;
* type function name without parentheses to see what the function is doing&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;JavaScript&amp;quot;&amp;gt;&lt;br /&gt;
&amp;gt; help&lt;br /&gt;
    db.help()            help on db methods&lt;br /&gt;
    db.mycoll.help()     help on collections methods&lt;br /&gt;
    ...&lt;br /&gt;
    exit                 quit mongo shell&lt;br /&gt;
&amp;gt;&lt;br /&gt;
&amp;gt; db.NobleProg.stats&lt;br /&gt;
function ( scale ){&lt;br /&gt;
    return this._db.runCommand( { collstats : this._shortName , scale : scale } );&lt;br /&gt;
}&lt;br /&gt;
&amp;gt;&lt;br /&gt;
&amp;gt; db.NobleProg.stats()&lt;br /&gt;
{ &amp;quot;ok&amp;quot; : 0, &amp;quot;errmsg&amp;quot; : &amp;quot;Collection [test.NobleProg] not found.&amp;quot; }&lt;br /&gt;
&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Running Scripts ===&lt;br /&gt;
* mongo can execute JavaScript files&lt;br /&gt;
* scripts have access to all global variables (e.g. &amp;quot;db&amp;quot;)&lt;br /&gt;
* shell helpers (e.g. &amp;quot;show collections&amp;quot;) do not work from files; use valid JavaScript equivalents (e.g. &amp;quot;db.getCollectionNames()&amp;quot;)&lt;br /&gt;
* use --quiet to hide &amp;quot;MongoDB shell version...&amp;quot; when executing script&lt;br /&gt;
* use load() to run script directly from Mongo Shell&lt;br /&gt;
* use .mongorc.js for frequently-loaded scripts&lt;br /&gt;
** located in user home directory, run when starting up the shell, --norc to disable it&lt;br /&gt;
** useful also to customize prompt&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;JavaScript&amp;quot;&amp;gt;&lt;br /&gt;
$ mongo script.js&lt;br /&gt;
MongoDB shell version: 4.0.6&lt;br /&gt;
connecting to: test&lt;br /&gt;
script.js was executed successfully!&lt;br /&gt;
$&lt;br /&gt;
$ mongo --quiet script.js&lt;br /&gt;
script.js was executed successfully!&lt;br /&gt;
$&lt;br /&gt;
$ mongo&lt;br /&gt;
MongoDB shell version: 4.0.6&lt;br /&gt;
connecting to: test&lt;br /&gt;
&amp;gt; load(&amp;quot;script.js&amp;quot;)&lt;br /&gt;
script.js was executed successfully!&lt;br /&gt;
&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Editing Complex Variables ===&lt;br /&gt;
* limited multiline support in the shell&lt;br /&gt;
* external editors are allowed&lt;br /&gt;
* EDITOR=&amp;quot;/usr/bin/gedit&amp;quot;&lt;br /&gt;
* EDITOR=&amp;quot;c:\\windows\\notepad.exe&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;JavaScript&amp;quot;&amp;gt;&lt;br /&gt;
$ mongo --quiet&lt;br /&gt;
&amp;gt; EDITOR=&amp;quot;c:\\windows\\notepad.exe&amp;quot;&lt;br /&gt;
&amp;gt; use training&lt;br /&gt;
switched to db training&lt;br /&gt;
&amp;gt; person = db.people.findOne()&lt;br /&gt;
{ &amp;quot;_id&amp;quot; : ObjectId(&amp;quot;54568445cfc7c83518fa5430&amp;quot;), &amp;quot;Name&amp;quot; : &amp;quot;Sean Connery&amp;quot; }&lt;br /&gt;
&amp;gt; edit person&lt;br /&gt;
&amp;gt; person&lt;br /&gt;
{ &amp;quot;_id&amp;quot; : ObjectId(&amp;quot;54568445cfc7c83518fa5430&amp;quot;), &amp;quot;Name&amp;quot; : &amp;quot;Sean Connery&amp;quot;, &amp;quot;Nationality&amp;quot; : &amp;quot;Great Britain&amp;quot; }&lt;br /&gt;
&amp;gt; db.people.save(person)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Kbaran</name></author>
	</entry>
</feed>