Docs Menu

Docs HomeAtlas App Services

Enforce a Schema

On this page

  • Overview
  • Procedure
  • Navigate to the Collection Schema Screen
  • Generate a Schema
  • Add Field-Level Schema Definitions
  • Add Change Validation Expressions
  • Save the Schema
  • Validate Documents Against the Schema
  • Log In to MongoDB Cloud
  • Pull the Latest Version of Your App
  • Define the Schema
  • Define Change Validation
  • Deploy the Updated Schema
  • Validate Null Types

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.

Note

Federated data sources do not support rules or schemas. You can only access a Federated data source from a system function.

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 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 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 →
Share Feedback
© 2022 MongoDB, Inc.

About

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