Choose your language:
    Update a model
    Parameters
    name  string  Optional

    Name of the model

    apiKey  string  Optional

    API key of the model

    collectionAppearance  enum  Optional

    The way the model collection should be presented to the editors

    singleton  boolean  Optional

    Whether the model is single-instance or not

    allLocalesRequired  boolean  Optional

    Whether we require all the project locales to be present for each localized field or not

    sortable  boolean  Optional

    Whether editors can sort records via drag & drop or not

    modularBlock  boolean  Optional

    Whether this model is a modular content block or not

    draftModeActive  boolean  Optional

    Whether draft/published mode is active or not

    tree  boolean  Optional

    Whether editors can organize records in a tree or not

    orderingDirection  enum, null  Optional

    If an ordering field is set, this fields specify the sorting direction

    orderingMeta  enum, null  Optional

    Specifies the model's sorting method. Cannot be set in concurrency with ordering_field

    hint  string, null  Optional

    A hint shown to editors to help them understand the purpose of this model/block

    orderingField  field.id, null  Optional

    The field upon which the collection is sorted

    titleField  field.id, null  Optional

    The field to use as display title

    workflow  workflow.id, null  Optional

    The workflow to enforce on records

    Returns
    Returns a item_type object.

    Examples

    Example code:
    const SiteClient = require('datocms-client').SiteClient;
    const client = new SiteClient('YOUR-API-TOKEN');
    const modelIdOrApiKey = 'blog_post';
    client.itemType.update(modelIdOrApiKey, {
    name: 'Blog post',
    apiKey: 'post',
    collectionAppearance: 'compact',
    singleton: false,
    allLocalesRequired: false,
    sortable: true,
    modularBlock: false,
    draftModeActive: false,
    tree: false,
    orderingDirection: null,
    orderingMeta: 'created_at',
    hint: 'Blog posts will be shown in our website under the Blog section',
    orderingField: null,
    titleField: null,
    workflow: null
    })
    .then((itemType) => {
    console.log(itemType);
    })
    .catch((error) => {
    console.error(error);
    });
    Returned output:
    > node example.js
    {
    "id": "44",
    "name": "Blog post",
    "apiKey": "post",
    "collectionAppearance": "compact",
    "singleton": false,
    "allLocalesRequired": false,
    "sortable": true,
    "modularBlock": false,
    "draftModeActive": false,
    "tree": false,
    "orderingDirection": null,
    "orderingMeta": "created_at",
    "hasSingletonItem": false,
    "hint": "Blog posts will be shown in our website under the Blog section",
    "singletonItem": null,
    "fields": [
    "124"
    ],
    "titleField": null,
    "orderingField": null,
    "workflow": null
    }