Understanding object types and schemas in Sanity.io

25 replies
Last updated: Feb 18, 2021
If I go with an object, I will have to lift it up, meaning I have to define it as a type, but this would then automatically show up as an option to define for editors?
Feb 17, 2021, 4:01 PM
Hi User. The object shouldn’t add to your hierarchy.
Feb 17, 2021, 4:02 PM
Hm. Creating the object would generally mean to:1. add it as a type
2. add it to the schema file
Feb 17, 2021, 4:04 PM
Correct?
Feb 17, 2021, 4:04 PM
And as I understand, this would add them to the general studio type sidebar.
Feb 17, 2021, 4:08 PM
Let me double check.
Feb 17, 2021, 4:08 PM
Sorry, I misunderstood you at first. Yes, that’s correct about the steps required. It’s generally a good thing as it allows for re-use.
An object won’t appear in the left-most sidebar in Sanity. Only documents.
Feb 17, 2021, 4:09 PM
There is some error in my conception of the whole process. Is there any good video that follows somebody through the creation of some complex schemas besides the simple introductionary ones?
Feb 17, 2021, 4:10 PM
Thank you for the help and the patience, User. Much appreciated.
Feb 17, 2021, 4:11 PM
Let me test a little first and then get back to you, if I still struggle with it.
Feb 17, 2021, 4:11 PM
Please let me find one for you. In the meantime, https://www.sanity.io/docs/object-type and https://www.sanity.io/docs/document-type offer some distinctions between the types. This distinction on the object page might help:

By default, object types can not be represented as standalone documents in the data store. If you want to define an object type that you’d like to be represented as a document with an id, revision and created and updated timestamps, you should define it using the 
document
 type instead. Apart from these additional fields, there’s no semantic difference between a document and an object.
Feb 17, 2021, 4:12 PM
Also, I’d invite you to check out fieldsets to see if they accomplish what you’re after.
Feb 17, 2021, 4:15 PM
And make sure to check out Knut’s video series on customizing schemas: https://www.youtube.com/watch?v=GbQ4dbQqduk
Feb 17, 2021, 4:21 PM
Sorry, last thing! 😆
I have found it valuable to set up some of Sanity’s starters and inspect their schemas. It definitely gives some insight into what’s possible and how things work.
Feb 17, 2021, 4:23 PM
I went through Knuts video series already and a lot of the docs. I will go through the things you have linked now and also inspect some of the starter schemas.
Feb 17, 2021, 4:24 PM
Thanks a lot for the valuable input, User!
Feb 17, 2021, 4:24 PM
Any time, User! 🙂 🙌
Feb 17, 2021, 4:25 PM
user A
Dead links found 🙂 (the last two)
Feb 17, 2021, 5:34 PM
Is there a github repo for the docs so that I can help correct the docs, if I stumble over anything?
Feb 17, 2021, 5:37 PM
user L
Those were just there to make sure you read them. 😆
Kidding. I’ll report those to the Sanity team. Thanks so much!
Feb 17, 2021, 5:38 PM
Feb 17, 2021, 5:39 PM
Thanks for reporting those, User. User has already fixed them! 🚤
Feb 17, 2021, 5:59 PM
You are welcome User! Thank you for being that responsive in terms of help! :)
Feb 17, 2021, 6:24 PM
Hey
user A
!
In case anybody else is asking:
This series from User is genius when it comes to explaining the whole process of schema creation and organization. All the way from mapping out the schema in Figma, to explaining the documents, objects, plugs folder pattern used in the kitchen sink starter.

Invidious Link:

https://invidious.tube/playlist?list=PL46OzlGGU84RZw0R73RhMeqBZWlgBMHsg Youtube Link:

https://www.youtube.com/playlist?list=PL46OzlGGU84RZw0R73RhMeqBZWlgBMHsg
Feb 18, 2021, 7:16 AM
The exact video and time stamp mentioning the opinionated approach, documents, objects, plugs:
https://youtu.be/-B_Fxd6TMwA?t=112
Feb 18, 2021, 7:20 AM

Sanity– build remarkable experiences at scale

Sanity is a modern headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.

Was this answer helpful?