π¦ΈββοΈ Enable Validation for the Authors Collection
In this exercise, you will define a JSON schema for the authors collection, apply the schema to the collection, and test the schema validation by inserting a document that does not match the schema.
This is an advanced exercise that requires you to write code. If you get stuck and you're doing this during a live workshop, you can flag down an instructor in the room for help.
- Start by opening the
server/src/schema-validation/apply-schema.ts
file in your GitHub codespace and uncomment lines 41-61. - Complete the tasks marked with
// TODO
comments. - Execute the script again to apply the schema to the
authors
collection.cd server
npx tsx src/schema-validation/apply-schema.ts - Finally, test the schema validation by modifying the
server/src/schema-validation/test-validation.ts
script. Inserting a document in theauthors
collection.