• Start

Languages

/

Mojo

/

Methods

upsert

The upsert() method for the SurrealDB Mojo SDK upserts all records in a table, or a specific record.

Creates a record if it does not exist, or updates it if it does. This is a convenience wrapper that runs UPSERT <thing> CONTENT <content_json>;.

Method Syntax

client.upsert(thing, content_json, session, txn)
ArgumentDescription
thingThe table or specific record to upsert.
content_jsonThe record content as a JSON string.
sessionAn optional session id.
txnAn optional transaction id.
var resp = client.upsert("person:chiru", '{ "name": "Chiru", "age": 31 }')
UPSERT $thing CONTENT $content_json;

Was this page helpful?