Modifying collection behavior using the collMod command
This is a command that would be executed to change the behavior of a collection in mongo. It could be thought of as a collection modify operation (officially, it is not mentioned anywhere though).
For a part of this recipe, knowledge of TTL indexes is required.
Getting ready
In this recipe, we will execute the collMod
operation on a collection. We need to start a standalone server listening to any port for client connections; in this case, we will stick to the default 27017
. If you are not aware how to start a standalone server, refer to Installing single node MongoDB in Chapter 1, Installing and Starting the Server. We also need to start a shell that would be used for this administration. It is highly recommended to take a look at the recipes Expiring documents after a fixed interval using the TTL index and Expiring documents at a given time using the TTL index in Chapter 2, Command-line Operations and Indexes if you are not aware of...