Chapter 2. Command-line Operations and Indexes

In this chapter, we will cover the following topics:

  • Creating test data
  • Performing simple querying, projections, and pagination from the Mongo shell
  • Updating and deleting data from the shell
  • Creating an index and viewing plans of queries
  • Creating a background and foreground index in the shell
  • Creating and understanding sparse indexes
  • Expiring documents after a fixed interval using the TTL index
  • Expiring documents at a given time using the TTL index

Introduction

In this chapter we will be performing simple queries using the mongo shell. Later in the chapter, we will have a detailed look at commonly used MongoDB indexes.

Get MongoDB Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.