SurrealDB Docs Logo

Enter a search query

.Insert<T>()

Inserts one or multiple records in the database.

Method Syntax
await db.Insert<T>(table, data)

Arguments

ArgumentsDescription
table optional

Optionally pass along a table to insert into.

data optional

Either a single document/record or an array of documents/records to insert

cancellationToken optional

The cancellationToken enables graceful cancellation of asynchronous operations.

Example usage

var posts = new List<Post> { new Post { Id = ("post", "First"), Title = "An article", Content = "This is the first article" }, new Post { Id = ("post", "Second"), Title = "An article", Content = "This is the second article" } }; await db.Insert("post", posts);

On this page

© SurrealDB GitHub Discord Community Cloud Features Releases Install