I’m confused with usage of components and reference fields in the Schemas so maybe I could get some clarifications.
If I use Components field in Schema and use different schema that exists and it’s created in squidex system, am I able to retrieve the content of the Components field as separate content?
For example, I have Job as Schema and JobDescription as other schema, and it’s used in Components field in Job schema.
When I create job and, let’s say two descriptions, I see JobDescription content only under job content but not when I try to filter per JobDescription content under Contents tab.
Is Reference field solution to this? To be able to get content separately from ‘parent’ schema as we need something like get me all job descriptions with that location.
If I use Refereneces type then I need first to create JobDescription content in separate api calls, then use ids to add to Reference field. Is there any way to fetch combined data when I’m getting job all together with JobDescription content not only ids?
Sorry on my long post. If you could point me in right direction, I would appreciate a lot.
Components and references are similar but also totally different:
a) Live inside the main content
b) Can only be retrieved together with the content.
c) Don’t have its own history.
d) Don’t have its own ID, creation and modified flag.
e) Cannot be referenced by other content items.
a) Live outside of the main content
b) Need an additional API call to be retrieved
c) Have its own history
d) Have its own ID, creation and modified flag.
e) Can be referenced by other content items.
So it depends on your use case whether components or arrays are useful.
Good examples for components or component:
- Page structure
- Pricing information (if you use a single component)
Good examples for references:
As mentioned references need an additional API call, BUT if you use GraphQL this is handled for you and you can also get the referenced items with the same API call. It is still slower than components, because an additional database call is needed, but usually the performance is acceptable because the references are queried by primary ID (therefore an index is used) and only one additional API call per level is needed (one db all for the references of the root content items, another for the references of the references and so on, independent of the number of content items returned).
Thanks for clarification!