Docs Menu

Enforce a Schema

On this page

You can control the shape and contents of documents in a collection by defining a schema. Schemas let you require specific fields, control the type of a field's value, and validate changes before committing write operations.

This guide shows you how to define, configure, and deploy a schema for a linked MongoDB Atlas collection.

Data Lakes Do Not Support Schemas

Data Lake data sources do not support schema validation or data access rules. You can only access a Data Lake data source in a system function.

Atlas App Services's default behavior is to only accept a single type for each field. Schema fields are not nullable by default because null is a unique BSON type.

You can configure Atlas App Services to pass schema validation when you use null values with optional fields. Enabling null type validation allows the value for a field to be persisted as the type in the schema or the BSON null type. If you do not enable null type schema validation, App Services rejects null values passed to optional fields. Even if you enable null type validation, required fields are never nullable.

To enable null type schema validation in the Atlas App Services UI:

  1. In the left navigation menu below the Manage header, select App Settings.
  2. On the General tab, navigate to the Null Type Schema Validation section. Toggle the switch to ON.
  3. Click the Save button.
←  SchemasRemove a Schema →
Give Feedback
© 2022 MongoDB, Inc.


  • Careers
  • Investor Relations
  • Legal Notices
  • Privacy Notices
  • Security Information
  • Trust Center
© 2022 MongoDB, Inc.