Change Intelligence is coming.

Couchbase mutateIn

Last updated: July 13, 2026

Performs sub-document mutations on documents in a Couchbase collection, allowing you to modify, insert, or remove specific fields within a document without replacing the entire document.

Known limitations:

  • INCREMENT and DECREMENT operations only work on numeric (Long) values.

  • ARRAY_INSERT_UNIQUE throws an error if the value already exists in the array.

  • There is no automatic rollback support.

Available attributes

You must specify all top-level attributes marked as required. If you specify an optional attribute, you must also specify any nested attributes that it requires.

Attribute

Type

Description

Required

bucketName

String

The name of the bucket containing the collection.

Yes

scopeName

String

The name of the scope containing the collection.

Yes

collectionName

String

The name of the collection containing the document(s).

Yes

mutateInSpecs

Element

One or more sub-document mutation operations to perform. See nested tags below.

Yes

id

String

The key of a specific document to target. Mutually exclusive with whereCondition and sqlPlusPlusQuery.

Yes*

whereCondition

String

An N1QL WHERE clause identifying documents to target. Mutually exclusive with id and sqlPlusPlusQuery.

Yes*

sqlPlusPlusQuery

String

A full SQL++ query for document selection. Mutually exclusive with id and whereCondition.

Yes*

expiry

String

ISO 8601 duration for document expiry after mutation (e.g., PT5M for 5 minutes).

No

preserveExpiry

Boolean

When true, preserves the document's existing expiry setting.

No

storeSemantics

String

Controls how the mutated document is stored. REPLACE requires the document to already exist. UPSERT inserts or replaces the document. INSERT requires the document to not already exist. REVIVE restores a deleted document.

No

Nested tags — mutateInSpec (within mutateInSpecs)

Attribute

Type

Description

Required

path

String

The JSON path to the document field to target. Use an empty string to target the root document.

Yes

mutateInType

String

The mutation operation. INSERT adds a new field. UPSERT inserts or replaces a field. REPLACE replaces an existing field. REMOVE removes a field. ARRAY_PREPEND prepends a value to an array. ARRAY_APPEND appends a value to an array. ARRAY_CREATE creates a new array. ARRAY_INSERT inserts a value at a specific array position. ARRAY_INSERT_UNIQUE inserts a value only if it is not already present. INCREMENT increments a numeric value. DECREMENT decrements a numeric value.

Yes

value

Element

The new value for the targeted path. Required for all operations except REMOVE. See nested tags below.

No

Nested tags — value (within mutateInSpec)

Attribute

Type

Description

Required

data

String

The value content as a string, formatted according to the specified type.

Yes

type

String

The data type of data. Json is a JSON object. String is a plain string. Long is an integer. Double is a floating-point number. Boolean is a boolean. JsonArray is a JSON array.

Yes

loading

loading

loading