SurrealDB Docs Logo

Enter a search query

.Create<T>()

Creates a record in the database.

Method Syntax
await db.Create<T>(resource, data)

Arguments

ArgumentsDescription
thing required

The table name or a RecordId to create.

data optional

The document / record data to insert.

cancellationToken optional

The cancellationToken enables graceful cancellation of asynchronous operations.

Example usage

// Create a record with a random ID var person = await db.Create<Person>("person"); // Create a record with a random ID & specific fields var person = await db.Create("person", new Person { Name = "Tobie" }); // Create a record with a specific ID var personToCreate = new Person { Id = ("person", "tobie"), Name = "Tobie", Settings = new Settings { Active = true, Marketing = true, }, }; var result = await db.Create(personToCreate);

On this page

© SurrealDB GitHub Discord Community Cloud Features Releases Install