Book Image

MongoDB Cookbook

By : Amol Nayak
Book Image

MongoDB Cookbook

By: Amol Nayak

Overview of this book

<p>MongoDB is a high-performance and feature-rich NoSQL database that forms the backbone of numerous complex development systems. You will certainly find the MongoDB solution you are searching for in this book.</p> <p>Starting with how to initialize the server in three different modes with various configurations, you will then learn a variety of skills including the basics of advanced query operations and features in MongoDB and monitoring and backup using MMS. From there, you can delve into recipes on cloud deployment, integration with Hadoop, and improving developer productivity. By the end of this book, you will have a clear idea about how to design, develop, and deploy MongoDB.</p>
Table of Contents (17 chapters)
MongoDB Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Storing binary data in MongoDB


So far we have seen how to store text values, dates, and numbers fields in a document. Binary content also needs to be stored at times in the database. Consider cases where users upload their photographs or scanned copies of documents that need to be stored in the database. In relational databases, the BLOB data type is the most commonly used type to address these requirements. Mongo too supports binary contents to be stored in a document in the collection. The catch is that the total size of the document shouldn't exceed 16 MB, which is the upper limit of the document size at the time of writing this book. In this recipe, we will store a small image file in Mongo's document and also retrieve it later. If the content you wish to store in MongoDB collections is greater than 16 MB, MongoDB offers an out-of-the-box solution called GridFS. We will see how to use GridFS in the Storing large data in MongoDB using GridFS recipe later in this chapter.

Getting ready

Look...