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

Creating and tailing capped collection cursors in MongoDB


Capped collections are fixed-size collections and they act like queues. The documents added to it are added towards the end of the collection, removing the oldest entry in the collection, if the space allocated to the collection becomes full. They provide fast access to the limited-sized collections even without the use of the index. They are naturally sorted by the order of the insertion, and any retrieval needed on them ordered by time can be retrieved using the $natural sort order. The following diagram gives a pictorial representation of a capped collection whose size is enough to hold up to three documents of equal size (which is too small for any practical use, but good for illustration purposes). As we see in the diagram, the collection is similar to a circular queue, where the oldest document is replaced by the newly added document, should the collection become full:

Tailable cursors are a special type of cursor that tails...