📆 Don't miss our Sanity Showcase virtual meetup on March 20th!
@public
function

append()

Creates an insert operation that appends the provided items.

Import

import {append} from 'sanity/migrate'

Signature

function append<Items extends AnyArray<unknown>>(items: Items | ArrayElement<Items>): InsertOp<NormalizeReadOnlyArray<Items>, 'after', -1>
function append<Items extends AnyArray<unknown>>(items: Items | ArrayElement<Items>): InsertOp<NormalizeReadOnlyArray<Items>, 'after', -1>

Returns

InsertOp<NormalizeReadOnlyArray<Items>, 'after', -1>
InsertOp<NormalizeReadOnlyArray<Items>, 'after', -1>

An insert operation for adding a value to the end of an array. https://www.sanity.io/docs/http-patches#Cw4vhD88

Examples

const appendFoo = append('foo')
const appendObject = append({name: 'foo'})
const appendObjects = append([{name: 'foo'}, [{name: 'bar'}]])
sanity@3.79.0