• Start

Languages

/

Mojo

/

Methods

insert_relation

The insert_relation() method for the SurrealDB Mojo SDK inserts one or more relations into a table.

Inserts one or more relation records into a table. This is a convenience wrapper that runs INSERT RELATION INTO <table> <data_json>;.

Method Syntax

client.insert_relation(table, data_json, session, txn)
ArgumentDescription
tableThe relation table to insert into.
data_jsonA single relation or an array of relations, as a JSON string. Each carries an in and an out record.
sessionAn optional session id.
txnAn optional transaction id.
var resp = client.insert_relation(
"likes",
'[{ "in": "person:alice", "out": "person:bob" }]',
)
INSERT RELATION INTO $table $data_json;

Was this page helpful?