Help articles

Introducing the document type

Studio v0.118.0 introduced the document schema type for any type you want to store as a document in the Content Lake. Before that release, any top-level object type could become a document. From v0.118.0 onward, a type must be declared as document to be stored as one: only document types appear in the Structure tool's content column, and only documents can be referenced from other documents or fetched by ID. This applies to every Studio version since, including Studio v3 and v4.

Keep reusable object types as objects

Convert top-level object types to document types

Current Studio versions have no fallback: a top-level object type is never listed in the Structure tool's content column, and you cannot create documents of it. Change every top-level type you want stored as a document from object to document. Replace PROJECT_ID with your project ID. For example, if your schema defines a book type as an object:

import {defineConfig, defineType, defineField} from 'sanity'

export default defineConfig({
  name: 'default',
  projectId: 'PROJECT_ID',
  dataset: 'production',
  schema: {
    types: [
      defineType({
        name: 'book',
        title: 'Book',
        type: 'object',
        fields: [defineField({name: 'title', type: 'string'})],
      }),
    ],
  },
})

Change it to:

import {defineConfig, defineType, defineField} from 'sanity'

export default defineConfig({
  name: 'default',
  projectId: 'PROJECT_ID',
  dataset: 'production',
  schema: {
    types: [
      defineType({
        name: 'book',
        title: 'Book',
        type: 'document',
        fields: [defineField({name: 'title', type: 'string'})],
      }),
    ],
  },
})

Do this for every top-level type in your schema that you want stored as a document.

Next steps

Read the Document type reference and the Object type reference for the full type definitions and properties.

Was this page helpful?