<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Linux Ask! &#187; MongoDB</title>
	<atom:link href="http://www.linuxask.com/topics/databases/mongodb/feed" rel="self" type="application/rss+xml" />
	<link>http://www.linuxask.com</link>
	<description>Linux Ask! is a Q &#38; A web site specific for Linux related questions such as how to use common Linux commands.</description>
	<lastBuildDate>Tue, 05 May 2015 07:15:40 +0000</lastBuildDate>
	<language>en-US</language>
		<sy:updatePeriod>hourly</sy:updatePeriod>
		<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.9.1</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
	<item>
		<title>Generate random data in MongoDB</title>
		<link>http://www.linuxask.com/questions/generate-random-data-in-mongodb</link>
		<comments>http://www.linuxask.com/questions/generate-random-data-in-mongodb#comments</comments>
		<pubDate>Wed, 15 May 2013 15:16:21 +0000</pubDate>
		<dc:creator><![CDATA[Linux Ask!]]></dc:creator>
				<category><![CDATA[Advanced Linux]]></category>
		<category><![CDATA[MongoDB]]></category>

		<guid isPermaLink="false">http://www.linuxask.com/?p=4246</guid>
		<description><![CDATA[Generate random data in MongoDB Answer: You can use the following method to generate random string into a collection in MongoDB: function randomString() { var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz"; var randomstring = ''; var string_length = 100; for (var i=0; i&#60;string_length; i++) { var rnum = Math.floor(Math.random() * chars.length); randomstring += chars.substring(rnum,rnum+1); } return randomstring; } <a href='http://www.linuxask.com/questions/generate-random-data-in-mongodb' class='excerpt-more'>[...]</a><div class='yarpp-related-rss'>

Related posts:<ol>
<li><a href="http://www.linuxask.com/questions/generate-uuid-in-php" rel="bookmark" title="Generate UUID in PHP">Generate UUID in PHP </a></li>
<li><a href="http://www.linuxask.com/questions/generate-random-number-in-linux" rel="bookmark" title="Generate random number in Linux">Generate random number in Linux </a></li>
<li><a href="http://www.linuxask.com/questions/generate-random-number-in-perl" rel="bookmark" title="Generate random number in Perl">Generate random number in Perl </a></li>
</ol>
</div>
]]></description>
				<content:encoded><![CDATA[<p>Generate random data in MongoDB</p>
<p><strong>Answer:</strong></p>
<p>You can use the following method to generate random string into a collection in MongoDB:</p>
<pre><code>function randomString() { 
        var chars = 
"0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz"; 
        var randomstring = ''; 
        var string_length = 100;
        for (var i=0; i&lt;string_length; i++) { 
                var rnum = Math.floor(Math.random() * chars.length); 
                randomstring += chars.substring(rnum,rnum+1); 
        } 
        return randomstring; 
} 

for(var i=0; i<2000000; i++){db.test.save({x:i, data:randomString()});} 
</code></pre>
<div class='yarpp-related-rss'>
<p>Related posts:<ol>
<li><a href="http://www.linuxask.com/questions/generate-uuid-in-php" rel="bookmark" title="Generate UUID in PHP">Generate UUID in PHP </a></li>
<li><a href="http://www.linuxask.com/questions/generate-random-number-in-linux" rel="bookmark" title="Generate random number in Linux">Generate random number in Linux </a></li>
<li><a href="http://www.linuxask.com/questions/generate-random-number-in-perl" rel="bookmark" title="Generate random number in Perl">Generate random number in Perl </a></li>
</ol></p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.linuxask.com/questions/generate-random-data-in-mongodb/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to get the total database index size of my MongoDB</title>
		<link>http://www.linuxask.com/questions/how-to-get-the-total-database-index-size-of-my-mongodb</link>
		<comments>http://www.linuxask.com/questions/how-to-get-the-total-database-index-size-of-my-mongodb#comments</comments>
		<pubDate>Wed, 15 May 2013 07:47:01 +0000</pubDate>
		<dc:creator><![CDATA[Linux Ask!]]></dc:creator>
				<category><![CDATA[MongoDB]]></category>

		<guid isPermaLink="false">http://www.linuxask.com/?p=4235</guid>
		<description><![CDATA[How to get the total database index size of my MongoDB Answer: In you mongo shell, execute the following command: var sum = 0; db.getMongo().getDBs()["databases"].forEach(function(x) { sum += db.getMongo().getDB(x.name).stats().indexSize }); print(sum)<div class='yarpp-related-rss'>

Related posts:<ol>
<li><a href="http://www.linuxask.com/questions/creates-an-index-in-mongodb" rel="bookmark" title="Creates an index in MongoDB">Creates an index in MongoDB </a></li>
<li><a href="http://www.linuxask.com/questions/repair-and-compact-database-in-mongodb" rel="bookmark" title="Repair and compact database in MongoDB">Repair and compact database in MongoDB </a></li>
<li><a href="http://www.linuxask.com/questions/create-an-index-on-a-document-in-mongodb" rel="bookmark" title="Create an index on a document in MongoDB">Create an index on a document in MongoDB </a></li>
</ol>
</div>
]]></description>
				<content:encoded><![CDATA[<p>How to get the total database index size of my MongoDB</p>
<p><strong>Answer:</strong></p>
<p>In you mongo shell, execute the following command:</p>
<pre><code>var sum = 0; db.getMongo().getDBs()["databases"].forEach(function(x) { sum += db.getMongo().getDB(x.name).stats().indexSize }); print(sum)</code></pre>
<div class='yarpp-related-rss'>
<p>Related posts:<ol>
<li><a href="http://www.linuxask.com/questions/creates-an-index-in-mongodb" rel="bookmark" title="Creates an index in MongoDB">Creates an index in MongoDB </a></li>
<li><a href="http://www.linuxask.com/questions/repair-and-compact-database-in-mongodb" rel="bookmark" title="Repair and compact database in MongoDB">Repair and compact database in MongoDB </a></li>
<li><a href="http://www.linuxask.com/questions/create-an-index-on-a-document-in-mongodb" rel="bookmark" title="Create an index on a document in MongoDB">Create an index on a document in MongoDB </a></li>
</ol></p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.linuxask.com/questions/how-to-get-the-total-database-index-size-of-my-mongodb/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Check how long a MongoDB instance was running</title>
		<link>http://www.linuxask.com/questions/check-how-long-a-mongodb-instance-was-running</link>
		<comments>http://www.linuxask.com/questions/check-how-long-a-mongodb-instance-was-running#comments</comments>
		<pubDate>Mon, 15 Apr 2013 02:16:59 +0000</pubDate>
		<dc:creator><![CDATA[Linux Ask!]]></dc:creator>
				<category><![CDATA[MongoDB]]></category>

		<guid isPermaLink="false">http://www.linuxask.com/?p=4219</guid>
		<description><![CDATA[Check how long a MongoDB instance was running Answer: To see how long a MongoDB instance was running, you can login into the mongo shell, and enter db.serverStatus().uptime / 3600 The above command reply the value in term of hours.<div class='yarpp-related-rss'>

Related posts:<ol>
<li><a href="http://www.linuxask.com/questions/check-how-long-server-has-been-running" rel="bookmark" title="Check how long server has been running">Check how long server has been running </a></li>
<li><a href="http://www.linuxask.com/questions/how-to-get-the-startup-warning-from-mongodb" rel="bookmark" title="How to get the startup warning from MongoDB?">How to get the startup warning from MongoDB? </a></li>
<li><a href="http://www.linuxask.com/questions/how-to-check-the-current-mongodb-version" rel="bookmark" title="How to check the current MongoDB version">How to check the current MongoDB version </a></li>
</ol>
</div>
]]></description>
				<content:encoded><![CDATA[<p>Check how long a MongoDB instance was running</p>
<p><strong>Answer:</strong></p>
<p>To see how long a MongoDB instance was running, you can login into the mongo shell, and enter</p>
<p><code>db.serverStatus().uptime / 3600</code></p>
<p>The above command reply the value in term of <strong>hours</strong>.</p>
<div class='yarpp-related-rss'>
<p>Related posts:<ol>
<li><a href="http://www.linuxask.com/questions/check-how-long-server-has-been-running" rel="bookmark" title="Check how long server has been running">Check how long server has been running </a></li>
<li><a href="http://www.linuxask.com/questions/how-to-get-the-startup-warning-from-mongodb" rel="bookmark" title="How to get the startup warning from MongoDB?">How to get the startup warning from MongoDB? </a></li>
<li><a href="http://www.linuxask.com/questions/how-to-check-the-current-mongodb-version" rel="bookmark" title="How to check the current MongoDB version">How to check the current MongoDB version </a></li>
</ol></p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.linuxask.com/questions/check-how-long-a-mongodb-instance-was-running/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to get the startup warning from MongoDB?</title>
		<link>http://www.linuxask.com/questions/how-to-get-the-startup-warning-from-mongodb</link>
		<comments>http://www.linuxask.com/questions/how-to-get-the-startup-warning-from-mongodb#comments</comments>
		<pubDate>Thu, 11 Apr 2013 02:16:28 +0000</pubDate>
		<dc:creator><![CDATA[Linux Ask!]]></dc:creator>
				<category><![CDATA[MongoDB]]></category>

		<guid isPermaLink="false">http://www.linuxask.com/?p=4217</guid>
		<description><![CDATA[How to get the startup warning from MongoDB? Answer: The easiest way is login into the MongoDB using the shell, enter the command: db.adminCommand({getLog: "startupWarnings" })<div class='yarpp-related-rss'>

Related posts:<ol>
<li><a href="http://www.linuxask.com/questions/drop-a-collection-in-mongodb" rel="bookmark" title="Drop a collection in MongoDB">Drop a collection in MongoDB </a></li>
<li><a href="http://www.linuxask.com/questions/create-an-index-on-a-document-in-mongodb" rel="bookmark" title="Create an index on a document in MongoDB">Create an index on a document in MongoDB </a></li>
<li><a href="http://www.linuxask.com/questions/how-to-check-the-current-mongodb-version" rel="bookmark" title="How to check the current MongoDB version">How to check the current MongoDB version </a></li>
</ol>
</div>
]]></description>
				<content:encoded><![CDATA[<p>How to get the startup warning from MongoDB?</p>
<p><strong>Answer:</strong></p>
<p>The easiest way is login into the MongoDB using the shell, enter the command:</p>
<p><code>db.adminCommand({getLog: "startupWarnings" })</code></p>
<div class='yarpp-related-rss'>
<p>Related posts:<ol>
<li><a href="http://www.linuxask.com/questions/drop-a-collection-in-mongodb" rel="bookmark" title="Drop a collection in MongoDB">Drop a collection in MongoDB </a></li>
<li><a href="http://www.linuxask.com/questions/create-an-index-on-a-document-in-mongodb" rel="bookmark" title="Create an index on a document in MongoDB">Create an index on a document in MongoDB </a></li>
<li><a href="http://www.linuxask.com/questions/how-to-check-the-current-mongodb-version" rel="bookmark" title="How to check the current MongoDB version">How to check the current MongoDB version </a></li>
</ol></p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.linuxask.com/questions/how-to-get-the-startup-warning-from-mongodb/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to check the current MongoDB version</title>
		<link>http://www.linuxask.com/questions/how-to-check-the-current-mongodb-version</link>
		<comments>http://www.linuxask.com/questions/how-to-check-the-current-mongodb-version#comments</comments>
		<pubDate>Tue, 20 Nov 2012 04:19:58 +0000</pubDate>
		<dc:creator><![CDATA[Linux Ask!]]></dc:creator>
				<category><![CDATA[MongoDB]]></category>

		<guid isPermaLink="false">http://www.linuxask.com/?p=4064</guid>
		<description><![CDATA[How to check the current MongoDB version Answer: Simply type the following command in your MongoDB's shell db.version()<div class='yarpp-related-rss'>

Related posts:<ol>
<li><a href="http://www.linuxask.com/questions/how-to-check-the-bash-shell-version" rel="bookmark" title="How to check the bash shell version">How to check the bash shell version </a></li>
<li><a href="http://www.linuxask.com/questions/how-to-check-current-php-version-in-php" rel="bookmark" title="How to check current PHP version in PHP?">How to check current PHP version in PHP? </a></li>
<li><a href="http://www.linuxask.com/questions/check-how-long-a-mongodb-instance-was-running" rel="bookmark" title="Check how long a MongoDB instance was running">Check how long a MongoDB instance was running </a></li>
</ol>
</div>
]]></description>
				<content:encoded><![CDATA[<p>How to check the current MongoDB version</p>
<p><strong>Answer:</strong></p>
<p>Simply type the following command in your MongoDB's shell</p>
<p><code>db.version()</code></p>
<div class='yarpp-related-rss'>
<p>Related posts:<ol>
<li><a href="http://www.linuxask.com/questions/how-to-check-the-bash-shell-version" rel="bookmark" title="How to check the bash shell version">How to check the bash shell version </a></li>
<li><a href="http://www.linuxask.com/questions/how-to-check-current-php-version-in-php" rel="bookmark" title="How to check current PHP version in PHP?">How to check current PHP version in PHP? </a></li>
<li><a href="http://www.linuxask.com/questions/check-how-long-a-mongodb-instance-was-running" rel="bookmark" title="Check how long a MongoDB instance was running">Check how long a MongoDB instance was running </a></li>
</ol></p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.linuxask.com/questions/how-to-check-the-current-mongodb-version/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Select a document in MongoDB</title>
		<link>http://www.linuxask.com/questions/select-a-document-in-mongodb</link>
		<comments>http://www.linuxask.com/questions/select-a-document-in-mongodb#comments</comments>
		<pubDate>Tue, 06 Sep 2011 10:50:38 +0000</pubDate>
		<dc:creator><![CDATA[Linux Ask!]]></dc:creator>
				<category><![CDATA[MongoDB]]></category>

		<guid isPermaLink="false">http://www.linuxask.com/?p=3454</guid>
		<description><![CDATA[Select a document in MongoDB Answer: To select (find) a document in MongoDB, you can use the following syntax in the mongodb Interactive shell. use my_db db.users.find({name:"peter"}) You need to switch to the current database (e.g. my_db) and then execute your select statement.<div class='yarpp-related-rss'>

Related posts:<ol>
<li><a href="http://www.linuxask.com/questions/insert-a-new-document-to-mongodb" rel="bookmark" title="Insert a new document to MongoDB">Insert a new document to MongoDB </a></li>
<li><a href="http://www.linuxask.com/questions/create-an-index-on-a-document-in-mongodb" rel="bookmark" title="Create an index on a document in MongoDB">Create an index on a document in MongoDB </a></li>
<li><a href="http://www.linuxask.com/questions/remove-a-document-in-a-collection-in-mongodb" rel="bookmark" title="Remove a document in a collection in MongoDB">Remove a document in a collection in MongoDB </a></li>
</ol>
</div>
]]></description>
				<content:encoded><![CDATA[<p>Select a document in MongoDB</p>
<p><strong>Answer:</strong></p>
<p>To select (find) a document in <strong>MongoDB</strong>, you can use the following syntax in the mongodb Interactive shell.</p>
<pre><code>use my_db
db.users.find({name:"peter"})</code></pre>
<p>You need to switch to the current database (e.g. my_db) and then execute your select statement.</p>
<div class='yarpp-related-rss'>
<p>Related posts:<ol>
<li><a href="http://www.linuxask.com/questions/insert-a-new-document-to-mongodb" rel="bookmark" title="Insert a new document to MongoDB">Insert a new document to MongoDB </a></li>
<li><a href="http://www.linuxask.com/questions/create-an-index-on-a-document-in-mongodb" rel="bookmark" title="Create an index on a document in MongoDB">Create an index on a document in MongoDB </a></li>
<li><a href="http://www.linuxask.com/questions/remove-a-document-in-a-collection-in-mongodb" rel="bookmark" title="Remove a document in a collection in MongoDB">Remove a document in a collection in MongoDB </a></li>
</ol></p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.linuxask.com/questions/select-a-document-in-mongodb/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Explain query execution plan in MongoDB</title>
		<link>http://www.linuxask.com/questions/explain-query-execution-plan-in-mongodb</link>
		<comments>http://www.linuxask.com/questions/explain-query-execution-plan-in-mongodb#comments</comments>
		<pubDate>Fri, 02 Sep 2011 14:20:19 +0000</pubDate>
		<dc:creator><![CDATA[Linux Ask!]]></dc:creator>
				<category><![CDATA[MongoDB]]></category>

		<guid isPermaLink="false">http://www.linuxask.com/?p=3450</guid>
		<description><![CDATA[Explain query execution plan in MongoDB Answer: Like MySQL, you can get a better understanding of the performance of your MongoDB's query, you can use the $explain feature. E.g. db.collection.find(query).explain();<div class='yarpp-related-rss'>

Related posts:<ol>
<li><a href="http://www.linuxask.com/questions/explain-query-execution-plan-in-mysql" rel="bookmark" title="Explain query execution plan in MySQL">Explain query execution plan in MySQL </a></li>
<li><a href="http://www.linuxask.com/questions/drop-a-collection-in-mongodb" rel="bookmark" title="Drop a collection in MongoDB">Drop a collection in MongoDB </a></li>
<li><a href="http://www.linuxask.com/questions/count-the-total-number-of-objects-in-the-collection-in-mongodb" rel="bookmark" title="Count the total number of objects in the collection in MongoDB">Count the total number of objects in the collection in MongoDB </a></li>
</ol>
</div>
]]></description>
				<content:encoded><![CDATA[<p>Explain query execution plan in MongoDB</p>
<p><strong>Answer:</strong></p>
<p>Like <a href="http://www.linuxask.com/questions/explain-query-execution-plan-in-mysql">MySQL</a>, you can get a better understanding of the performance of your <strong>MongoDB's</strong> query, you can use the <strong>$explain</strong> feature.</p>
<p>E.g.</p>
<pre><code>db.collection.find(query).explain();</code></pre>
<div class='yarpp-related-rss'>
<p>Related posts:<ol>
<li><a href="http://www.linuxask.com/questions/explain-query-execution-plan-in-mysql" rel="bookmark" title="Explain query execution plan in MySQL">Explain query execution plan in MySQL </a></li>
<li><a href="http://www.linuxask.com/questions/drop-a-collection-in-mongodb" rel="bookmark" title="Drop a collection in MongoDB">Drop a collection in MongoDB </a></li>
<li><a href="http://www.linuxask.com/questions/count-the-total-number-of-objects-in-the-collection-in-mongodb" rel="bookmark" title="Count the total number of objects in the collection in MongoDB">Count the total number of objects in the collection in MongoDB </a></li>
</ol></p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.linuxask.com/questions/explain-query-execution-plan-in-mongodb/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Repair and compact database in MongoDB</title>
		<link>http://www.linuxask.com/questions/repair-and-compact-database-in-mongodb</link>
		<comments>http://www.linuxask.com/questions/repair-and-compact-database-in-mongodb#comments</comments>
		<pubDate>Fri, 19 Aug 2011 14:15:26 +0000</pubDate>
		<dc:creator><![CDATA[Linux Ask!]]></dc:creator>
				<category><![CDATA[MongoDB]]></category>

		<guid isPermaLink="false">http://www.linuxask.com/?p=3315</guid>
		<description><![CDATA[Repair and compact database in MongoDB Answer: To repair and compact a database in MongoDB, you can use the following command in the mongodb Interactive shell. 1. Select the database use test 2. Repair the current database db.repairDatabase() Done.<div class='yarpp-related-rss'>

Related posts:<ol>
<li><a href="http://www.linuxask.com/questions/select-a-document-in-mongodb" rel="bookmark" title="Select a document in MongoDB">Select a document in MongoDB </a></li>
<li><a href="http://www.linuxask.com/questions/drop-a-database-in-mongodb" rel="bookmark" title="Drop a database in MongoDB">Drop a database in MongoDB </a></li>
<li><a href="http://www.linuxask.com/questions/how-to-get-the-total-database-index-size-of-my-mongodb" rel="bookmark" title="How to get the total database index size of my MongoDB">How to get the total database index size of my MongoDB </a></li>
</ol>
</div>
]]></description>
				<content:encoded><![CDATA[<p>Repair and compact database in MongoDB</p>
<p><strong>Answer:</strong></p>
<p>To repair and compact a database in <strong>MongoDB</strong>, you can use the following command in the mongodb Interactive shell.</p>
<p>1. Select the database</p>
<p><code>use test</code></p>
<p>2. Repair the current database</p>
<p><code>db.repairDatabase()</code></p>
<p>Done.</p>
<div class='yarpp-related-rss'>
<p>Related posts:<ol>
<li><a href="http://www.linuxask.com/questions/select-a-document-in-mongodb" rel="bookmark" title="Select a document in MongoDB">Select a document in MongoDB </a></li>
<li><a href="http://www.linuxask.com/questions/drop-a-database-in-mongodb" rel="bookmark" title="Drop a database in MongoDB">Drop a database in MongoDB </a></li>
<li><a href="http://www.linuxask.com/questions/how-to-get-the-total-database-index-size-of-my-mongodb" rel="bookmark" title="How to get the total database index size of my MongoDB">How to get the total database index size of my MongoDB </a></li>
</ol></p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.linuxask.com/questions/repair-and-compact-database-in-mongodb/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Count the total number of objects in the collection in MongoDB</title>
		<link>http://www.linuxask.com/questions/count-the-total-number-of-objects-in-the-collection-in-mongodb</link>
		<comments>http://www.linuxask.com/questions/count-the-total-number-of-objects-in-the-collection-in-mongodb#comments</comments>
		<pubDate>Wed, 17 Aug 2011 14:11:22 +0000</pubDate>
		<dc:creator><![CDATA[Linux Ask!]]></dc:creator>
				<category><![CDATA[MongoDB]]></category>

		<guid isPermaLink="false">http://www.linuxask.com/?p=3311</guid>
		<description><![CDATA[Count the total number of objects in the collection in MongoDB Answer: In MongoDB, to count the total number of objects in the collection, you can use the following statement in the mongodb Interactive shell. db.test.count() The above statement will return the total number of objects in the collection "test"<div class='yarpp-related-rss'>

Related posts:<ol>
<li><a href="http://www.linuxask.com/questions/drop-a-collection-in-mongodb" rel="bookmark" title="Drop a collection in MongoDB">Drop a collection in MongoDB </a></li>
<li><a href="http://www.linuxask.com/questions/remove-a-document-in-a-collection-in-mongodb" rel="bookmark" title="Remove a document in a collection in MongoDB">Remove a document in a collection in MongoDB </a></li>
<li><a href="http://www.linuxask.com/questions/creates-an-index-in-mongodb" rel="bookmark" title="Creates an index in MongoDB">Creates an index in MongoDB </a></li>
</ol>
</div>
]]></description>
				<content:encoded><![CDATA[<p>Count the total number of objects in the collection in MongoDB</p>
<p><strong>Answer:</strong></p>
<p>In <strong>MongoDB</strong>, to count the total number of objects in the collection, you can use the following statement in the mongodb Interactive shell.</p>
<p><code>db.test.count()</code></p>
<p>The above statement will return the total number of objects in the collection "<strong>test</strong>"</p>
<div class='yarpp-related-rss'>
<p>Related posts:<ol>
<li><a href="http://www.linuxask.com/questions/drop-a-collection-in-mongodb" rel="bookmark" title="Drop a collection in MongoDB">Drop a collection in MongoDB </a></li>
<li><a href="http://www.linuxask.com/questions/remove-a-document-in-a-collection-in-mongodb" rel="bookmark" title="Remove a document in a collection in MongoDB">Remove a document in a collection in MongoDB </a></li>
<li><a href="http://www.linuxask.com/questions/creates-an-index-in-mongodb" rel="bookmark" title="Creates an index in MongoDB">Creates an index in MongoDB </a></li>
</ol></p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.linuxask.com/questions/count-the-total-number-of-objects-in-the-collection-in-mongodb/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Creates an index in MongoDB</title>
		<link>http://www.linuxask.com/questions/creates-an-index-in-mongodb</link>
		<comments>http://www.linuxask.com/questions/creates-an-index-in-mongodb#comments</comments>
		<pubDate>Mon, 15 Aug 2011 14:06:57 +0000</pubDate>
		<dc:creator><![CDATA[Linux Ask!]]></dc:creator>
				<category><![CDATA[MongoDB]]></category>

		<guid isPermaLink="false">http://www.linuxask.com/?p=3309</guid>
		<description><![CDATA[Creates an index in MongoDB Answer: In an given collection, if you want to add an index on a specify field, you can do the following in the mongodb Interactive shell. db.test.ensureIndex( { name : 1 } ) The key "name" from now on will have index enabled.<div class='yarpp-related-rss'>

Related posts:<ol>
<li><a href="http://www.linuxask.com/questions/create-an-index-on-a-document-in-mongodb" rel="bookmark" title="Create an index on a document in MongoDB">Create an index on a document in MongoDB </a></li>
<li><a href="http://www.linuxask.com/questions/remove-a-document-in-a-collection-in-mongodb" rel="bookmark" title="Remove a document in a collection in MongoDB">Remove a document in a collection in MongoDB </a></li>
<li><a href="http://www.linuxask.com/questions/count-the-total-number-of-objects-in-the-collection-in-mongodb" rel="bookmark" title="Count the total number of objects in the collection in MongoDB">Count the total number of objects in the collection in MongoDB </a></li>
</ol>
</div>
]]></description>
				<content:encoded><![CDATA[<p>Creates an index in MongoDB</p>
<p><strong>Answer:</strong></p>
<p>In an given collection, if you want to add an <strong>index </strong>on a specify field, you can do the following in the mongodb Interactive shell.</p>
<p><code>db.test.ensureIndex( { name : 1 } )</code></p>
<p>The key "name" from now on will have index enabled.</p>
<div class='yarpp-related-rss'>
<p>Related posts:<ol>
<li><a href="http://www.linuxask.com/questions/create-an-index-on-a-document-in-mongodb" rel="bookmark" title="Create an index on a document in MongoDB">Create an index on a document in MongoDB </a></li>
<li><a href="http://www.linuxask.com/questions/remove-a-document-in-a-collection-in-mongodb" rel="bookmark" title="Remove a document in a collection in MongoDB">Remove a document in a collection in MongoDB </a></li>
<li><a href="http://www.linuxask.com/questions/count-the-total-number-of-objects-in-the-collection-in-mongodb" rel="bookmark" title="Count the total number of objects in the collection in MongoDB">Count the total number of objects in the collection in MongoDB </a></li>
</ol></p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.linuxask.com/questions/creates-an-index-in-mongodb/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
