Set up Data Schema

Using the web console (opens in a new tab), navigate to the Schema section in the side menu, select your collection from the list, then click the edit icon in the top right corner of the Schemas box.

In this example, we are defining a schema for the people collection, which dictates that the document must be an object and should include required fields for name (with a data type of string) and age (with a data type of number).

Schema
{
  type: "object",
  required: ["name", "age"],
  properties: {
    name: { type: "string" },
    age: { type: "number" }
  }
}

You can copy & paste the schema object above to the popped-up textarea and click Add.

With the defined schema, you cannot add a document that violates the schema requirements. For example:

Web Console Terminal
set {name:123,age:"Bob"} people Bob