• Start

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

;`.

Method Syntax
client.insert_relation(table, data_json, session, txn)

Argument

Description

table

The relation table to insert into.

data_json

A single relation or an array of relations, as a JSON string. Each carries an

in

and an

out

record.

session

An optional session id.

txn

An 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?