Coding Exercises: MongoDB

Coding Exercises: MongoDB

1h 45mIntermediate2022-11-18

Authors

John Cokos

John Cokos

Director of Curriculum at Code Fellows

Course details

Hone your skills in the core concepts of working with a MongoDB database in this course with instructor John Cokos. John delves into the CRUD operations—create, read, update, delete—with MongoDB databases. He presents challenges to teach you how to create a database, document schemas, and validation rules, as well as adding documents in those collections manually and through importing and exporting. John then delves into the many ways to query MongoDB databases using JavaScript in MongoShell, Compass, and advanced filtering and aggregations. The challenge series finishes up with some exercises related to updating and deleting documents and collections.

Skills covered

MongoDBDatabase DevelopmentDatabase ManagementOpen SourceSoftware DevelopmentOne-Off

Concepts

Introduction

  • Introduction, goals, and prerequisites
  • Tooling - mongosh and Compass install, configure, and basic use

CRUD - Create (Insert) Documents

  • Create - Complex schema (array, object, reference, and constraints)
  • Create - Insert a record into the document
  • Create - Insert multiple records with one statement
  • Create - Insert multiple records using a loop (seeding)
  • Create - Insert multiple records from a file

CRUD - Read (Query Find) Documents

  • Find - Query with a simple filter
  • Find - Specify which fields to return in a .find()
  • Find - Sorting and limiting
  • Find - Query operators - $gte, $in - , etc
  • Find - Values in sub-documents and objects
  • Find - Values in arrays
  • Find - $and and $or queries
  • Find - Custom query logic with functions

CRUD - Update Documents

  • Update - Use a filter to update one or more records
  • Update - Add an element to an array in a document

CRUD - Delete Documents

  • Delete - Remove an element in an array within a document
  • Delete - Multiple records

Conclusion

  • Next steps
40,000 Toman