Sanity Library Reference Docs
    Preparing search index...

    Type Alias FieldMutationOp<TTarget>

    FieldMutationOp:
        | { target: TTarget; type: "field.set"; value: ValueExpr }
        | { target: TTarget; type: "field.setIfMissing"; value: ValueExpr }
        | { target: TTarget; type: "field.unset" }
        | { target: TTarget; type: "field.append"; value: ValueExpr }
        | { target: TTarget; type: "field.inc"; value?: ValueExpr }
        | { target: TTarget; type: "field.dec"; value?: ValueExpr }
        | {
            target: TTarget;
            type: "field.updateWhere";
            value: ValueExpr;
            where: Condition;
        }
        | { target: TTarget; type: "field.removeWhere"; where: Condition }

    A field mutation targeting a declared field. Resolved values must satisfy that field's shape, choices, validation, and assignment constraints.

    field.setIfMissing supports nullable fields only. If a value exists, it leaves the value unchanged and records no opApplied history event. field.inc and field.dec require an initialized number field; their delta defaults to 1. Both the delta and resulting value must be finite, and the result must satisfy the field's validation bounds.

    field.append adds one valid list member. field.updateWhere accepts only array fields and merges an object into matching rows. The merge cannot write _key or _type, and each resulting row must satisfy its declared shape. field.removeWhere supports list fields. See Op for row selection and history behavior.

    Type Parameters

    • TTarget extends { field: string }