MongoDB
MongoDB Sharding: Step by Step Tutorial with Example
What is Sharding in MongoDB? Sharding is a concept in MongoDB, which splits large data sets into...
Mongo DB provides query modifiers such as the 'limit' and 'Orders' clause to provide more flexibility when executing queries. We will take a look at the following query modifiers
This modifier is used to limit the number of documents which are returned in the result set for a query. The following example shows how this can be done.
db.Employee.find().limit(2).forEach(printjson);
Code Explanation:
Output:
If the command is executed successfully, the following Output will be shown
The output clearly shows that since there is a limit modifier, so at most just 2 records are returned as part of the result set based on the ObjectId in ascending order.
One can specify the order of documents to be returned based on ascending or descending order of any key in the collection. The following example shows how this can be done.
db.Employee.find().sort({Employeeid:-1}).forEach(printjson)
Code Explanation:
If the command is executed successfully, the following Output will be shown
Output:
The output clearly shows the documents being returned in descending order of the Employeeid.
Ascending order is defined by value 1.
What is Sharding in MongoDB? Sharding is a concept in MongoDB, which splits large data sets into...
What is NoSQL? NoSQL Database is a non-relational Data Management System, that does not require a...
The installers for MongoDB are available in both the 32-bit and 64-bit format. The 32-bit...
Basic document updates MongoDB provides the update() command to update the documents of a...
Regular expressions are used for pattern matching, which is basically for findings strings within...
One of the key concepts in MongoDB is the management of databases. Important aspects such as...