• Start

Languages

/

Mojo

/

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 <table> <data_json>;.

Method Syntax

client.insert(table, data_json, session, txn)
ArgumentDescription
tableThe table to insert into.
data_jsonA single record or an array of records, as a JSON string.
sessionAn optional session id.
txnAn optional transaction id.
var resp = client.insert("person", '[{ "name": "Alice" }, { "name": "Bob" }]')
INSERT INTO $table $data_json;

Was this page helpful?