Content Management API > Model/Block
List models referencing another model/block
Returns all models that reference the specified item type, either directly through fields or indirectly through nested blocks.
For Block Models (modular_block: true)
Returns all models that can embed the specified block model, including:
Direct embedding via:
rich_textfields (Modular Content) — specified in therich_text_blocksvalidatorsingle_blockfields — specified in thesingle_block_blocksvalidatorstructured_textfields — specified in thestructured_text_blocksorstructured_text_inline_blocksvalidators
Indirect embedding:
- Models that embed other block models, which themselves contain fields that can embed the target block (recursive traversal through nested block structures)
For Regular Models (modular_block: false)
Returns all models that reference the specified model, including:
Direct references via:
linkfields (Single link) — specified in theitem_item_typevalidatorlinksfields (Multiple links) — specified in theitems_item_typevalidatorstructured_textfields — specified in thestructured_text_linksvalidator
Indirect references:
- Models that embed block models containing fields that reference the target model (traversal through nested block structures to find references within blocks)
Returns
Returns an array of resource objects of type item_type
Examples
import { buildClient } from "@datocms/cma-client-node";
async function run() { const client = buildClient({ apiToken: process.env.DATOCMS_API_TOKEN });
const modelIdOrApiKey = "blog_post";
const itemTypes = await client.itemTypes.referencing(modelIdOrApiKey);
for (const itemType of itemTypes) { // Check the 'Returned output' tab for the result ☝️ console.log(itemType); }}
run();{ id: "DxMaW10UQiCmZcuuA-IkkA", name: "Blog post", api_key: "post", singleton: false, sortable: true, modular_block: false, tree: false, ordering_direction: null, ordering_meta: "created_at", draft_mode_active: false, all_locales_required: false, collection_appearance: "compact", hint: "Blog posts will be shown in our website under the Blog section", inverse_relationships_enabled: false, draft_saving_active: false, meta: { has_singleton_item: false }, singleton_item: null, fields: [{ type: "field", id: "Pkg-oztERp6o-Rj76nYKJg" }], fieldsets: [{ type: "fieldset", id: "93Y1C2sySkG4Eg0atBRIwg" }], presentation_title_field: null, presentation_image_field: null, title_field: null, image_preview_field: null, excerpt_field: null, ordering_field: null, workflow: null,}