SurrealDB Docs Logo

Enter a search query

->create()

Creates a record in the database.

Method Syntax
$db->create(thing, data)

Arguments

ArgumentsDescription
thing required

The table name or a RecordId to create.

data optional

The document / record data to create.

Example usage

// Create a record with a random ID [$person] = $db->create('person'); // Create a record with a specific ID $person = $db->create(new RecordId('person', 'tobie'), [ "name" => 'Tobie', "settings" => [ "active" => true, "marketing" => true, ], ]); // The content you are creating the record with might differ from the return type [$record] = $db->create( new RecordId('person', 'tobie'), ["name" => "Tobie"] );

Translated query

This function will run the following query in the database.

CREATE $thing CONTENT $data;

On this page

© SurrealDB GitHub Discord Community Cloud Features Releases Install