1. Learn
  2. /
  3. Courses
  4. /
  5. Introduction to MongoDB in Python

Connected

Exercise

MongoDB's built-in schema validation

Even though MongoDB has a flexible schema, it also comes pre-packed with extensive functionality for schema validation. When creating a collection, you can specify a JSON schema to describe what format documents should follow.

Note: we're using a randomly generated collection name here, so that you can freely experiment with multiple submissions.

Instructions

100 XP
  • Adapt the .create_collection() call: title should be a "string".
  • Insert the movie into your newly minted movies collection, mov.
  • Inspect the result of the insertion to check it was successful.