Enforce shape at the database
$jsonSchema validators reject invalid documents. validationAction: "error" blocks bad inserts; "warn" logs them.
Schemaless is a feature. Schema validation is the apology letter to your future ops team.
Output
Press Run to execute your code.