Sanity Library Reference Docs
    Preparing search index...

    Function insert

    • Creates an insert operation with the provided items, position, and reference item.

      Returns any

      An insert operation for adding values to arrays https://www.sanity.io/docs/http-patches#febxf6Fk

      const prependFoo = insert(['foo'], 'before', 0)
      const appendFooAndBar = insert(['foo', 'bar'], 'after', someArray.length -1)
      const insertObjAfterXYZ = insert({name: 'foo'}, 'after', {_key: 'xyz'}])