Pular para o conteúdo principal

EntrySelector <D>

A Selector that provide methods to list and request information on Entries.

You can use an EntrySelector by accessing ModelInstance.entries.

Index

Methods

Methods

get

  • Returns a StarlightItemResponse with a single Entry. Supports revision previewing by passing a preview parameter.

    @example

    Requesting information from an entry “hello-world” from a model of slug “posts”.

    import Starlight from '@starlightcms/js-sdk'

    const response = await Starlight.posts.entries.get('hello-world')
    @example

    Passing a preview token on the last example.

    import Starlight from '@starlightcms/js-sdk'

    const response = await Starlight.posts.entries.get('hello-world', {
    preview: 'CDfkvt1zTF5XhxWzi2Lejgo1'
    })

    Parameters

    • slug: string

      The entry slug.

    • optionalparams: GetEntryParams

      An optional object of request parameters. See GetEntryParams for all available options.

    • optionaloptions: RequestInit

      An optional object of Fetch parameters. Use it to modify the fetch request.See MDN documentation on fetch() for all available options.

    Returns Promise<StarlightItemResponse<Entry<D>>>

list

  • Returns a StarlightListResponse with a list of Entries.

    @example

    Requesting all entries from a model of slug “recipes”.

    import Starlight from '@starlightcms/js-sdk'

    const response = await Starlight.recipes.entries.list()
    @example

    Paginating and searching on the last example.

    import Starlight from '@starlightcms/js-sdk'

    const response = await Starlight.recipes.entries.list({
    page: 2,
    query: 'gravy',
    'field:is_vegan': true,
    })
    @example

    Ordering entries by number of views.

    import Starlight from '@starlightcms/js-sdk'

    const response = await Starlight.recipes.entries.list({
    order: 'views:desc'
    })

    Parameters

    Returns Promise<StarlightListResponse<Entry<D>>>