MongoDB Programming Tips


What is the Maximum Size of a MongoDB Document?

MongoDB is a NoSQL database which can store JSON like documents in containers known as collections. There is no technical limit as to how many documents can be stored in a MongoDB collection. However, current versions of MongoDB has a limit on the maximum size of a single document stored in a collection. Since 1.7.4 […]

MongoDB History

When it comes to modern web application development, MongoDB is the king. If you are a full stack programmer, you hear about MERN or MEAN stacks every day. The M is in every one of them and it stands for MongoDB. The free and open source community version of MongoDB powers a large number of […]

How to Find the Document with the Longest Array in a MongoDB Collection?

When working with MongoDB collections, sometimes you may want to find the document that contains the longest array. For example, you may have a collection for storing shirts and the array “sizes” in it may contain all the sizes in which the shirt is available. In this case, how do you find the shirts with […]

How to Find Largest Document in MongoDB

MongoDB collections are usually schema less. This means that a collection can potentially contain documents with different structure. Even if they are same, since data stored is different, document size can substantially vary. Sometimes you may want to find the largest document in a MongoDB collection. This is required if you are planning to migrate […]

How to Get Sorted List of Collection and Index Sizes in a MongoDB Database

If you have a large MongoDB database in production with a large of number of collections and indexes, you may need to periodically analyse the size of them. Here are a few MongoDB script snippets that you may find useful. How to Get Sorted List of MongoDB Collections by Size? The following script sorts and […]