Pular para o conteúdo principal

ModelInstance <D>

An Instance that provide methods to request information from a Model, its Entries, and its Categories.

You can access a ModelInstance using StarlightClient.model or using the dynamic syntax on a DynamicStarlightClient. Usage examples will use the dynamic syntax.

To list all workspace models, use a ModelSelector.

Index

Accessors

categories

  • Returns a DynamicModelCategorySelector.

    This is an accessor, which means that it should be used just like a common object parameter. For instance:

    import Starlight from '@starlightcms/js-sdk'

    // "categories" below is a DynamicModelCategorySelector.
    const response = await Starlight.posts.categories.get('interviews')

    Returns DynamicModelCategorySelector<D>

entries

  • Returns an EntrySelector.

    This is an accessor, which means that it should be used just like a common object parameter. For instance:

    import Starlight from '@starlightcms/js-sdk'

    // "entries" below is an EntrySelector.
    const response = await Starlight.posts.entries.list()

    Returns EntrySelector<D>

Methods

category

  • Returns a ModelCategoryInstance.

    If you’re using a DynamicModelInstance, you can use the dynamic syntax instead of this method.

    @example

    Listing all entries from the “news” category of a model of slug “posts”.

    import Starlight from '@starlightcms/js-sdk'

    const response = await Starlight.posts.category('news').entries()

    Parameters

    • slug: string

      The category slug.

    Returns ModelCategoryInstance<D>

get