5. Inserting, Updating, and Deleting Documents
Overview
This chapter introduces you to the core operations in MongoDB, namely inserting, updating, and deleting documents in a collection. You will learn how to insert a single document or a batch of multiple documents into a MongoDB collection. You will add or autogenerate an _id
field, replace existing documents, and update specific fields in the documents of an existing collection. Finally, you will learn how you can delete all or delete specific documents in a collection.