• Start

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 CONTENT ;`.

Method Syntax
client.upsert(thing, content_json, session, txn)

Argument

Description

thing

The table or specific record to upsert.

content_json

The record content as a JSON string.

session

An optional session id.

txn

An optional transaction id.

var resp = client.upsert("person:chiru", '{ "name": "Chiru", "age": 31 }')
UPSERT $thing CONTENT $content_json;

Was this page helpful?