• Start

Methods

insert

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

Inserts one or more records into a table. This is a convenience wrapper that runs `INSERT INTO

;`.

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

Argument

Description

table

The table to insert into.

data_json

A single record or an array of records, as a JSON string.

session

An optional session id.

txn

An optional transaction id.

var resp = client.insert("person", '[{ "name": "Alice" }, { "name": "Bob" }]')
INSERT INTO $table $data_json;

Was this page helpful?