Practical solutions

MongoDB Howtos How-To Guides

Solve the problem. Keep building. Collection of MongoDB how-to articles

Find the answer you need

Browse practical solutions, grouped by the task you're working on.

__COUNT__ entries on this page

How to Check Field Contains a String in MongoDBThis article will show you several examples, how to use regex in MongoDB to determine if a field contains a string or not, and to verify if a field contains a certain string. How to Drop or Delete a Collection in MongoDBThis tutorial article will tell you how to delete collections in MongoDB database and what are different methods to delete collections in MongoDB. How to Uninstall MongoDBTo completely remove MongoDB, you have to first remove the MongoDB services, the databases, and log files. Through this article, you will be able to uninstall MongoDB from Windows, Mac, and Linux. Make sure to keep a backup of your data, as the uninstallation cannot be reversed. How to Secure MongoDB With Username and PasswordIn this MongoDB article, you will learn how to properly configure the most important and fundamental security feature which is securing MongoDB with a username and password by creating an authentication user while remotely accessing MongoDB. How to Return Unique Values in MongoDBThis tutorial article will discuss the distinct function in MongoDB and how you can use it with db.collections. Moreover, you will learn how to return values from database with no duplicates in result. How to Rename a Database in MongoDBIn this MongoDB tutorial, you will learn how to rename a MongoDB database using different methods. These methods renames a MongoDB database using MongoDB GUI and rename a MongoDB database using MongoDB shell. How to Check if MongoDB Server Is RunningThis MongoDB instructional post will tell you how to check if MongoDB is installed and what is the version of installed MongoDB server. It is implemented in different operating systems like Windows, UBUNTU and MAC. How to Page in MongoDBThis instructional post will tell you what is paging in MongoDB. Why paging is needed in MongoDB and what are different methods or ways to get pagination done in MongoDB. How to Export Collection Into a CSV Format in MongoDBThis instructional post discusses different ways to export collections to CSV format. We can use the Studio 3T and MongoExport. How to Export All Collections in MongoDBThis article will explain how you can export all collections in MongoDB. It will also throw light on how we can export all collections in MongoDB to CSV (Comma Separated Value) and JSON file types. How to Compare Date in MongoDBThis MongoDB tutorial tackles how to compare dates. How to Update Push Array in MongoDBThis MongoDB instructional post will tell you what are operators in MongoDB and how are they described. Moreover, $push operator is explained in detail to help in understanding the problem of updating array in MongoDB. How to Log All Queries in MongoDBThis instructional post will teach you about logging in MongoDB. Furthermore, the operators used for logging queries in MongoDB are briefly discussed. How to Insert Records if Not Exists in MongoDBThis instructional post will tell you how to insert records in fields of array in collections of database if they don't exist. Moreover, Upsert and $setOninsert are also explained in brief detail with code segments and examples of each. How to Import a JSON File Into MongoDBThis instructional post will tell you different ways to import collections in MongoDB. Moreover, importing to JSON, CSV, and TSV formats is described briefly. How to Have Unique Index in MongoDBIn this instructional post you will learn about the unique indexes, what they are and how to make indexes unique in MongoDB. Moreover, making user's email unique in MongoDB is also explained in brief detail. How to Drop or Delete a Collection in a MongoDB DatabaseThis article will tell you how to delete collections in MongoDB database and what are different methods to delete collections in MongoDB. db.collection.remove and db.collection.drop will be discussed in detail. Moreover, dropping or deleting a database will be discussed using command line. How to Define a Schema in MongoDBThe structure and contents of your data are defined by a schema, which is a JSON object. Realm's BSON schemas, which extend the JSON Schema standard, can be used to design your app's data model and validate documents whenever they are created, changed, or deleted. How to Copy/Clone a Database in MongoDBThere are several ways through which the user can clone a collection within the same or to a different MongoDB database. In this MongoDB tutorial article, you will learn about different ways in which the user can copy/clone a Database in MongoDB along with its data. How to Add New Field to Every Document in a MongoDB CollectionYou will learn about the $set and $setOnInsert operations in this article post. Furthermore, utilizing these two operators, the challenge of adding a field to a collection in MongoDB is quickly described. How to Join Multiple Conditions Using the Lookup Operator in MongoDBThis tutorial demonstrates how we can join multiple conditions using the lookup operator in MongoDB. How to Get the Size of a Database in MongoDBThis tutorial demonstrates how to get the size of a database in MongoDB. How to Copy a Collection Within the Same Database in MongoDBThis tutorial demonstrates how to copy a collection within the same database using the mongodump, monogrestore, aggregate function, and forEach loop. How to Combine Two Collections Into One Collection Using MongoDBThis tutorial demonstrates how to combine or join two collections into one collection using MongoDB.