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(RecordID('person', 'tobie'), { "name": 'Tobie', "settings": { "active": True, "marketing": True, } })

Translated query

This function will run the following query in the database.

CREATE $thing CONTENT $data