SurrealDB Docs Logo

Enter a search query

.Insert[T](table, data)

Inserts one or multiple records in the database.

Method Syntax
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

// Insert an entry person2, err := surrealdb.Insert[Person](db, models.Table("persons"), map[interface{}]interface{}{ "Name": "Jane", "Surname": "Smith", "Location": models.NewGeometryPoint(-0.12, 22.01), }) if err != nil { panic(err) } fmt.Printf("Inserted person with a map: %+v\n", person2)

On this page

© SurrealDB GitHub Discord Community Cloud Features Releases Install