<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://charlesreid1.com/w/index.php?action=history&amp;feed=atom&amp;title=Mongo%2FCRUD</id>
	<title>Mongo/CRUD - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://charlesreid1.com/w/index.php?action=history&amp;feed=atom&amp;title=Mongo%2FCRUD"/>
	<link rel="alternate" type="text/html" href="https://charlesreid1.com/w/index.php?title=Mongo/CRUD&amp;action=history"/>
	<updated>2026-06-20T02:58:27Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.39.12</generator>
	<entry>
		<id>https://charlesreid1.com/w/index.php?title=Mongo/CRUD&amp;diff=23882&amp;oldid=prev</id>
		<title>Admin: Created page with &quot;=CRUD Operations from the Mongo Shell=  The mongo shell is a Javascript command-line interface to MongoDB that can be started by running the command &lt;code&gt;mongo&lt;/code&gt;:  &lt;pre&gt;...&quot;</title>
		<link rel="alternate" type="text/html" href="https://charlesreid1.com/w/index.php?title=Mongo/CRUD&amp;diff=23882&amp;oldid=prev"/>
		<updated>2018-01-31T04:23:31Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;=CRUD Operations from the Mongo Shell=  The mongo shell is a Javascript command-line interface to MongoDB that can be started by running the command &amp;lt;code&amp;gt;mongo&amp;lt;/code&amp;gt;:  &amp;lt;pre&amp;gt;...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;=CRUD Operations from the Mongo Shell=&lt;br /&gt;
&lt;br /&gt;
The mongo shell is a Javascript command-line interface to MongoDB that can be started by running the command &amp;lt;code&amp;gt;mongo&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ mongo&lt;br /&gt;
&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Below, we cover the four basic operations of transactional databases: create, remove, update, delete (CRUD).&lt;br /&gt;
&lt;br /&gt;
==Create (Insert)==&lt;br /&gt;
&lt;br /&gt;
To insert documents into a collection:&lt;br /&gt;
* &amp;lt;code&amp;gt;db.collection.insertOne()&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;db.collection.insertMany()&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example: &amp;lt;code&amp;gt;db.users.insertOne({name:&amp;quot;Sue&amp;quot;, age:26})&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Read (Query)==&lt;br /&gt;
&lt;br /&gt;
To read documents from a collection,&lt;br /&gt;
use the find function:&lt;br /&gt;
*  &amp;lt;code&amp;gt;db.collection.find()&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example: &amp;lt;code&amp;gt;db.users.find({age:{$gt:18}})&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Update==&lt;br /&gt;
&lt;br /&gt;
To update documents in a collection:&lt;br /&gt;
* &amp;lt;code&amp;gt;db.collection.updateOne()&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;db.collection.updateMany()&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;db.collection.replaceOne()&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example: &amp;lt;code&amp;gt;db.users.updateMany( {age:{$lt:18}, $set: {status: &amp;quot;reject&amp;quot;}} )&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Delete==&lt;br /&gt;
&lt;br /&gt;
Delete documents one at a time or en masse:&lt;br /&gt;
* &amp;lt;code&amp;gt;db.collection.deleteOne()&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;db.collection.deleteMany()&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:MongoDB]]&lt;br /&gt;
[[Category:Databases]]&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
	</entry>
</feed>