• Start

Languages

/

Mojo

/

Methods

patch

The patch() method for the SurrealDB Mojo SDK applies a JSON Patch to a record.

Applies a JSON Patch to all records in a table, or a specific record. This is a convenience wrapper that runs UPDATE <thing> PATCH <patch_json>;.

Method Syntax

client.patch(thing, patch_json, session, txn)
ArgumentDescription
thingThe table or specific record to patch.
patch_jsonA JSON Patch array as a JSON string.
sessionAn optional session id.
txnAn optional transaction id.
var resp = client.patch("person:chiru", '[{ "op": "replace", "path": "/age", "value": 31 }]')
UPDATE $thing PATCH $patch_json;

Was this page helpful?