Understanding object types and schemas in Sanity.io
25 replies
Last updated: Feb 18, 2021
L
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
G
Hi User. The object shouldn’t add to your hierarchy.
Feb 17, 2021, 4:02 PM
L
Hm. Creating the object would generally mean to:1. add it as a type
2. add it to the schema file
2. add it to the schema file
Feb 17, 2021, 4:04 PM
L
Correct?
Feb 17, 2021, 4:04 PM
L
And as I understand, this would add them to the general studio type sidebar.
Feb 17, 2021, 4:08 PM
L
Let me double check.
Feb 17, 2021, 4:08 PM
G
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.
An object won’t appear in the left-most sidebar in Sanity. Only documents.
Feb 17, 2021, 4:09 PM
L
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
L
Thank you for the help and the patience, User. Much appreciated.
Feb 17, 2021, 4:11 PM
L
Let me test a little first and then get back to you, if I still struggle with it.
Feb 17, 2021, 4:11 PM
G
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 thedocumenttype instead. Apart from these additional fields, there’s no semantic difference between a document and an object.
Feb 17, 2021, 4:12 PM
G
I really like this guide: https://www.sanity.io/guides/implementing-a-content-model-in-sanity-io
Feb 17, 2021, 4:13 PM
G
Also, I’d invite you to check out fieldsets to see if they accomplish what you’re after.
Feb 17, 2021, 4:15 PM
G
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
G
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.
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
L
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
L
Thanks a lot for the valuable input, User!
Feb 17, 2021, 4:24 PM
G
Any time, User! 🙂 🙌
Feb 17, 2021, 4:25 PM
L
user A
Dead links found 🙂 (the last two)Feb 17, 2021, 5:34 PM
L
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
G
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
G
https://www.sanity.io/docs/donts-and-dos
https://www.sanity.io/docs/naming-things
Here are the correct links in the meantime.
https://www.sanity.io/docs/naming-things
Here are the correct links in the meantime.
Feb 17, 2021, 5:39 PM
G
Thanks for reporting those, User. User has already fixed them! 🚤
Feb 17, 2021, 5:59 PM
L
You are welcome User! Thank you for being that responsive in terms of help! :)
Feb 17, 2021, 6:24 PM
L
Hey
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
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
L
The exact video and time stamp mentioning the opinionated approach, documents, objects, plugs:
https://youtu.be/-B_Fxd6TMwA?t=112
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.