Personal Catalogue: React & Firebase — Chapter 1, Exercise 1 ===================================================================== TASK Explain the real, load-bearing difference between the MongoDB sibling's own Mongoose discriminators and a plain Firestore collection — specifically, what guarantee discriminators give at write time that Firestore does not, and what has to replace that guarantee in a Firestore-based app. SOLUTION Mongoose discriminators give a real, enforced guarantee at write time: before a document ever reaches the underlying MongoDB collection, it is checked against the schema for its own declared item type. A document tagged as a Book but missing a required `title` field, or carrying a field that only a Dvd schema defines, is rejected by Mongoose itself — the database never sees the bad write at all. That guarantee holds regardless of which part of the codebase is doing the writing. Firestore gives no equivalent guarantee. A Firestore collection is a plain bucket of documents with no declared shape at all — any document, with any fields, in any combination, can be written to any collection, and Firestore's own database layer will accept it without complaint. Nothing prevents a bug from writing a document tagged `itemType: "Cd"` that actually carries a Dvd's own `runtime` and `director` fields instead of a Cd's `artist` and `tracklist`. Something else has to fill that gap in a Firestore-based app. The real options are: validating shape in application code before every write (easy to get right once, easy to forget in a second code path later); enforcing structure through Firestore Security Rules, which can check a document's own field names and types as part of deciding whether a write is even allowed; or accepting the risk for a small, single-user tool where the person writing the code is also the only person who will ever call these write functions. Chapter 2 covers which of these this course actually reaches for. WHY THIS WORKS AS AN ANSWER ---------------------------- It names the specific, concrete guarantee Mongoose discriminators provide (a rejected write before the database ever sees it) rather than a vague "MongoDB has schemas" claim, correctly identifies that Firestore provides no equivalent at the database layer, and lists genuine, specific alternatives rather than asserting Firestore is simply "unsafe."